Track MCP LogoTrack MCP
Track MCP LogoTrack MCP

The world's largest repository of Model Context Protocol servers. Discover, explore, and submit MCP tools.

Product

  • Categories
  • Top MCP
  • New & Updated
  • Submit MCP

Company

  • About

Legal

  • Privacy Policy
  • Terms of Service
  • Cookie Policy

© 2026 TrackMCP. All rights reserved.

Built with ❤️ by Krishna Goyal

    My Mcp Worker

    MCP Server with Cloudflare Workers

    0 stars
    TypeScript
    Updated Mar 20, 2025

    Table of Contents

    • Introduction
    • Prerequisites
    • Getting Started
    • Step 1: Create a New Cloudflare Worker
    • Step 2: Configure Wrangler
    • Installing MCP Tooling
    • Writing MCP Server Code
    • Key Components:
    • Adding API Calls
    • Deploying the MCP Server
    • Testing the MCP Server
    • Security
    • Conclusion

    Table of Contents

    • Introduction
    • Prerequisites
    • Getting Started
    • Step 1: Create a New Cloudflare Worker
    • Step 2: Configure Wrangler
    • Installing MCP Tooling
    • Writing MCP Server Code
    • Key Components:
    • Adding API Calls
    • Deploying the MCP Server
    • Testing the MCP Server
    • Security
    • Conclusion

    Documentation

    MCP Server with Cloudflare Workers

    Introduction

    Model Context Protocol (MCP) is an open standard that enables AI agents and assistants to interact with services. By setting up an MCP server, you can allow AI assistants to access your APIs directly.

    Cloudflare Workers, combined with the workers-mcp package, provide a powerful and scalable solution for building MCP servers.

    Prerequisites

    Before starting, ensure you have:

    • A Cloudflare account
    • Node.js installed
    • Wrangler CLI installed (npm install -g wrangler)

    ---

    Getting Started

    Step 1: Create a New Cloudflare Worker

    First, initialize a new Cloudflare Worker project:

    bash
    npx create-cloudflare@latest my-mcp-worker
    cd my-mcp-worker

    Then, authenticate your Cloudflare account:

    bash
    wrangler login

    Step 2: Configure Wrangler

    Update your wrangler.toml file with the correct account details:

    toml
    name = "my-mcp-worker"
    main = "src/index.ts"
    compatibility_date = "2025-03-03"
    account_id = "your-account-id"

    ---

    Installing MCP Tooling

    To enable MCP support, install the workers-mcp package:

    bash
    npm install workers-mcp

    Run the setup command to configure MCP:

    bash
    npx workers-mcp setup

    This will:

    • Add necessary dependencies
    • Set up a local proxy for testing
    • Configure the Worker for MCP compliance

    ---

    Writing MCP Server Code

    Update your src/index.ts to define your MCP server:

    typescript
    import { WorkerEntrypoint } from 'cloudflare:workers';
    import { ProxyToSelf } from 'workers-mcp';
    
    export default class MyWorker extends WorkerEntrypoint {
      /**
       * A friendly greeting from your MCP server.
       * @param name {string} The name of the user.
       * @return {string} A personalized greeting.
       */
      sayHello(name: string) {
        return `Hello from an MCP Worker, ${name}!`;
      }
    
      /**
       * @ignore
       */
      async fetch(request: Request): Promise {
        return new ProxyToSelf(this).fetch(request);
      }
    }

    Key Components:

    • WorkerEntrypoint: Manages incoming requests and method exposure.
    • ProxyToSelf: Ensures MCP protocol compliance.
    • sayHello method: An example MCP function that AI assistants can call.

    ---

    Adding API Calls

    You can extend your MCP server by integrating with external APIs. Here's an example of fetching weather data:

    typescript
    export default class WeatherWorker extends WorkerEntrypoint {
      /**
       * Fetch weather data for a given location.
       * @param location {string} The city or ZIP code.
       * @return {object} Weather details.
       */
      async getWeather(location: string) {
        const response = await fetch(`https://api.weather.example/v1/${location}`);
        const data = await response.json();
        return {
          temperature: data.temp,
          conditions: data.conditions,
          forecast: data.forecast
        };
      }
    
      async fetch(request: Request): Promise {
        return new ProxyToSelf(this).fetch(request);
      }
    }

    ---

    Deploying the MCP Server

    Once your Worker is set up, deploy it to Cloudflare:

    bash
    npx wrangler deploy

    After deployment, your Worker is live and AI assistants can discover and use your MCP tools.

    To update your MCP server, redeploy with:

    bash
    npm run deploy

    ---

    Testing the MCP Server

    To test your MCP setup locally:

    bash
    npx workers-mcp proxy

    This command starts a local proxy allowing MCP clients (like Claude Desktop) to connect.

    ---

    Security

    To secure your MCP server, use Wrangler Secrets:

    bash
    npx wrangler secret put MCP_SECRET

    This adds a shared-secret authentication mechanism to prevent unauthorized access.

    ---

    Conclusion

    Congratulations! You have successfully built and deployed an MCP server using Cloudflare Workers. You can now extend it with more features and expose new tools for AI assistants.

    For more details, check the Cloudflare MCP documentation.

    ---

    Similar MCP

    Based on tags & features

    • MC

      Mcp Wave

      TypeScript00
    • GL

      Glm Mcp Server

      TypeScript·
      3
    • OP

      Openai Gpt Image Mcp

      TypeScript·
      75
    • MC

      Mcgravity

      TypeScript·
      71

    Trending MCP

    Most active this week

    • PL

      Playwright Mcp

      TypeScript·
      22.1k
    • SE

      Serena

      Python·
      14.5k
    • MC

      Mcp Playwright

      TypeScript·
      4.9k
    • MC

      Mcp Server Cloudflare

      TypeScript·
      3.0k
    View All MCP Servers

    Similar MCP

    Based on tags & features

    • MC

      Mcp Wave

      TypeScript00
    • GL

      Glm Mcp Server

      TypeScript·
      3
    • OP

      Openai Gpt Image Mcp

      TypeScript·
      75
    • MC

      Mcgravity

      TypeScript·
      71

    Trending MCP

    Most active this week

    • PL

      Playwright Mcp

      TypeScript·
      22.1k
    • SE

      Serena

      Python·
      14.5k
    • MC

      Mcp Playwright

      TypeScript·
      4.9k
    • MC

      Mcp Server Cloudflare

      TypeScript·
      3.0k