cloudflare -template
Reusable template for creating serverless Model Context Protocol (MCP) servers with provider plugin system. Deploy to Cloudflare Workers, Vercel, or any edge runtime.
claude mcp add --transport stdio mahmoudfazeli-cloudflare-mcp-template node src/worker.ts \ --env CF_WORKER_ENV="development" \ --env OAUTH_KV_NAMESPACE="OAuth KV namespace (set up via npm run setup-oauth)"
How to use
This MCP server template runs as a Cloudflare Workers project and exposes a provider plugin system that allows you to register and use MCP tools through a modular provider architecture. The included example provider offers basic ping/echo/status tooling out of the box, demonstrating how providers can be wired into the MCP server factory and how the MCP transport and runtime validate inputs and return consistent JSON-RPC responses. You can access the running server locally at http://localhost:8787/ once started, where you’ll see the example tools visible and invocable via the MCP API surface. The setup also includes OAuth 2.1 integration with dynamic client registration and KV-backed credential storage, enabling secure authentication flows in multi-environment deployments.
How to install
Prerequisites:
- Node.js and npm installed
- Wrangler (Cloudflare) CLI installed for local testing and deployment
- git installed
Installation steps:
-
Clone the template and prepare your project git clone https://github.com/mahmoudfazeli/cloudflare-mcp-template.git cd cloudflare-mcp-template mkdir ../your-mcp-project cp -r template/* ../your-mcp-project/ cd ../your-mcp-project/
-
Configure project name in template files
Replace placeholders in package.json and wrangler config if needed
sed 's/{{PROJECT_NAME}}/your-project-name/g' package.json.template > package.json sed 's/{{PROJECT_NAME}}/your-project-name/g' wrangler.toml.template > wrangler.toml
-
Install dependencies npm install
-
Set up OAuth 2.1 infrastructure (creates KV namespaces) npm run setup-oauth
-
Run locally for testing npm run dev
Optional for Cloudflare deployment:
- Configure Wrangler with your Cloudflare account and environment settings
- Deploy to Cloudflare Workers using Wrangler commands (e.g., wrangler publish)
Additional notes
Tips and common considerations:
- The template uses a provider plugin system; to add your own provider, follow docs in docs/PROVIDERS.md and integrate your API client with the server factory pattern.
- OAuth 2.1 integration relies on KV namespaces created by setup-oauth; ensure those namespaces are correctly provisioned in your Cloudflare account.
- Environment naming supports multiple environments (development, staging, production) to align with the template’s recommended workflow.
- When deploying, consider enabling CORS and configuring production security features as outlined in the template docs.
- If you encounter local testing limits, verify that the local dev server (port 8787) is not blocked by firewall and that Wrangler is properly configured for local emulation.
Related MCP Servers
obsidian
Obsidian Knowledge-Management MCP (Model Context Protocol) server that enables AI agents and development tools to interact with an Obsidian vault. It provides a comprehensive suite of tools for reading, writing, searching, and managing notes, tags, and frontmatter, acting as a bridge to the Obsidian Local REST API plugin.
flyto-core
The open-source execution engine for AI agents. 412 modules, MCP-native, triggers, queue, versioning, metering.
Matryoshka
MCP server for token-efficient large document analysis via the use of REPL state
ez
The easiest path to getting an MCP server going
grok-faf
First MCP server for Grok | FAST⚡️AF • URL-based AI context • Vercel-deployed
vscode-context
MCP Server to Connect with VS Code IDE