Cloudflare MCP Server
Last Updated: 2025-11-21
Quick Start
import { McpServer } from '@modelcontextprotocol/sdk';
const server = new McpServer({
name: 'my-server',
version: '1.0.0'
});
server.tool('getTodo', async ({ id }) => ({
id,
title: 'Task',
completed: false
}));
export default server;
Core Concepts
- Tools: Functions AI can call
- Resources: Data AI can access
- Prompts: Reusable templates
- Transports: SSE, HTTP, WebSocket
Example Tool
server.tool('searchDocs', {
description: 'Search documentation',
parameters: {
type: 'object',
properties: {
query: { type: 'string' }
}
},
handler: async ({ query }) => {
return { results: [...] };
}
});
Resources
Core Documentation
references/quick-start-guide.md (704 lines) - Official Cloudflare templates, complete step-by-step workflow, 5-minute setup
references/core-concepts.md (66 lines) - MCP fundamentals: tools, resources, prompts, transports
references/worker-basics.md (326 lines) - Worker & Durable Objects basics, transport selection, HTTP fundamentals
references/stateful-servers.md (246 lines) - Durable Objects integration, WebSocket hibernation, cost optimization, common patterns
references/production-deployment.md (814 lines) - Deployment & testing, configuration reference, authentication patterns, 22 known errors with solutions
Templates
templates/basic-mcp.ts - Minimal MCP server
templates/tools-example.ts - Tool definitions
templates/durable-object-mcp.ts - Stateful MCP with DO
templates/websocket-mcp.ts - WebSocket transport
Official Docs: https://modelcontextprotocol.io | Cloudflare: https://developers.cloudflare.com/workers/runtime-apis/durable-objects/
1---2name: cloudflare-mcp-server3description: Build MCP (Model Context Protocol) servers on Cloudflare Workers with tools, resources, and prompts.4license: MIT5---67# Cloudflare MCP Server89**Last Updated**: 2025-11-211011## Quick Start1213```typescript14import { McpServer } from '@modelcontextprotocol/sdk';1516const server = new McpServer({17 name: 'my-server',18 version: '1.0.0'19});2021server.tool('getTodo', async ({ id }) => ({22 id,23 title: 'Task',24 completed: false25}));2627export default server;28```2930## Core Concepts3132- **Tools**: Functions AI can call33- **Resources**: Data AI can access34- **Prompts**: Reusable templates35- **Transports**: SSE, HTTP, WebSocket3637## Example Tool3839```typescript40server.tool('searchDocs', {41 description: 'Search documentation',42 parameters: {43 type: 'object',44 properties: {45 query: { type: 'string' }46 }47 },48 handler: async ({ query }) => {49 return { results: [...] };50 }51});52```5354## Resources5556### Core Documentation57- `references/quick-start-guide.md` (704 lines) - Official Cloudflare templates, complete step-by-step workflow, 5-minute setup58- `references/core-concepts.md` (66 lines) - MCP fundamentals: tools, resources, prompts, transports59- `references/worker-basics.md` (326 lines) - Worker & Durable Objects basics, transport selection, HTTP fundamentals60- `references/stateful-servers.md` (246 lines) - Durable Objects integration, WebSocket hibernation, cost optimization, common patterns61- `references/production-deployment.md` (814 lines) - Deployment & testing, configuration reference, authentication patterns, 22 known errors with solutions6263### Templates64- `templates/basic-mcp.ts` - Minimal MCP server65- `templates/tools-example.ts` - Tool definitions66- `templates/durable-object-mcp.ts` - Stateful MCP with DO67- `templates/websocket-mcp.ts` - WebSocket transport6869**Official Docs**: https://modelcontextprotocol.io | **Cloudflare**: https://developers.cloudflare.com/workers/runtime-apis/durable-objects/