Back to Blog

How to Deploy an MCP Server on Cloudflare Workers in 2025

Model Context Protocol (MCP) is transforming how AI agents interact with external systems. Here's how to deploy a production-ready MCP server on Cloudflare Workers with sub-50ms response times.

What is MCP?

Model Context Protocol is an open standard developed by Anthropic that allows AI assistants like Claude to securely connect to external data sources and tools. Think of it as a universal connector between your AI and your business systems.

Why Cloudflare Workers?

Cloudflare Workers offer several advantages for MCP deployments:

  • Global edge network: Deploy to 300+ locations worldwide
  • Blazing fast: Sub-50ms response times typical
  • Serverless: No infrastructure to manage
  • Cost-effective: 100,000 free requests per day
  • TypeScript support: Modern development experience

Prerequisites

Before you start, you'll need:

  • A Cloudflare account (free tier works fine)
  • Node.js 18+ installed
  • Basic TypeScript knowledge
  • An API you want to connect (Supabase, Notion, etc.)

Step 1: Set Up Your Project

npm create cloudflare@latest mcp-server
cd mcp-server
npm install @modelcontextprotocol/sdk

Step 2: Create Your MCP Server

Create a basic MCP server that exposes tools to Claude:

import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';

const server = new Server({
  name: 'my-mcp-server',
  version: '1.0.0',
}, {
  capabilities: {
    tools: {},
  },
});

// Define your tools
server.setRequestHandler('tools/list', async () => ({
  tools: [{
    name: 'get_data',
    description: 'Fetch data from your API',
    inputSchema: {
      type: 'object',
      properties: {
        query: { type: 'string' }
      }
    }
  }]
}));

// Handle tool calls
server.setRequestHandler('tools/call', async (request) => {
  // Your API integration logic here
  return { content: [{ type: 'text', text: 'Result' }] };
});

const transport = new StdioServerTransport();
await server.connect(transport);

Step 3: Deploy to Cloudflare

npx wrangler deploy

Step 4: Connect to Claude

Once deployed, add your MCP server to Claude Desktop by updating the config file at ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "my-server": {
      "url": "https://your-worker.workers.dev"
    }
  }
}

Performance Optimization

To achieve sub-50ms response times:

  • Cache frequently accessed data
  • Use KV storage for persistent data
  • Minimize external API calls
  • Keep bundle size small

Real-World Example

At Linux Stewards, we've deployed MCP servers that achieve consistent 30-50ms response times across UK and Europe. Our production deployments handle thousands of requests daily with 99.9% uptime.

Next Steps

Need help deploying your own MCP server? We offer integration packages starting at £1,500 with full deployment in 5-7 days.

Ready to Deploy Your MCP Server?

Book a free 30-minute strategy call to discuss your AI integration needs.

Book Free Call →