MCPAgentic

Build a Remote MCP Server (Cloudflare Agents)

by Cloudflare

IntermediateTutorialFreeSelf-paced; the templated deploy takes minutes, adding OAuth takes considerably longer

Get an authenticated, internet-reachable MCP server live on Workers — not another stdio demo.

Start LearningAdded Jul 4, 2026 · Updated Aug 9, 2026

Overview

This is Cloudflare's official walkthrough for standing up a remote MCP server, and it is organised as five sections: choosing an approach, deploying your first server, connecting from an MCP client via a local proxy, adding authentication, and next steps. It opens with the architectural decision most tutorials never raise — a stateless server built on createMcpHandler versus a stateful one backed by Durable Objects, which is what lets an MCP server hold per-session state such as a cart, a knowledge graph or a game rather than acting as a thin API shim. Scaffolding is a single command (npm create cloudflare@latest -- remote-mcp-server-authless --template=cloudflare/ai/demos/remote-mcp-authless), local testing runs through npx @modelcontextprotocol/inspector@latest, and deployment is npx wrangler@latest deploy. Transport is Streamable HTTP. The authentication section is the substantial half: Cloudflare's workers-oauth-provider library implements OAuth 2.1 including Dynamic Client Registration and Authorization Server Metadata, so the MCP server itself acts as an authorization server and issues its own tokens — limiting blast radius if it is compromised — and the guide names Cloudflare Access plus third-party providers including GitHub, Google, Slack, Stytch, Auth0 and WorkOS, with separate OAuth apps for development and production and a KV namespace for session storage. The templates it points at are public and maintained in the cloudflare/ai repository, which carries roughly sixteen MCP demos covering authless, bearer-auth, AutoRAG and one variant per identity provider.

At a Glance

Topic
MCP
Level
Intermediate
Format
Tutorial
Cost
Free
Duration
Self-paced; the templated deploy takes minutes, adding OAuth takes considerably longer
Provider
Cloudflare
Hands-on
Yes — code/exercises
Certificate
None

What You’ll Learn

  • Choose between a stateless createMcpHandler and a stateful Durable Object server
  • Scaffold a working remote MCP server from a Cloudflare template in one command
  • Deploy an MCP server to a public URL with npx wrangler deploy
  • Exercise a remote server locally through the MCP Inspector and a local proxy
  • Add OAuth so the MCP server acts as its own authorization server
  • Wire third-party identity providers such as GitHub, Google, Auth0 or WorkOS
  • Store session state in a KV namespace and manage production secrets separately

Highlights

  • Teaches remote MCP over Streamable HTTP, not the local stdio setup most tutorials assume
  • Authentication is a first-class chapter, not an appendix — it is the hardest part of remote MCP
  • Backed by roughly sixteen runnable templates in the public cloudflare/ai repository
  • workers-oauth-provider implements OAuth 2.1 with Dynamic Client Registration out of the box
  • Durable Objects give MCP servers real per-session state without you running any infrastructure

Who It’s For

Best For

  • Engineers moving an MCP server off stdio onto a hosted URL
  • Teams that need authenticated, multi-user MCP servers
  • TypeScript developers already working with Cloudflare Workers

Prerequisites

  • Working TypeScript/JavaScript and Node.js tooling knowledge
  • A Cloudflare account and basic familiarity with Workers and Wrangler
  • Understanding of what MCP tools and MCP clients are

FAQ

What is Build a Remote MCP Server (Cloudflare Agents)?

Cloudflare's official guide to deploying a remote MCP server on Workers over Streamable HTTP, with optional OAuth. It covers choosing between a stateless handler and a stateful Durable Object server, scaffolding from a template, testing through the MCP Inspector, and then bolting on real authentication. The end state is an MCP server on a public URL that other people can actually connect to.

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: Working TypeScript/JavaScript and Node.js tooling knowledge, A Cloudflare account and basic familiarity with Workers and Wrangler, Understanding of what MCP tools and MCP clients are.

How long does Build a Remote MCP Server (Cloudflare Agents) take?

Expect roughly Self-paced; the templated deploy takes minutes, adding OAuth takes considerably longer. Most learners work through it at their own pace.

What will I learn from Build a Remote MCP Server (Cloudflare Agents)?

You'll learn: Choose between a stateless createMcpHandler and a stateful Durable Object server; Scaffold a working remote MCP server from a Cloudflare template in one command; Deploy an MCP server to a public URL with npx wrangler deploy; Exercise a remote server locally through the MCP Inspector and a local proxy; Add OAuth so the MCP server acts as its own authorization server; Wire third-party identity providers such as GitHub, Google, Auth0 or WorkOS; Store session state in a KV namespace and manage production secrets separately.

Topics

MCPCloudflareWorkersOAuthremote-mcpTypeScript

Sources

This page was written from 3 sources, 2 on domains other than developers.cloudflare.com.

  1. 1.developers.cloudflare.comremote mcp servervendor
  2. 2.github.comdemos
  3. 3.blog.cloudflare.comremote model context protocol servers mcp