Skip to content

Commit 4da191c

Browse files
Drop the experimental on createMcpHandler (#603)
* refactor: rename experimental_createMcpHandler to createMcpHandler and add deprecation warning * Create two-deers-help.md * Update two-deers-help.md --------- Co-authored-by: Sunil Pai <spai@cloudflare.com>
1 parent aed8e18 commit 4da191c

File tree

6 files changed

+32
-7
lines changed

6 files changed

+32
-7
lines changed

.changeset/two-deers-help.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"agents": patch
3+
---
4+
5+
Drop the experimental\_ prefix on createMcpHandler

examples/mcp-worker-authenticated/src/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
experimental_createMcpHandler as createMcpHandler,
3-
getMcpAuthContext
4-
} from "agents/mcp";
1+
import { createMcpHandler, getMcpAuthContext } from "agents/mcp";
52
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
63
import { z } from "zod";
74
import { OAuthProvider } from "@cloudflare/workers-oauth-provider";

examples/mcp-worker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MCP Worker Example
22

3-
This example demonstrates how to use `experimental_createMcpHandler` to create an unauthenticated stateless MCP server.
3+
This example demonstrates how to use `createMcpHandler` to create an unauthenticated stateless MCP server.
44

55
This is THE simplest way to get started with MCP on Cloudflare.
66

examples/mcp-worker/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { experimental_createMcpHandler as createMcpHandler } from "agents/mcp";
1+
import { createMcpHandler } from "agents/mcp";
22
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
33
import { z } from "zod";
44

packages/agents/src/mcp/handler.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export type OAuthExecutionContext = ExecutionContext & {
3535
props?: Record<string, unknown>;
3636
};
3737

38-
export function experimental_createMcpHandler(
38+
export function createMcpHandler(
3939
server: McpServer | Server,
4040
options: CreateMcpHandlerOptions = {}
4141
): (
@@ -92,3 +92,25 @@ export function experimental_createMcpHandler(
9292
}
9393
};
9494
}
95+
96+
let didWarnAboutExperimentalCreateMcpHandler = false;
97+
98+
/**
99+
* @deprecated This has been renamed to createMcpHandler, and experimental_createMcpHandler will be removed in the next major version
100+
*/
101+
export function experimental_createMcpHandler(
102+
server: McpServer | Server,
103+
options: CreateMcpHandlerOptions = {}
104+
): (
105+
request: Request,
106+
env: unknown,
107+
ctx: ExecutionContext
108+
) => Promise<Response> {
109+
if (!didWarnAboutExperimentalCreateMcpHandler) {
110+
didWarnAboutExperimentalCreateMcpHandler = true;
111+
console.warn(
112+
"experimental_createMcpHandler is deprecated, use createMcpHandler instead. experimental_createMcpHandler will be removed in the next major version."
113+
);
114+
}
115+
return createMcpHandler(server, options);
116+
}

packages/agents/src/mcp/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ export type {
448448
} from "./client";
449449

450450
export {
451+
createMcpHandler,
451452
experimental_createMcpHandler,
452453
type CreateMcpHandlerOptions,
453454
type OAuthExecutionContext

0 commit comments

Comments
 (0)