AI agents · OpenClaw · self-hosting · automation

Quick Answer

How to Deploy a Remote MCP Server (2026): 3 Hosts Compared

Published:

The short answer

Write the server against the Streamable HTTP transport, deploy it to Cloudflare Workers (fastest), Vercel (if it lives in a Next.js app) or Google Cloud Run (any language, in a container), and put OAuth 2.1 in front of anything that touches user data. A remote MCP server is just an HTTPS endpoint — usually /mcp — that speaks JSON-RPC. Steps below follow each vendor’s documentation and the MCP specification as of November 22, 2026.

The three hosts compared

Cloudflare WorkersVercelGoogle Cloud Run
How you write itcreateMcpHandler from the Agents SDK (stateless)mcp-handler v2 + MCP SDK v2 + Zod v4 in Next.js App RouterAny MCP SDK in a container
LanguageTypeScript / JavaScriptTypeScript (Node.js 22+)Any
AuthWorkers OAuth Provider (GitHub, Google, Cloudflare Access, other IdPs)OAuth support; Vercel Connect for clientsIAM, identity-aware proxy
StateStateless handler; KV, D1 or a Durable Object for persistenceFluid compute instance sharingYour choice (Cloud SQL, Firestore)
Fastest startDeploy-to-Workers button or npm create cloudflare templateAdd a route to an existing appgcloud run deploy from source
Best forPublic or multi-user servers, low latencyMCP endpoint inside a web appPython/Go servers, private VPC data

Step 1 — Pick the transport and spec revision

The MCP specification’s current revision is 2026-07-28. It defines two transports: stdio for a server launched as a local subprocess, and Streamable HTTP, where the client POSTs JSON-RPC and gets back a JSON object or a request-scoped SSE stream. Remote servers use Streamable HTTP. The 2026-07-28 revision makes requests stateless and self-contained, which suits serverless hosts; earlier revisions held a connection-scoped session. If you are converting a local stdio server, keep the tool code and swap the transport.

Step 2 — Deploy

Cloudflare Workers. Run npm create cloudflare@latest -- remote-mcp-server-authless --template=cloudflare/ai/demos/remote-mcp-authless, add tools, then npx wrangler deploy. The server goes live at your-worker.your-account.workers.dev/mcp. The handler builds a fresh McpServer per request, so no Durable Object is needed unless tools must remember state. Older McpAgent servers have a migration guide to MCP SDK v2.

Vercel. In a Next.js App Router project, install mcp-handler v2, the MCP SDK v2 and Zod v4, add a route (for example app/api/[transport]/route.ts) that registers your tools, and deploy. Fluid compute handles MCP’s pattern of long idle periods and short bursts by sharing instances. Vercel’s Hobby plan is $0 and Pro $20 a month.

Google Cloud Run. Containerize a server built with any MCP SDK on Streamable HTTP, then gcloud run deploy. Leave “allow unauthenticated” off and grant callers the Cloud Run Invoker role, or put Identity-Aware Proxy in front for user sign-in. Cloud Run does not host stdio servers.

Step 3 — Add authentication

The MCP authorization spec makes a protected server an OAuth 2.1 resource server and requires it to publish OAuth 2.0 Protected Resource Metadata (RFC 9728) so clients such as Claude, ChatGPT or Cursor can find the authorization server and run the sign-in flow. Do not invent API-key headers for multi-user servers — clients increasingly expect the standard flow.

  • On Cloudflare: build an authorization server Worker with OAuthAuthorizationServer (its /authorize page signs users in via GitHub, Google, Cloudflare Access or another IdP) and wrap createMcpHandler in OAuthResourceServer, which validates each token over a Service Binding. Tools can then be allowed or denied per user.
  • For a managed identity layer instead, see best auth platforms for AI agents and MCP servers.

Step 4 — Test and connect

  1. Point the MCP Inspector or Cloudflare’s AI Playground at your /mcp URL and call each tool.
  2. Add the URL as a custom connector in your client; complete the OAuth flow once.
  3. Log every tool call with user ID and arguments — you will need it for debugging and audits.

Step 5 — Harden before sharing

  • Scope tools per user, not per server; a read-only user should not see write tools.
  • Validate every argument with a schema (Zod or Pydantic) and cap result sizes so a tool cannot flood the model’s context.
  • Rate-limit per token, and set a spend alert on the host.
  • Front many servers with a gateway once you run more than a few — see best MCP gateways.

New to MCP servers? Start with how to build an MCP server.

Last verified: November 22, 2026.

Sources