Files
dss/scripts/setup-mcp.sh
2025-12-11 18:55:57 -03:00

71 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
# Generate .claude/mcp.json with absolute paths for current setup
#
# USAGE:
# ./scripts/setup-mcp.sh
#
# This script generates the MCP configuration file needed for Claude Code
# to access DSS tools. Run this after cloning or when switching machines.
set -e
DSS_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
MCP_CONFIG_DIR="$DSS_ROOT/.claude"
MCP_CONFIG="$MCP_CONFIG_DIR/mcp.json"
# Ensure .claude directory exists
mkdir -p "$MCP_CONFIG_DIR"
# Detect Python venv location
if [ -d "$DSS_ROOT/.venv" ]; then
PYTHON_PATH="$DSS_ROOT/.venv/bin/python3"
elif [ -d "$DSS_ROOT/venv" ]; then
PYTHON_PATH="$DSS_ROOT/venv/bin/python3"
else
echo "Error: No Python virtual environment found at .venv or venv"
echo "Create one with: python3 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt"
exit 1
fi
# Verify MCP server exists
MCP_SERVER="$DSS_ROOT/dss-claude-plugin/servers/dss-mcp-server.py"
if [ ! -f "$MCP_SERVER" ]; then
echo "Error: MCP server not found at $MCP_SERVER"
exit 1
fi
cat > "$MCP_CONFIG" << EOF
{
"\$schema": "https://raw.githubusercontent.com/anthropics/claude-code/main/schemas/mcp-servers.schema.json",
"mcpServers": {
"dss": {
"command": "$PYTHON_PATH",
"args": ["$MCP_SERVER"],
"env": {
"PYTHONPATH": "$DSS_ROOT:$DSS_ROOT/dss-claude-plugin",
"DSS_HOME": "$DSS_ROOT/.dss",
"DSS_DATABASE": "$DSS_ROOT/.dss/dss.db",
"DSS_CACHE": "$DSS_ROOT/.dss/cache",
"DSS_BASE_PATH": "$DSS_ROOT"
},
"description": "Design System Server MCP - local development"
}
}
}
EOF
echo "Generated MCP config: $MCP_CONFIG"
echo ""
echo "Configuration:"
echo " DSS_ROOT: $DSS_ROOT"
echo " Python: $PYTHON_PATH"
echo " MCP Server: $MCP_SERVER"
echo ""
# Optionally install the DSS plugin for commands/skills
echo "To install DSS plugin commands (optional):"
echo " claude plugin marketplace add $DSS_ROOT/dss-claude-plugin"
echo " claude plugin install dss-claude-plugin@dss"
echo ""
echo "Restart Claude Code to load the DSS MCP server."