Skip to main content
Glama

MCP Server on Cloudflare Workers & Azure Functions

by TedTschopp
CAPABILITIES.md6.36 kB
# MCP Server Capabilities Summary ## Overview This MCP server now supports the full suite of Model Context Protocol capabilities, making it a complete implementation suitable for production use. The server can run both locally (stdio transport) and on Cloudflare Workers (HTTP transport). ## Supported Capabilities ### 1. Tools (with listChanged notifications) **Purpose**: Execute operations and computations on behalf of the AI **Capabilities Declared**: ```typescript tools: { listChanged: true // Server can notify clients when tools change } ``` **Available Tools**: - `get_time`: Returns current server timestamp - `echo`: Echoes back a message for testing - `add`: Adds two numbers together **Handlers**: - `tools/list`: Lists all available tools with their schemas - `tools/call`: Executes a specific tool with validation ### 2. Prompts (with listChanged notifications) **Purpose**: Provide reusable prompt templates for common AI tasks **Capabilities Declared**: ```typescript prompts: { listChanged: true // Server can notify clients when prompts change } ``` **Available Prompts**: - `code_review`: Code review assistance - `explain_concept`: Technical concept explanations - `debug_helper`: Debugging assistance - `api_design`: API design guidance - `refactor_suggestion`: Code refactoring suggestions **Handlers**: - `prompts/list`: Lists all available prompts - `prompts/get`: Retrieves a specific prompt with arguments **Implementation**: Prompts defined in `src/prompts.ts` ### 3. Resources (with subscribe and listChanged) **Purpose**: Provide contextual information and data to AI applications **Capabilities Declared**: ```typescript resources: { subscribe: true, // Clients can subscribe to resource changes listChanged: true, // Server can notify when resources change } ``` **Available Resources**: - `config://server/info` (application/json): Server metadata and configuration - `config://server/status` (application/json): Current server status and metrics - `docs://mcp/getting-started` (text/markdown): Getting started guide **Resource Templates**: - `log://{level}/{message}`: Parameterized log entries **Handlers**: - `resources/list`: Lists all available resources - `resources/read`: Reads content from a specific resource - `resources/templates/list`: Lists URI templates for dynamic resources - `resources/subscribe`: Subscribe to resource change notifications - `resources/unsubscribe`: Unsubscribe from resource notifications **Implementation**: Resources defined in `src/resources.ts` ### 4. Logging **Purpose**: Allow clients to control server logging verbosity **Capabilities Declared**: ```typescript logging: {} // Basic logging support ``` **Supported Log Levels**: - debug - info - notice - warning - error - critical - alert - emergency **Handler**: - `logging/setLevel`: Configure server logging level ## Notifications The server supports real-time notifications for: 1. **tools/list_changed**: Notifies clients when tools are added, removed, or modified 2. **prompts/list_changed**: Notifies clients when prompts are added, removed, or modified 3. **resources/list_changed**: Notifies clients when resources are added, removed, or modified 4. **resources/updated**: Notifies subscribed clients when specific resources change ## File Structure ``` src/ ├── index.ts - Main MCP server with all handlers ├── prompts.ts - Prompt definitions and generation └── resources.ts - Resource definitions and content generation ``` ## Capability Negotiation During initialization, the server declares all supported capabilities: ```typescript { name: 'cloudflare-mcp-server', version: '1.0.0', capabilities: { tools: { listChanged: true }, prompts: { listChanged: true }, resources: { subscribe: true, listChanged: true }, logging: {} } } ``` Clients can then choose which features to use based on their needs. ## Transport Support ### Stdio Transport (Local) - Used for direct MCP client connections - Suitable for local testing and development - Started via `npm run dev` (Node.js mode) ### HTTP Transport (Remote) - Used for Cloudflare Workers deployment - Suitable for production edge deployment - Endpoints: - `GET /health`: Health check - `POST /mcp`: MCP protocol handler - `OPTIONS /*`: CORS support ## Extension Points The server is designed to be easily extended: 1. **Add New Tools**: Define schema in `ListToolsRequestSchema` handler, implement logic in `CallToolRequestSchema` handler 2. **Add New Prompts**: Add to `PROMPTS` array in `src/prompts.ts` 3. **Add New Resources**: Add to `RESOURCES` array in `src/resources.ts`, implement content generation 4. **Add Sampling**: Server can request LLM completions from client (capability not yet implemented) ## Best Practices Implemented ✅ Comprehensive error handling with descriptive messages ✅ Type safety with TypeScript and JSON Schema validation ✅ Modular design with separated concerns (prompts, resources) ✅ Full JSDoc documentation ✅ Support for both static and dynamic content ✅ CORS support for cross-origin requests ✅ Health check endpoint for monitoring ✅ Environment detection for dual-mode operation ## Testing ### Local Testing (stdio) ```bash npm run dev ``` ### HTTP Testing ```bash # Health check curl http://localhost:8787/health # Get server info curl http://localhost:8787/ # MCP request (example) curl -X POST http://localhost:8787/mcp \ -H "Content-Type: application/json" \ -d '{"method":"tools/list","params":{}}' ``` ## Deployment Deploy to Cloudflare Workers: ```bash npx wrangler login npm run deploy ``` The deployed Worker will be available at `https://your-worker.your-subdomain.workers.dev` ## Next Steps Optional enhancements: - Implement sampling capability (server requests LLM completions from client) - Add roots capability (filesystem access declarations) - Implement actual notification sending when tools/prompts/resources change - Add authentication/authorization for HTTP endpoints - Integrate with Cloudflare KV or D1 for dynamic resource storage - Add telemetry and monitoring ## References - [MCP Specification](https://modelcontextprotocol.io/) - [Cloudflare Workers](https://developers.cloudflare.com/workers/) - [JSON-RPC 2.0](https://www.jsonrpc.org/specification)

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TedTschopp/MCP-Server-on-CloudFlare'

If you have feedback or need assistance with the MCP directory API, please join our Discord server