lioarce01/mcp-server-cloudflare-workers-starter-enhanced
If you are the rightful owner of mcp-server-cloudflare-workers-starter-enhanced and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A modular Model Context Protocol (MCP) starter with a hybrid 3-level priority configuration system.
MCP Starter - Flexible Configuration System
A modular Model Context Protocol (MCP) starter with a hybrid 3-level priority configuration system. Build scalable MCP servers for any API integration (REST, Odoo, Salesforce, custom APIs) with dynamic tool filtering and flexible configuration management.
๐
๐ฏ Key Features
- 3-Level Priority Configuration - Headers โ Environment Variables โ Defaults
- Dynamic Tool Filtering - Control available tools per request via
to-use
header - REST API Client - Built-in client with auth, retries, and error handling
- Modular Architecture - Easy to extend and maintain
- Production Ready - Cloudflare Workers optimized
๐ Quick Start
# Install and run
npm install
npm run type-check
npm run dev # Local development
npm run deploy # Production deployment
๐ก Basic Usage
Simple Request (Uses Defaults)
curl http://localhost:8787/mcp
Per-Request Configuration (Headers)
curl -H "api-url: https://api.example.com" \
-H "api-token: your-token" \
-H "to-use: [\"health_check\", \"api_get\"]" \
http://localhost:8787/mcp
Health Check
curl -X POST http://localhost:8787/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "health_check",
"arguments": {"includeConfig": true}
}
}'
๐๏ธ Configuration Priority
The system automatically resolves configuration using a 3-level priority system:
- Headers (Highest) - Per-request via HTTP headers
- Environment (Medium) - Set in wrangler.toml or dashboard
- Defaults (Lowest) - Hardcoded fallbacks
Example:
# Environment: API_URL=https://env-api.com
# Headers override: api-url=https://header-api.com
# Result: Uses https://header-api.com
๐ Project Structure
src/
โโโ config/ # 3-level priority configuration
โโโ tools/ # Tool registry and filtering
โโโ clients/ # REST API client with auth
โโโ utils/ # Logging and error handling
โโโ mcp.ts # MCP agent implementation
โโโ index.ts # Entry point
๐ง Extending the Starter
Add New Tools
- Create tool in
src/tools/examples/
- Export from
src/tools/examples/index.ts
- Use
to-use
header to control availability
Add New Clients
- Extend
RestApiClient
insrc/clients/
- Map configuration fields in constructor
- Use in tool handlers
Custom Configuration
Add any configuration field via headers or environment:
curl -H "custom-field: value" /mcp
# OR
CUSTOM_FIELD=value npm run deploy
๐งช Testing & Development
# Local testing
npm run dev
curl http://localhost:8787/mcp
# Test with configuration
curl -H "api-url: https://jsonplaceholder.typicode.com" \
-H "to-use: [\"health_check\"]" \
http://localhost:8787/mcp
# Type checking
npm run type-check
๐ Deployment
# Configure environment in wrangler.toml
[vars]
API_URL = "https://your-api.com"
API_TOKEN = "your-token"
# Deploy
npm run deploy
๐ Documentation
- - Complete setup and development guide
- Built-in Tools - Calculator, health check, API tools
- Configuration Examples - REST, Odoo, Salesforce integrations
- Tool Development - Step-by-step tool creation
๐ค Contributing
- Fork the repository
- Create feature branch (
git checkout -b feature/name
) - Follow existing patterns and run
npm run type-check
- Submit pull request
๐ License
MIT License - see LICENSE file for details.