MCP Setup & Configuration
MCP Setup & Configuration
Section titled “MCP Setup & Configuration”This guide walks you through setting up and configuring MCP (Model Context Protocol) servers for use with Claude Code in the astro-basics project.
Prerequisites
Section titled “Prerequisites”Before setting up MCP servers, ensure you have:
- Claude Code CLI installed and configured
- Node.js 18+ (for JavaScript-based servers)
- Python 3.8+ (for Python-based servers)
- Git for cloning server repositories
- API Keys for external services (detailed below)
Installation Methods
Section titled “Installation Methods”Install MCP servers as npm packages:
# Core MCP serversnpm install -g @anthropic/mcp-server-filesystemnpm install -g @anthropic/mcp-server-githubnpm install -g @anthropic/mcp-server-postgres
# Specialized serversnpm install -g @astrojs/mcp-server-docsnpm install -g @supabase/mcp-servernpm install -g @clerk/mcp-serverClone and install from source:
# Create MCP servers directorymkdir ~/.mcp-serverscd ~/.mcp-servers
# Clone specific serversgit clone https://github.com/microsoft/playwright-mcp-server.gitgit clone https://github.com/figma/figma-mcp-server.gitgit clone https://github.com/netlify/netlify-mcp-server.git
# Install dependenciescd playwright-mcp-server && npm installcd ../figma-mcp-server && npm installcd ../netlify-mcp-server && npm installRun MCP servers in containers:
# Create docker-compose.ymlversion: '3.8'services:mcp-playwright: image: mcpservers/playwright:latest ports: - "3001:3000" environment: - BROWSER_HEADLESS=true
mcp-supabase: image: mcpservers/supabase:latest ports: - "3002:3000" environment: - SUPABASE_URL=${SUPABASE_URL} - SUPABASE_ANON_KEY=${SUPABASE_ANON_KEY}
# Start containersdocker-compose up -dConfiguration File
Section titled “Configuration File”Create a configuration file to register your MCP servers:
-
Create configuration directory:
Terminal window mkdir -p ~/.claude-code/mcp -
Create server configuration (
~/.claude-code/mcp/servers.json):{"servers": {"astro-docs": {"command": "npx","args": ["@astrojs/mcp-server"],"description": "Astro framework documentation search"},"playwright": {"command": "node","args": ["~/.mcp-servers/playwright-mcp-server/dist/index.js"],"description": "Browser automation and testing","env": {"PLAYWRIGHT_BROWSERS_PATH": "/usr/bin"}},"supabase": {"command": "npx","args": ["@supabase/mcp-server"],"description": "Database operations and project management","env": {"SUPABASE_ACCESS_TOKEN": "${SUPABASE_ACCESS_TOKEN}"}},"context7": {"command": "npx","args": ["@context7/mcp-server"],"description": "Library documentation retrieval"},"figma": {"command": "node","args": ["~/.mcp-servers/figma-mcp-server/dist/index.js"],"description": "Design-to-code generation","env": {"FIGMA_ACCESS_TOKEN": "${FIGMA_ACCESS_TOKEN}"}},"clerk": {"command": "npx","args": ["@clerk/mcp-server"],"description": "Authentication and user management","env": {"CLERK_SECRET_KEY": "${CLERK_SECRET_KEY}"}},"ide": {"command": "npx","args": ["@vscode/mcp-server"],"description": "IDE integration and diagnostics"},"netlify": {"command": "node","args": ["~/.mcp-servers/netlify-mcp-server/dist/index.js"],"description": "Deployment and hosting management","env": {"NETLIFY_ACCESS_TOKEN": "${NETLIFY_ACCESS_TOKEN}"}},"web-tools": {"command": "npx","args": ["@anthropic/mcp-server-web"],"description": "Web search and content fetching"},"mcp-generic": {"command": "npx","args": ["@anthropic/mcp-server-filesystem", "--root", "./"],"description": "Generic MCP resource operations"}}} -
Set file permissions:
Terminal window chmod 600 ~/.claude-code/mcp/servers.json
Environment Variables
Section titled “Environment Variables”Set up the required environment variables for authenticated services:
# Create environment filecat > ~/.claude-code/mcp/.env << 'EOF'# Supabase ConfigurationSUPABASE_ACCESS_TOKEN=sb_your_access_token_hereSUPABASE_URL=https://your-project.supabase.coSUPABASE_ANON_KEY=your_anon_key_here
# Clerk ConfigurationCLERK_SECRET_KEY=sk_test_your_secret_key_hereCLERK_PUBLISHABLE_KEY=pk_test_your_publishable_key_here
# Figma ConfigurationFIGMA_ACCESS_TOKEN=figd_your_access_token_here
# Netlify ConfigurationNETLIFY_ACCESS_TOKEN=netlify_your_access_token_here
# GitHub Configuration (if using)GITHUB_TOKEN=ghp_your_personal_access_token_hereEOF
# Secure the environment filechmod 600 ~/.claude-code/mcp/.envAPI Keys & Authentication
Section titled “API Keys & Authentication”Required for database operations
- Go to Supabase Dashboard
- Select your project
- Go to Settings > API
- Copy the URL and anon/public key
- For management operations, create an access token:
- Go to Account > Access Tokens
- Click Generate new token
- Copy the token
Required for authentication management
- Go to Clerk Dashboard
- Select your application
- Go to Developers > API Keys
- Copy the Secret Key (starts with
sk_) - Optionally copy the Publishable Key (starts with
pk_)
Required for design-to-code features
- Go to Figma Account Settings
- Scroll to Personal access tokens
- Click Generate new token
- Give it a descriptive name (e.g., “MCP Server Access”)
- Copy the token (starts with
figd_)
Required for deployment operations
- Go to Netlify User Settings
- Scroll to Personal access tokens
- Click New access token
- Give it a descriptive name
- Copy the generated token
Verification & Testing
Section titled “Verification & Testing”Test your MCP server configuration:
-
Check server status:
Terminal window claude-code mcp list -
Test individual servers:
Terminal window # Test Astro docs searchclaude-code mcp test astro-docs --function search_astro_docs --args '{"query": "components"}'# Test Supabase connectionclaude-code mcp test supabase --function list_projects# Test Playwright browserclaude-code mcp test playwright --function browser_navigate --args '{"url": "https://example.com"}' -
Verify authentication:
Terminal window # This should return your projects/resourcesclaude-code mcp test supabase --function list_projectsclaude-code mcp test clerk --function get_user_countclaude-code mcp test netlify --function get_sites
Common Configuration Issues
Section titled “Common Configuration Issues”Problem: Server command not found
Solution: Use full paths or ensure executables are in PATH
{ "command": "/usr/local/bin/node", "args": ["/full/path/to/server/dist/index.js"]}Problem: Environment variables not loading
Solution: Check file permissions and syntax
# Check permissions (should be 600)ls -la ~/.claude-code/mcp/.env
# Test variable loadingsource ~/.claude-code/mcp/.env && echo $SUPABASE_ACCESS_TOKENProblem: Server port already in use
Solution: Change server port or stop conflicting service
# Find what's using the portlsof -i :3000
# Use different port"env": { "PORT": "3001"}Problem: Cannot connect to external APIs
Solution: Check firewall and network settings
# Test API connectivitycurl -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ https://api.supabase.com/v1/projects
# Check DNS resolutionnslookup api.supabase.comSecurity Best Practices
Section titled “Security Best Practices”- Environment Files: Keep
.envfiles out of version control - File Permissions: Set restrictive permissions (600) on config files
- Token Rotation: Regularly rotate API tokens and access keys
- Least Privilege: Use tokens with minimal required permissions
- Monitoring: Monitor server logs for unauthorized access attempts
Next Steps
Section titled “Next Steps”With MCP servers configured, explore:
- Server Documentation - Detailed guides for each server
- Usage Examples - Real-world implementation scenarios
- Troubleshooting - Solutions to common problems
Advanced Configuration
Section titled “Advanced Configuration”For advanced scenarios, see:
- Custom server development
- Load balancing multiple server instances
- Server monitoring and logging
- Integration with CI/CD pipelines