#!/bin/bash # Generate .claude/mcp.json with absolute paths for current setup # # USAGE: # ./scripts/setup-mcp.sh [--api-url https://dss.example.com] # # 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" # Defaults API_URL="" while [[ $# -gt 0 ]]; do case "$1" in --local) # Kept for backwards-compatibility; MCP server is always local now. shift ;; --api-url) API_URL="${2:-}" if [ -z "$API_URL" ]; then echo "Error: --api-url requires a value" exit 1 fi shift 2 ;; *) echo "Unknown argument: $1" echo "Usage: ./scripts/setup-mcp.sh [--api-url https://dss.example.com]" exit 1 ;; esac done # 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 MCP_ARGS='["-m", "dss.mcp.server"]' MCP_SERVER_DESC="python -m dss.mcp.server" PYTHONPATH_VALUE="$DSS_ROOT" 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_ARGS, "env": { "PYTHONPATH": "$PYTHONPATH_VALUE", "DSS_HOME": "$DSS_ROOT/.dss", "DSS_CACHE": "$DSS_ROOT/.dss/cache", "DSS_BASE_PATH": "$DSS_ROOT", "DSS_ENABLE_DEV_COMMANDS": "1", "DSS_API_URL": "$API_URL" }, "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_DESC" if [ -n "$API_URL" ]; then echo " DSS_API_URL: $API_URL" fi echo "" echo "Optional: install DSS Claude plugin commands/skills:" 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."