Unify MCP across clients; remove legacy plugin server
Some checks failed
DSS Project Analysis / dss-context-update (push) Has been cancelled

This commit is contained in:
DSS
2025-12-12 14:33:18 -03:00
parent 1d53ec341d
commit ec09a0a662
60 changed files with 3451 additions and 4668 deletions

View File

@@ -5,12 +5,12 @@
# Portable single-server launcher. One command, one port, everything included.
#
# Usage:
# ./dss start Start DSS (UI + API on port 3456)
# ./dss dev Development mode with auto-reload
# ./dss stop Stop DSS server
# ./dss status Check service status
# ./dss config Show current configuration
# ./dss help Show this help
# ./scripts/dss start Start DSS (UI + API on one port)
# ./scripts/dss dev Development mode with auto-reload
# ./scripts/dss stop Stop DSS server
# ./scripts/dss status Check service status
# ./scripts/dss config Show current configuration
# ./scripts/dss help Show this help
#
set -e
@@ -21,7 +21,7 @@ UI_DIR="$DSS_ROOT/admin-ui"
VENV_DIR="$DSS_ROOT/.venv"
PID_FILE="$DSS_ROOT/.dss/dss.pid"
LOG_FILE="$DSS_ROOT/.dss/dss.log"
PORT="${DSS_PORT:-3456}"
PORT="${DSS_PORT:-6220}"
# Colors
RED='\033[0;31m'
@@ -200,8 +200,8 @@ show_config() {
echo "═══════════════════════════════════════════════════"
echo ""
if curl -s http://localhost:3456/api/config > /dev/null 2>&1; then
curl -s http://localhost:3456/api/config | python3 -m json.tool
if curl -s "http://localhost:$PORT/api/config" > /dev/null 2>&1; then
curl -s "http://localhost:$PORT/api/config" | python3 -m json.tool
else
warn "DSS not running. Showing file-based config..."
if [ -f "$DSS_ROOT/.dss/runtime-config.json" ]; then
@@ -234,14 +234,14 @@ show_help() {
echo " help Show this help"
echo ""
echo "Environment:"
echo " DSS_PORT Override default port (default: 3456)"
echo " DSS_PORT Override default port (default: 6220)"
echo ""
echo "Examples:"
echo " ./dss start # Start on port 3456"
echo " DSS_PORT=8080 ./dss start # Start on port 8080"
echo " ./dss dev # Dev mode with auto-reload"
echo " ./scripts/dss start # Start on port 6220"
echo " DSS_PORT=8080 ./scripts/dss start # Start on port 8080"
echo " ./scripts/dss dev # Dev mode with auto-reload"
echo ""
echo "Once running, open http://localhost:3456 for:"
echo "Once running, open http://localhost:6220 for:"
echo " / Dashboard (Admin UI)"
echo " /api/* REST API endpoints"
echo " /docs Swagger documentation"

View File

@@ -4,7 +4,7 @@
# This is the single entry point for DSS setup. It handles:
# - MCP configuration
# - Dependencies (Python venv, Node modules)
# - Directory structure and database
# - Directory structure (JSON storage)
# - Figma sync and token resolution
# - CSS generation with style-dictionary
# - Storybook story generation
@@ -103,9 +103,6 @@ if [ "$RESET" = true ]; then
rm -rf .dss/data/projects/* .dss/data/teams/* .dss/data/_system/cache/* .dss/data/_system/activity/* 2>/dev/null || true
rm -rf .dss/data/_system/tokens/* .dss/data/_system/themes/* .dss/data/_system/components/* 2>/dev/null || true
# Reset database
rm -f .dss/dss.db .dss/dss.db.old
# Clear admin-ui generated files
rm -f admin-ui/css/dss-*.css 2>/dev/null || true
rm -f admin-ui/src/components/*.stories.js admin-ui/src/components/ds-*.js 2>/dev/null || true
@@ -169,26 +166,29 @@ fi
# ============================================================================
log_step "2. Generating MCP configuration..."
cat > "$DSS_ROOT/.mcp.json" << EOF
mkdir -p "$DSS_ROOT/.claude"
cat > "$DSS_ROOT/.claude/mcp.json" << EOF
{
"\$schema": "https://raw.githubusercontent.com/anthropics/claude-code/main/schemas/mcp-servers.schema.json",
"mcpServers": {
"dss": {
"command": "$DSS_ROOT/.venv/bin/python3",
"args": ["$DSS_ROOT/dss-claude-plugin/servers/dss-mcp-server.py"],
"args": ["-m", "dss.mcp.server"],
"env": {
"PYTHONPATH": "$DSS_ROOT:$DSS_ROOT/dss-claude-plugin",
"PYTHONPATH": "$DSS_ROOT",
"DSS_HOME": "$DSS_ROOT/.dss",
"DSS_DATABASE": "$DSS_ROOT/.dss/dss.db",
"DSS_CACHE": "$DSS_ROOT/.dss/cache",
"DSS_BASE_PATH": "$DSS_ROOT"
"DSS_BASE_PATH": "$DSS_ROOT",
"DSS_ENABLE_DEV_COMMANDS": "1",
"DSS_API_URL": ""
},
"description": "Design System Server MCP - local development"
}
}
}
EOF
log_ok "MCP config: .mcp.json"
log_ok "MCP config: .claude/mcp.json"
echo ""
@@ -323,36 +323,10 @@ log_ok "Directory structure ready"
echo ""
# ============================================================================
# STEP 6: Initialize Database
# STEP 6: Storage (JSON)
# ============================================================================
log_step "6. Initializing database..."
if [ ! -f ".dss/dss.db" ]; then
python3 << 'PYEOF'
import sqlite3
conn = sqlite3.connect(".dss/dss.db")
c = conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS projects (
id TEXT PRIMARY KEY, name TEXT NOT NULL, path TEXT,
config TEXT, created_at TEXT, updated_at TEXT)''')
c.execute('''CREATE TABLE IF NOT EXISTS tokens (
id TEXT PRIMARY KEY, project_id TEXT, category TEXT,
name TEXT, value TEXT, source TEXT, created_at TEXT,
FOREIGN KEY (project_id) REFERENCES projects(id))''')
c.execute('''CREATE TABLE IF NOT EXISTS components (
id TEXT PRIMARY KEY, project_id TEXT, name TEXT,
path TEXT, analysis TEXT, created_at TEXT,
FOREIGN KEY (project_id) REFERENCES projects(id))''')
c.execute('''CREATE TABLE IF NOT EXISTS figma_syncs (
id TEXT PRIMARY KEY, file_key TEXT, file_name TEXT,
tokens_count INTEGER, status TEXT, synced_at TEXT)''')
conn.commit()
conn.close()
PYEOF
log_ok "Database initialized"
else
log_ok "Database exists"
fi
log_step "6. Storage (JSON) ready..."
log_ok "Using JSON storage under .dss/data/"
echo ""

31
scripts/dss-mcp Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
set -euo pipefail
# DSS MCP stdio launcher (client-agnostic)
#
# Use this when configuring MCP clients that don't support per-server env vars,
# or when you want a single canonical entrypoint for DSS MCP across tools.
DSS_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# Prefer repo-local venv (recommended for DSS).
if [ -x "$DSS_ROOT/.venv/bin/python3" ]; then
PYTHON_BIN="$DSS_ROOT/.venv/bin/python3"
elif [ -x "$DSS_ROOT/venv/bin/python3" ]; then
PYTHON_BIN="$DSS_ROOT/venv/bin/python3"
else
echo "[dss-mcp] No venv found at $DSS_ROOT/.venv or $DSS_ROOT/venv" >&2
echo "[dss-mcp] Create one: python3 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt" >&2
exit 1
fi
# Defaults (allow caller to override).
export PYTHONPATH="${PYTHONPATH:-$DSS_ROOT}"
export DSS_HOME="${DSS_HOME:-$DSS_ROOT/.dss}"
export DSS_CACHE="${DSS_CACHE:-$DSS_ROOT/.dss/cache}"
export DSS_BASE_PATH="${DSS_BASE_PATH:-$DSS_ROOT}"
# Enable dev-only MCP workflow tools (shell-script wrappers).
export DSS_ENABLE_DEV_COMMANDS="${DSS_ENABLE_DEV_COMMANDS:-1}"
exec "$PYTHON_BIN" -m dss.mcp.server

View File

@@ -41,20 +41,16 @@ run_or_show "rm -rf .dss/data/projects/* .dss/data/teams/* .dss/data/_system/cac
run_or_show "rm -rf .dss/data/_system/tokens/* .dss/data/_system/themes/* .dss/data/_system/components/* 2>/dev/null || true"
run_or_show "mkdir -p .dss/data/{projects,teams,_system/{cache,activity,tokens,themes,components}}"
# 2. Reset database
echo "2. Resetting database..."
run_or_show "rm -f .dss/dss.db .dss/dss.db.old"
# 3. Remove admin-ui DSS CSS (keep non-dss files)
echo "3. Removing admin-ui DSS CSS files..."
# 2. Remove admin-ui DSS CSS (keep non-dss files)
echo "2. Removing admin-ui DSS CSS files..."
run_or_show "rm -f admin-ui/css/dss-*.css"
# 4. Remove generated stories and components
echo "4. Removing generated stories and components..."
# 3. Remove generated stories and components
echo "3. Removing generated stories and components..."
run_or_show "rm -f admin-ui/src/components/*.stories.js admin-ui/src/components/ds-*.js"
# 5. Reset core_tokens
echo "5. Resetting core_tokens..."
# 4. Reset core_tokens
echo "4. Resetting core_tokens..."
if [ "$DRY_RUN" = false ]; then
cat > dss/core_tokens/tokens.json << 'EOF'
{
@@ -71,8 +67,8 @@ else
echo " Would reset: dss/core_tokens/tokens.json"
fi
# 6. Reset skins to empty
echo "6. Resetting skins..."
# 5. Reset skins to empty
echo "5. Resetting skins..."
for skin in base classic workbench; do
if [ "$DRY_RUN" = false ]; then
# Capitalize first letter for description
@@ -106,14 +102,14 @@ EOF
fi
done
# 7. Clear caches and logs
echo "7. Clearing caches and logs..."
# 6. Clear caches and logs
echo "6. Clearing caches and logs..."
run_or_show "rm -f .dss/logs/*.jsonl 2>/dev/null || true"
run_or_show "rm -rf .dss/logs/browser-logs/* 2>/dev/null || true"
run_or_show "touch .dss/logs/dss-operations.jsonl .dss/logs/git-hooks.jsonl"
# 8. Regenerate hash manifest
echo "8. Regenerating hash manifest..."
# 7. Regenerate hash manifest
echo "7. Regenerating hash manifest..."
if [ "$DRY_RUN" = false ]; then
./scripts/regenerate-core-hashes.sh
else

View File

@@ -1,185 +0,0 @@
#!/bin/bash
# DSS Complete Setup Script
# Sets up MCP, initializes DSS structure, and starts services
#
# Usage: scripts/dss-setup.sh [--reset] [--skip-servers]
#
# Flow:
# 1. Generate MCP configuration
# 2. Install dependencies if needed
# 3. Initialize DSS structure (dss-init.sh)
# 4. Start development servers
set -e
DSS_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$DSS_ROOT"
# Parse arguments
RESET=false
SKIP_SERVERS=false
for arg in "$@"; do
case $arg in
--reset) RESET=true ;;
--skip-servers) SKIP_SERVERS=true ;;
esac
done
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m'
log_step() { echo -e "${BLUE}[SETUP]${NC} $1"; }
log_ok() { echo -e "${GREEN}[OK]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_info() { echo -e "${CYAN}[INFO]${NC} $1"; }
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ DSS COMPLETE SETUP ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""
# ============================================================================
# STEP 1: Generate MCP Configuration
# ============================================================================
log_step "1. Generating MCP configuration..."
cat > "$DSS_ROOT/.mcp.json" << EOF
{
"\$schema": "https://raw.githubusercontent.com/anthropics/claude-code/main/schemas/mcp-servers.schema.json",
"mcpServers": {
"dss": {
"command": "$DSS_ROOT/.venv/bin/python3",
"args": ["$DSS_ROOT/dss-claude-plugin/servers/dss-mcp-server.py"],
"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
log_ok "MCP config generated: .mcp.json"
echo ""
# ============================================================================
# STEP 2: Check/Install Dependencies
# ============================================================================
log_step "2. Checking dependencies..."
# Check Python venv
if [ ! -d "$DSS_ROOT/.venv" ]; then
log_info "Creating Python virtual environment..."
python3 -m venv "$DSS_ROOT/.venv"
fi
# Activate venv and check packages
source "$DSS_ROOT/.venv/bin/activate"
if ! python3 -c "import mcp" 2>/dev/null; then
log_info "Installing MCP package..."
pip install mcp 2>/dev/null || log_warn "MCP package install failed"
fi
log_ok "Python venv ready"
# Check admin-ui node_modules
if [ ! -d "$DSS_ROOT/admin-ui/node_modules" ]; then
log_info "Installing admin-ui dependencies..."
cd "$DSS_ROOT/admin-ui" && npm install --legacy-peer-deps
cd "$DSS_ROOT"
fi
log_ok "Node dependencies ready"
# Build admin-ui for production
log_info "Building admin-ui for production..."
cd "$DSS_ROOT/admin-ui"
npm run build 2>&1 | tail -5
cd "$DSS_ROOT"
log_ok "admin-ui built (dist/)"
echo ""
# ============================================================================
# STEP 3: Initialize DSS Structure
# ============================================================================
log_step "3. Running DSS initialization..."
if [ "$RESET" = true ]; then
"$DSS_ROOT/scripts/dss-init.sh" --reset
else
"$DSS_ROOT/scripts/dss-init.sh"
fi
echo ""
# ============================================================================
# STEP 4: Start Development Servers
# ============================================================================
if [ "$SKIP_SERVERS" = false ]; then
log_step "4. Starting development servers..."
# Kill existing processes
pkill -f "vite.*admin-ui" 2>/dev/null || true
pkill -f "storybook.*6006" 2>/dev/null || true
sleep 1
# Start admin-ui (Vite)
cd "$DSS_ROOT/admin-ui"
nohup npm run dev > /tmp/dss-admin-ui.log 2>&1 &
VITE_PID=$!
log_info "admin-ui starting (PID: $VITE_PID)..."
# Start Storybook
nohup npm run storybook > /tmp/dss-storybook.log 2>&1 &
SB_PID=$!
log_info "Storybook starting (PID: $SB_PID)..."
cd "$DSS_ROOT"
# Wait for servers
sleep 5
# Check status
if curl -s -o /dev/null -w "" http://localhost:3456 2>/dev/null; then
log_ok "admin-ui running on http://localhost:3456"
else
log_warn "admin-ui not responding yet (check /tmp/dss-admin-ui.log)"
fi
if curl -s -o /dev/null -w "" http://localhost:6006 2>/dev/null; then
log_ok "Storybook running on http://localhost:6006"
else
log_warn "Storybook not responding yet (check /tmp/dss-storybook.log)"
fi
echo ""
else
log_step "4. Skipping servers (--skip-servers)"
echo ""
fi
# ============================================================================
# SUMMARY
# ============================================================================
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ DSS SETUP COMPLETE ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""
echo " Services:"
echo " admin-ui: http://localhost:3456"
echo " Storybook: http://localhost:6006"
echo ""
echo " Logs:"
echo " /tmp/dss-admin-ui.log"
echo " /tmp/dss-storybook.log"
echo ""
echo " Next: Restart Claude Code to load DSS MCP server"
echo ""

94
scripts/enable-mcp-clients.sh Executable file
View File

@@ -0,0 +1,94 @@
#!/bin/bash
set -euo pipefail
# Enable DSS MCP for supported AI clients (Claude Code, Codex CLI, Gemini CLI).
#
# This is safe to run multiple times.
#
# Usage:
# ./scripts/enable-mcp-clients.sh [--force] [--api-url <url>] [--skip-codex] [--skip-gemini] [--skip-claude]
#
# Notes:
# - Claude Code MCP config is project-local: `.claude/mcp.json`
# - Codex/Gemini are configured via their CLI (`codex mcp add`, `gemini mcp add`)
DSS_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
MCP_CMD="$DSS_ROOT/scripts/dss-mcp"
FORCE=false
SKIP_CLAUDE=false
SKIP_CODEX=false
SKIP_GEMINI=false
API_URL=""
while [[ $# -gt 0 ]]; do
case "$1" in
--force)
FORCE=true
shift
;;
--skip-claude)
SKIP_CLAUDE=true
shift
;;
--skip-codex)
SKIP_CODEX=true
shift
;;
--skip-gemini)
SKIP_GEMINI=true
shift
;;
--api-url)
API_URL="${2:-}"
if [[ -z "$API_URL" ]]; then
echo "Error: --api-url requires a value" >&2
exit 1
fi
shift 2
;;
*)
echo "Unknown argument: $1" >&2
echo "Usage: ./scripts/enable-mcp-clients.sh [--force] [--api-url <url>] [--skip-codex] [--skip-gemini] [--skip-claude]" >&2
exit 1
;;
esac
done
echo "[dss] Enabling MCP clients in: $DSS_ROOT"
if [[ "$SKIP_CLAUDE" != "true" ]]; then
echo "[dss] Claude Code: generating .claude/mcp.json"
if [[ -n "$API_URL" ]]; then
"$DSS_ROOT/scripts/setup-mcp.sh" --api-url "$API_URL"
else
"$DSS_ROOT/scripts/setup-mcp.sh"
fi
fi
if [[ "$SKIP_CODEX" != "true" ]]; then
if command -v codex >/dev/null 2>&1; then
echo "[dss] Codex CLI: configuring MCP server 'dss'"
if $FORCE; then
codex mcp remove dss >/dev/null 2>&1 || true
fi
codex mcp get dss >/dev/null 2>&1 || codex mcp add dss -- "$MCP_CMD"
else
echo "[dss] Codex CLI: not found (skip)" >&2
fi
fi
if [[ "$SKIP_GEMINI" != "true" ]]; then
if command -v gemini >/dev/null 2>&1; then
echo "[dss] Gemini CLI: configuring MCP server 'dss'"
if $FORCE; then
gemini mcp remove dss >/dev/null 2>&1 || true
fi
gemini mcp list 2>/dev/null | grep -qE '^dss\\b' || gemini mcp add dss "$MCP_CMD"
else
echo "[dss] Gemini CLI: not found (skip)" >&2
fi
fi
echo "[dss] Done."
echo "[dss] Restart Claude Code/Codex/Gemini sessions to load the updated MCP toolset."

View File

@@ -2,7 +2,7 @@
# Generate .claude/mcp.json with absolute paths for current setup
#
# USAGE:
# ./scripts/setup-mcp.sh
# ./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.
@@ -13,6 +13,31 @@ 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"
@@ -27,12 +52,9 @@ else
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
MCP_ARGS='["-m", "dss.mcp.server"]'
MCP_SERVER_DESC="python -m dss.mcp.server"
PYTHONPATH_VALUE="$DSS_ROOT"
cat > "$MCP_CONFIG" << EOF
{
@@ -40,13 +62,14 @@ cat > "$MCP_CONFIG" << EOF
"mcpServers": {
"dss": {
"command": "$PYTHON_PATH",
"args": ["$MCP_SERVER"],
"args": $MCP_ARGS,
"env": {
"PYTHONPATH": "$DSS_ROOT:$DSS_ROOT/dss-claude-plugin",
"PYTHONPATH": "$PYTHONPATH_VALUE",
"DSS_HOME": "$DSS_ROOT/.dss",
"DSS_DATABASE": "$DSS_ROOT/.dss/dss.db",
"DSS_CACHE": "$DSS_ROOT/.dss/cache",
"DSS_BASE_PATH": "$DSS_ROOT"
"DSS_BASE_PATH": "$DSS_ROOT",
"DSS_ENABLE_DEV_COMMANDS": "1",
"DSS_API_URL": "$API_URL"
},
"description": "Design System Server MCP - local development"
}
@@ -59,11 +82,13 @@ echo ""
echo "Configuration:"
echo " DSS_ROOT: $DSS_ROOT"
echo " Python: $PYTHON_PATH"
echo " MCP Server: $MCP_SERVER"
echo " MCP Server: $MCP_SERVER_DESC"
if [ -n "$API_URL" ]; then
echo " DSS_API_URL: $API_URL"
fi
echo ""
# Optionally install the DSS plugin for commands/skills
echo "To install DSS plugin commands (optional):"
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 ""