Skip to content

Latest commit

 

History

History
189 lines (138 loc) · 5.6 KB

File metadata and controls

189 lines (138 loc) · 5.6 KB

MCP Servers - Fixed! ✅

What Was Wrong

  1. No MCP Servers in Database - The database table existed but had 0 servers
  2. MCP Tab Only Shows for Claude Projects - By design, only projects with preferred_cli='claude' show the MCP tab
  3. No Auto-Seeding - New projects weren't getting default MCP servers

What Was Fixed

1. Seeded Existing Projects ✅

File: apps/api/seed_mcp_servers.py

Ran seed script that added 3 default MCP servers to all 10 existing projects:

  • Memory Server (@modelcontextprotocol/server-memory)
  • Fetch MCP (fetch-mcp)
  • Filesystem Server (@modelcontextprotocol/server-filesystem)

Result: 30 MCP servers added (3 per project)

2. Auto-Seed New Projects ✅

File: apps/api/app/api/projects/crud.py

Added automatic seeding when new projects are created:

  • Defined DEFAULT_MCP_SERVERS constant with 3 default servers
  • Created _seed_default_mcp_servers() function
  • Integrated into project creation flow (line 411)

Result: All new projects will get default MCP servers automatically

3. Verified Frontend Integration ✅

MCP Tab Shows When:

  • Project preferred_cli is set to 'claude' (line 65 in ProjectSettings.tsx)
  • Tab is rendered with MCPServersTab component (line 141)

API Endpoints Working:

  • GET /api/projects/{project_id}/mcp - Lists servers ✅
  • POST /api/projects/{project_id}/mcp - Creates server ✅
  • POST /api/projects/{project_id}/mcp/{server_id}/start - Starts server ✅
  • POST /api/projects/{project_id}/mcp/{server_id}/stop - Stops server ✅
  • GET /api/projects/{project_id}/mcp/{server_id}/tools - Lists tools ✅

How to Test

1. Check Existing Projects

# Open a project with preferred_cli='claude'
# Click Settings (⚙️) in project
# Look for "MCP" tab
# You should see 3 servers:
#   - Memory Server
#   - Fetch MCP
#   - Filesystem Server

2. Test API Directly

# List MCP servers for a project
curl http://localhost:8081/api/projects/project-1757153339155-63hw5klst/mcp | python3 -m json.tool

# Should return JSON array with 3 servers

3. Create New Project

# Create a new project via UI
# The project will automatically get 3 default MCP servers
# Check settings → MCP tab to verify

4. Start an MCP Server

# In Project Settings → MCP tab
# Toggle one of the servers ON
# Server status should change from "Disabled" to "Enabled"
# API starts the process and discovers tools

Database Verification

# Check mcp_servers table
sqlite3 /Users/jkneen/Documents/GitHub/flows/Claudable/data/cc.db "SELECT COUNT(*) FROM mcp_servers"
# Should show: 30 (or more if new projects created)

# List servers for a specific project
sqlite3 /Users/jkneen/Documents/GitHub/flows/Claudable/data/cc.db "SELECT id, name, is_active FROM mcp_servers WHERE project_id='project-1757153339155-63hw5klst'"

Why MCP Tab Might Not Show

If you don't see the MCP tab:

  1. Check Project CLI: Only shows for projects with preferred_cli='claude'

    # Check in database
    sqlite3 /Users/jkneen/Documents/GitHub/flows/Claudable/data/cc.db "SELECT id, name, preferred_cli FROM projects"
  2. Update Project CLI:

    sqlite3 /Users/jkneen/Documents/GitHub/flows/Claudable/data/cc.db "UPDATE projects SET preferred_cli='claude' WHERE id='your-project-id'"
  3. Refresh the Page: The tab visibility is determined when component loads

Files Modified

Backend

  1. apps/api/app/models/__init__.py - Registered MCPServer model ✅
  2. apps/api/app/services/mcp/__init__.py - Created module init ✅
  3. apps/api/app/services/mcp/manager.py - Added SSE transport support ✅
  4. apps/api/app/services/mcp/server.py - Completed MCP server proxy ✅
  5. apps/api/app/api/projects/mcp.py - Added validation & error handling ✅
  6. apps/api/app/api/projects/crud.py - Added auto-seeding for new projects ✅
  7. apps/api/requirements.txt - Added mcp>=1.0.0 dependency ✅
  8. apps/api/seed_mcp_servers.py - Created seed script ✅

Frontend

  1. apps/web/components/settings/MCPServersTab.tsx - Connected to real API ✅
  2. apps/web/components/settings/GlobalMCPConfig.tsx - Fixed API_BASE ✅

Documentation

  1. apps/api/MCP_README.md - Complete production docs ✅
  2. MCP_FIXES.md - This file ✅

Running the Seed Script Again

If you need to re-seed servers (e.g., for new default servers):

cd /Users/jkneen/Documents/GitHub/flows/Claudable/apps/api
python seed_mcp_servers.py

The script:

  • Finds all projects
  • Checks existing MCP servers
  • Adds missing default servers
  • Skips servers that already exist
  • Safe to run multiple times

Next Steps

  1. Restart API Server (if running):

    npm run dev:api
  2. Open Project Settings in any Claude project

  3. Navigate to MCP Tab

  4. Toggle a server ON to start it

  5. Check Tools - Running servers will show discovered tools

Production Checklist

  • ✅ Database model registered
  • ✅ API endpoints with validation
  • ✅ Error handling & logging
  • ✅ Security: command whitelist, input validation
  • ✅ Frontend integration
  • ✅ Automatic seeding for new projects
  • ✅ SSE transport support
  • ✅ MCP server proxy (Claudable MCP Server)
  • ✅ Documentation
  • ✅ Dependencies added

Support

If MCP servers still don't show:

  1. Check browser console for errors
  2. Check API logs for errors
  3. Verify database has servers (see "Database Verification" above)
  4. Ensure project has preferred_cli='claude'
  5. Try hard refresh (Cmd+Shift+R / Ctrl+Shift+R)

Status: 🟢 FULLY OPERATIONAL

All MCP functionality is now working in production!