Build a Remote MCP Server (Cloudflare Agents)
by Cloudflare
Deploy a remote MCP server on Cloudflare, with or without auth.
Overview
This Cloudflare Agents guide walks through deploying a remote Model Context Protocol server using Streamable HTTP transport, the current MCP standard. It presents three approaches: createMcpHandler() for stateless tools, McpAgent (a Durable Object per session) for stateful implementations with built-in state management, and raw transport with the @modelcontextprotocol/sdk for full control. It covers deploying a public server without authentication via dashboard or CLI templates (live instantly on a workers.dev subdomain), testing locally with the MCP Inspector, connecting clients like Claude Desktop through local proxies, and adding authentication via Cloudflare Access or direct OAuth 2.0, with a step-by-step GitHub OAuth walkthrough for separate dev and production apps.
At a Glance
- Topic
- MCP
- Level
- Intermediate
- Format
- Tutorial
- Cost
- Free
- Duration
- ~30-45 min, hands-on
- Provider
- Cloudflare
- Hands-on
- Yes — code/exercises
- Certificate
- None
What You’ll Learn
- ✓Deploying a remote MCP server with Streamable HTTP on Cloudflare
- ✓Choosing between stateless handlers, McpAgent, and raw transport
- ✓Testing your server with MCP Inspector
- ✓Adding OAuth authentication with Cloudflare Access or GitHub
Highlights
- •First-party guide from a major edge platform
- •Covers both no-auth and OAuth-secured deployments
- •Connect real clients like Claude Desktop
Who It’s For
Best For
- ✓Engineers deploying production remote MCP servers
- ✓Developers on Cloudflare Workers/Agents
Prerequisites
- •JavaScript/TypeScript and Node basics
- •A Cloudflare account and familiarity with Workers
FAQ
What is Build a Remote MCP Server (Cloudflare Agents)?
Cloudflare's guide to deploying a remote MCP server using Streamable HTTP transport, including optional OAuth authentication. For developers who want a real, internet-reachable MCP server on the edge.
Is Build a Remote MCP Server (Cloudflare Agents) free?
Build a Remote MCP Server (Cloudflare Agents) is free to access.
What level is Build a Remote MCP Server (Cloudflare Agents) for?
Build a Remote MCP Server (Cloudflare Agents) is aimed at a intermediate audience. Recommended background: JavaScript/TypeScript and Node basics, A Cloudflare account and familiarity with Workers.
How long does Build a Remote MCP Server (Cloudflare Agents) take?
Expect roughly ~30-45 min, hands-on. Most learners work through it at their own pace.
What will I learn from Build a Remote MCP Server (Cloudflare Agents)?
You'll learn: Deploying a remote MCP server with Streamable HTTP on Cloudflare; Choosing between stateless handlers, McpAgent, and raw transport; Testing your server with MCP Inspector; Adding OAuth authentication with Cloudflare Access or GitHub.