A proof of concept implementation of Model Context Protocol server running on Cloudflare's edge network with bearer token authentication, allowing deployed AI models to access tools via serverless architecture.
This repository demonstrates a proof of concept implementation of a Model Context Protocol (MCP) server running on Cloudflare Workers with simple bearer token authentication.
This project shows how to:
# Install dependencies npm install # Run the server locally npm run dev
After starting the server, it will be available at http://localhost:8787
This implementation uses a simple bearer token authentication scheme. Clients must provide an Authorization header with their requests. The server passes this token to the MCP tools, allowing tools to perform actions based on the authenticated user.
You can use the MCP Inspector to test your MCP server:
Install and start the inspector:
npx @modelcontextprotocol/inspector
Configure the inspector:
SSE
http://localhost:8787/sse
or deployed: https://your-worker.workers.dev/sse
)Test the functionality:
Deploy your MCP server to Cloudflare Workers:
npm run deploy
After deployment, your server will be available at https://your-worker.workers.dev
src/index.ts
- Main server implementation with MCP tools definitionsrc/utils.ts
- Helper utilities for rendering the web interfacewrangler.jsonc
- Cloudflare Workers configurationThis is a proof of concept implementation meant to demonstrate how MCP can run in a serverless environment. In a production setting, you would want to implement:
If you encounter issues:
For persistent authentication issues, you may need to clear any cached credentials:
rm -rf ~/.mcp-auth
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!