|
7 | 7 | order: 5 |
8 | 8 | --- |
9 | 9 |
|
10 | | -import { Details, Render, PackageManagers } from "~/components"; |
11 | | - |
12 | | -## Deploy a Stateless MCP Server |
| 10 | +import { Details, Render, PackageManagers, WranglerConfig } from "~/components"; |
13 | 11 |
|
14 | 12 | This guide will show you how to deploy a stateless MCP server on Cloudflare Workers using `experimental_createMcpHandler`. This is the simplest way to get started with MCP on Cloudflare. |
15 | 13 |
|
@@ -41,12 +39,6 @@ Install the required dependencies: |
41 | 39 | pkg="@modelcontextprotocol/sdk agents zod" |
42 | 40 | /> |
43 | 41 |
|
44 | | -<PackageManagers |
45 | | - type="install" |
46 | | - pkg="wrangler" |
47 | | - dev |
48 | | -/> |
49 | | - |
50 | 42 | ### Implement your MCP server |
51 | 43 |
|
52 | 44 | Create a `src/index.ts` file with your MCP server implementation: |
@@ -159,12 +151,6 @@ Install the required dependencies: |
159 | 151 | pkg="@modelcontextprotocol/sdk agents zod @cloudflare/workers-oauth-provider hono" |
160 | 152 | /> |
161 | 153 |
|
162 | | -<PackageManagers |
163 | | - type="install" |
164 | | - pkg="wrangler" |
165 | | - dev |
166 | | -/> |
167 | | - |
168 | 154 | ### Set up KV namespace |
169 | 155 |
|
170 | 156 | Create a KV namespace to store OAuth tokens and client registrations: |
@@ -387,31 +373,6 @@ For authenticated servers, the `OAuthProvider` wrapper: |
387 | 373 | 3. Injects user context into `getMcpAuthContext()` |
388 | 374 | 4. Routes authenticated requests to your MCP handler |
389 | 375 |
|
390 | | -### Architecture comparison |
391 | | - |
392 | | -**Stateless MCP Server (Worker):** |
393 | | -``` |
394 | | -Client → Worker → createMcpHandler → MCP Server → Tools |
395 | | -``` |
396 | | - |
397 | | -**Authenticated Stateless MCP Server:** |
398 | | -``` |
399 | | -Client → OAuth Flow → Token → Worker → OAuthProvider → createMcpHandler → MCP Server → Tools |
400 | | - ↓ |
401 | | - getMcpAuthContext() |
402 | | -``` |
403 | | - |
404 | | -**Durable Object MCP Server (MCPAgent):** |
405 | | -``` |
406 | | -Client → Worker → Durable Object (MCPAgent) → MCP Server → Tools |
407 | | - ↓ |
408 | | - Persistent State |
409 | | -``` |
410 | | - |
411 | | -Stateless servers are ideal when you don't need persistent state between requests. For servers that need to maintain conversation history, state, or long-running sessions, consider using the [Durable Object-based MCPAgent approach](/agents/model-context-protocol/). |
412 | | - |
413 | | -Learn more about connecting MCP clients in the [Test a Remote MCP Server](/agents/guides/test-remote-mcp-server/) guide. |
414 | | - |
415 | 376 | ## Next steps |
416 | 377 |
|
417 | 378 | - Add [tools](/agents/model-context-protocol/tools/) to your MCP server |
|
0 commit comments