You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `createMcpHandler` function creates a fetch handler to serve your MCP server. You can use it as a lightweight alternative to the [`McpAgent`](/agents/model-context-protocol/mcp-agent-api) class.
12
+
The `createMcpHandler` function creates a fetch handler to serve your MCP server. You can use it as an alternative to the [`McpAgent`](/agents/model-context-protocol/mcp-agent-api) class when you don't need the deprecated SSE transport.
13
13
14
14
It uses an implementation of the MCP Transport interface, `WorkerTransport`, built on top of web standards, which conforms to the [streamable-http](https://modelcontextprotocol.io/specification/draft/basic/transports/#streamable-http) transport specification.
15
15
@@ -20,12 +20,12 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
-**server** — An instance of `McpServer` from the `@modelcontextprotocol/sdk` package
28
+
-**server** — An instance of [`McpServer`](https://modelcontextprotocol.io/docs/develop/build-server#node) from the `@modelcontextprotocol/sdk` package
29
29
-**options** — Optional configuration object (see [`CreateMcpHandlerOptions`](#createmcphandleroptions))
An authentication context object that will be available to MCP tools via [`getMcpAuthContext()`](/agents/model-context-protocol/mcp-handler-api#authentication-context).
90
90
91
-
When using the [`OAuthProvider`](/agents/model-context-protocol/authorization/) from `@cloudflare/workers-oauth-provider`, the auth context is automatically populated with information from the OAuth flow. You typically don't need to set this manually.
91
+
When using the [`OAuthProvider`](/agents/model-context-protocol/authorization/) from `@cloudflare/workers-oauth-provider`, the authentication context is automatically populated with information from the OAuth flow. You typically don't need to set this manually.
92
92
93
93
#### transport
94
94
@@ -100,7 +100,7 @@ A custom `WorkerTransport` instance. If not provided, a new transport is created
@@ -411,7 +411,7 @@ const transport = new WorkerTransport({
411
411
412
412
## Authentication Context
413
413
414
-
When using [OAuth authentication](/agents/model-context-protocol/authorization/) with the `createMcpHandler`, user information is made available to your MCP tools through `getMcpAuthContext()`. Under the hood this uses `AsyncLocalStorage` to pass the request to the tool handler, keeping the authentication context available.
414
+
When using [OAuth authentication](/agents/model-context-protocol/authorization/) with `createMcpHandler`, user information is made available to your MCP tools through `getMcpAuthContext()`. Under the hood this uses `AsyncLocalStorage` to pass the request to the tool handler, keeping the authentication context available.
415
415
416
416
```ts
417
417
interfaceMcpAuthContext {
@@ -421,7 +421,7 @@ interface McpAuthContext {
421
421
422
422
### getMcpAuthContext
423
423
424
-
Retrieve the current authentication context within an MCP tool handler. This returns user information that was populated by the OAuth provider. Note that if using `McpAgent` this information is accessable directly on `this.props` instead.
424
+
Retrieve the current authentication context within an MCP tool handler. This returns user information that was populated by the OAuth provider. Note that if using `McpAgent`, this information is accessable directly on `this.props` instead.
0 commit comments