This guide explains how to configure and run the Effect Patterns MCP (Model Context Protocol) server with Claude Code IDE and other MCP clients.
The Effect Patterns MCP Server provides access to 700+ Effect-TS patterns through a Model Context Protocol interface. It allows Claude Code IDE to:
- Search Effect-TS patterns by query, category, and difficulty level
- Retrieve detailed pattern documentation and code examples
- Browse the analysis rule catalog (read-only metadata)
Paid features (code analysis, code review, refactoring, consistency analysis) are available via the HTTP API and paid CLI only — not exposed as MCP tools.
- Node.js 18+ or Bun 1.0+
- API key (for accessing the patterns API)
- The Effect Patterns repository cloned locally
cd /path/to/Effect-Patterns
bun installSet your API key as an environment variable:
export PATTERN_API_KEY="your-api-key-here"Or add to your .env.local:
PATTERN_API_KEY=your-api-key-here
From the mcp-server directory:
cd packages/mcp-transport
bun run mcpOr with debug logging enabled:
bun run mcp:debugThe server will start and listen on stdio, ready to accept MCP requests.
Create or update .windsurf/mcp_config.json in your project root:
{
"mcpServers": {
"effect-patterns": {
"command": "bun",
"args": ["run", "mcp"],
"cwd": "packages/mcp-transport",
"env": {
"PATTERN_API_KEY": "your-api-key-here",
"EFFECT_PATTERNS_API_URL": "http://localhost:3000"
},
"disabled": false
}
}
}- Open Claude settings
- Navigate to "Developer" → "Model Context Protocol"
- Click "Add MCP Server"
- Configure:
- Name: Effect Patterns
- Command:
bun - Arguments:
["run", "mcp"] - Working Directory:
/path/to/Effect-Patterns/packages/mcp-transport - Environment Variables:
PATTERN_API_KEY=your-api-key-here EFFECT_PATTERNS_API_URL=http://localhost:3000
The server can be used with any MCP-compatible client by running:
cd packages/mcp-transport
PATTERN_API_KEY=your-api-key-here bun run mcpAnd configuring your client to connect via stdio.
The MCP server respects the following environment variables:
PATTERN_API_KEY: API key for accessing the patterns API- Optional for MCP server (pure transport)
- Required by the HTTP API for authenticated requests
- Example:
export PATTERN_API_KEY=sk-...
-
EFFECT_PATTERNS_API_URL: Base URL for the patterns API- Default:
http://localhost:3000 - Example:
export EFFECT_PATTERNS_API_URL=https://api.example.com
- Default:
-
MCP_DEBUG: Enable debug logging to stderr- Default:
false - Values:
trueorfalse - Example:
export MCP_DEBUG=true
- Default:
The MCP server provides 3 tools (free-tier surface only). Paid features are exposed via the HTTP API, not the MCP server.
Search Effect-TS patterns with optional filters.
Parameters:
q(string, optional): Search query (e.g., "error handling", "async")category(string, optional): Pattern category filterdifficulty(string, optional): Difficulty level (beginner, intermediate, advanced)limit(number, optional): Maximum results (1-100, default: 20)
Example:
{
"q": "error handling",
"difficulty": "intermediate",
"limit": 10
}Retrieve full details for a specific pattern by ID.
Parameters:
id(string, required): Pattern identifier (e.g., "effect-service")
Example:
{
"id": "effect-service"
}List all analysis rule metadata (IDs, titles, severity, categories). Read-only catalog — does not scan or analyze user code.
Parameters: None
The following paid-tier features are available via the HTTP API only (not exposed as MCP tools):
analyze_code→POST /api/analyze-codereview_code→POST /api/review-codegenerate_pattern_code→POST /api/generate-patternanalyze_consistency→POST /api/analyze-consistencyapply_refactoring→POST /api/apply-refactoring
The MCP server no longer validates API keys. Authentication is enforced by the HTTP API. If requests fail with 401/402 errors, verify your HTTP API key and tier configuration.
Solution: Reinstall dependencies:
cd /path/to/Effect-Patterns
bun installPossible causes:
- The MCP server process is not running
- The working directory in configuration is incorrect
- Environment variables are not being passed properly
Solutions:
-
Start the server manually to verify it works:
cd packages/mcp-transport PATTERN_API_KEY=your-key bun run mcp:debug -
Check the working directory is absolute:
"cwd": "/full/path/to/Effect-Patterns/packages/mcp-transport"
-
Verify environment variables in configuration are spelled correctly
Possible causes:
- The backend API is not running
- API key is invalid
- The API URL is incorrect
Solutions:
- Verify the API server is running (default: http://localhost:3000)
- Check your API key is correct
- Use
MCP_DEBUG=trueto see actual errors:MCP_DEBUG=true bun run mcp
Solution: Never log actual API keys. The server sanitizes API keys in logs for security. If you see API key in a log message, it means the key itself is not logged (which is correct).
To develop against a local API server:
# Terminal 1: Start the API server
cd packages/mcp-transport
bun run dev # Starts Next.js API server on port 3000
# Terminal 2: Start the MCP server
cd packages/mcp-transport
PATTERN_API_KEY=dev-key bun run mcpEnable debug output to stderr:
MCP_DEBUG=true PATTERN_API_KEY=dev-key bun run mcpThis will log:
- Tool calls and parameters
- API requests and responses
- Error messages with full context
To create a standalone bundle:
cd packages/mcp-transport
bun run mcp:buildThis creates dist/mcp-stdio.js (668KB bundled).
Use the search_patterns tool in conversation prompts:
Search for patterns about error handling with difficulty level intermediate
Claude will automatically use the search_patterns tool and show results.
Code analysis, review, pattern generation, and refactoring are available via the HTTP API and paid CLI, not via MCP tools:
# Example: analyze code via HTTP API
curl -X POST -H "x-api-key: $PATTERN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"source": "...", "analysisType": "all"}' \
https://effect-patterns-mcp.vercel.app/api/analyze-code- API Keys: Never commit API keys to version control. Use environment variables or
.env.local - Log Files: When
MCP_DEBUG=true, sensitive information might appear in stderr. Redirect logs carefully - Network: The server communicates with the backend API. Ensure HTTPS is used in production
- Input Validation: All inputs are validated by the MCP SDK before reaching handlers
- Caching: Pattern searches are cached server-side for 5 minutes
- Limits: The API has rate limits (default: 100 requests/minute per key)
- Large Files: For analyzing multiple files via HTTP API, keep total size under 10MB
- Batch Operations: Group multiple refactorings into a single HTTP API
apply_refactoringcall
For issues:
- Check the main documentation
- Review logs with debug enabled:
MCP_DEBUG=true bun run mcp - Verify API connectivity:
curl -H "x-api-key: $PATTERN_API_KEY" http://localhost:3000/api/patterns?q=service - Check MCP specification: https://spec.modelcontextprotocol.io/
The MCP server can be tested against three environments: local, staging, and production.
Test the MCP server stdio interface against your local development server:
# Prerequisites: Start local server
cd packages/mcp-transport
bun run dev # In one terminal
# Run local MCP tests (in another terminal)
bun run test:mcp:local
# Or use the script directly
./scripts/test-mcp-local.shEnvironment Variables:
PATTERN_API_KEYorLOCAL_API_KEY: API key for local server (default: "test-api-key")EFFECT_PATTERNS_API_URL: Local server URL (default: "http://localhost:3000")MCP_DEBUG: Enable debug logging ("true" or "false")
Test the MCP server against the staging deployment:
# Set staging API key
export STAGING_API_KEY="your-staging-api-key"
# Run staging MCP tests
bun run test:mcp:staging
# Or use the script directly
STAGING_API_KEY=your-key ./scripts/test-mcp-staging.shEnvironment Variables:
STAGING_API_KEY: Required. API key for staging environmentMCP_DEBUG: Optional. Enable debug logging
Test the MCP server against the production deployment:
# Set production API key
export PRODUCTION_API_KEY="your-production-api-key"
# Run production MCP tests
bun run test:mcp:production
# Or use the script directly
PRODUCTION_API_KEY=your-key ./scripts/test-mcp-production.shEnvironment Variables:
PRODUCTION_API_KEY: Required. API key for production environmentMCP_DEBUG: Optional. Enable debug logging
Run tests against all three environments in sequence:
# Set API keys for staging and production
export STAGING_API_KEY="your-staging-key"
export PRODUCTION_API_KEY="your-production-key"
# Run all tests
bun run test:mcp:all
# Or use the script directly
STAGING_API_KEY=staging-key PRODUCTION_API_KEY=prod-key ./scripts/test-mcp-all.shNote: Local tests require a running local server. Staging and production tests require valid API keys.
The MCP protocol tests verify the stdio communication between the MCP client and server:
# Run all MCP protocol tests (requires local server)
bun run test:mcp
# Watch mode
bun run test:mcp:watch
# Run specific test file
bunx vitest run --config vitest.mcp.config.ts tests/mcp-protocol/local.test.tsTest the HTTP API endpoints directly (not via MCP stdio):
# Test staging deployment
bun run test:deployment:staging
# Test production deployment
bun run test:deployment:production
# Test both
bun run test:deploymentThe MCP server uses environment-specific configuration:
- API URL:
http://localhost:3000(orEFFECT_PATTERNS_API_URL) - API Key:
PATTERN_API_KEYorLOCAL_API_KEY(default: "test-api-key") - Use Case: Development and local testing
- API URL:
https://effect-patterns-mcp-staging.vercel.app - API Key:
STAGING_API_KEY(required) - Use Case: Pre-production testing
- API URL:
https://effect-patterns-mcp.vercel.app - API Key:
PRODUCTION_API_KEY(required) - Use Case: Production validation
Set the MCP_ENV environment variable to switch between environments:
# Use local environment
export MCP_ENV=local
bun run mcp
# Use staging environment
export MCP_ENV=staging
export STAGING_API_KEY=your-key
bun run mcp
# Use production environment
export MCP_ENV=production
export PRODUCTION_API_KEY=your-key
bun run mcp