cloudflare-mcp-server
Build MCP (Model Context Protocol) servers on Cloudflare Workers with tools, resources, and prompts.
When & Why to Use This Skill
The Cloudflare MCP Server skill provides a comprehensive framework for developers to build and deploy Model Context Protocol (MCP) servers on the Cloudflare Workers serverless platform. It solves the challenge of connecting AI models to external data and custom functionalities by offering a standardized way to manage tools, resources, and prompts. By leveraging Cloudflare's edge infrastructure, it ensures low-latency, scalable, and secure integrations for AI agents and LLM-powered applications.
Use Cases
- Case 1: Building custom AI tools that allow LLMs to interact with private enterprise APIs or internal databases through a secure, serverless gateway.
- Case 2: Developing stateful AI agents by integrating Cloudflare Durable Objects to maintain persistent context and session data across multiple AI interactions.
- Case 3: Creating real-time resource providers that expose live documentation, codebases, or system logs to AI models using the standardized Model Context Protocol.
| name | cloudflare-mcp-server |
|---|---|
| description | Build MCP (Model Context Protocol) servers on Cloudflare Workers with tools, resources, and prompts. |
| license | MIT |
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 setupreferences/core-concepts.md(66 lines) - MCP fundamentals: tools, resources, prompts, transportsreferences/worker-basics.md(326 lines) - Worker & Durable Objects basics, transport selection, HTTP fundamentalsreferences/stateful-servers.md(246 lines) - Durable Objects integration, WebSocket hibernation, cost optimization, common patternsreferences/production-deployment.md(814 lines) - Deployment & testing, configuration reference, authentication patterns, 22 known errors with solutions
Templates
templates/basic-mcp.ts- Minimal MCP servertemplates/tools-example.ts- Tool definitionstemplates/durable-object-mcp.ts- Stateful MCP with DOtemplates/websocket-mcp.ts- WebSocket transport
Official Docs: https://modelcontextprotocol.io | Cloudflare: https://developers.cloudflare.com/workers/runtime-apis/durable-objects/