From 0eec90b01ba5a5ca02a6248ff3f600c759e83034 Mon Sep 17 00:00:00 2001 From: Adam Jones Date: Fri, 10 Oct 2025 01:45:32 +0100 Subject: [PATCH] Add @deprecated annotations to legacy APIs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Deprecate Server class in favor of McpServer for most use cases - Deprecate McpServer.tool(), .resource(), .prompt() methods in favor of registerTool(), registerResource(), registerPrompt() - Deprecate SSEServerTransport and SSEClientTransport in favor of StreamableHTTPServerTransport and StreamableHTTPClientTransport - Add migration guidance for clients that may need to support both SSE and Streamable HTTP during transition period 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/client/sse.ts | 1 + src/server/index.ts | 1 + src/server/mcp.ts | 14 ++++++++++++++ src/server/sse.ts | 1 + 4 files changed, 17 insertions(+) diff --git a/src/client/sse.ts b/src/client/sse.ts index aa4942444..800cfd2b3 100644 --- a/src/client/sse.ts +++ b/src/client/sse.ts @@ -57,6 +57,7 @@ export type SSEClientTransportOptions = { /** * Client transport for SSE: this will connect to a server using Server-Sent Events for receiving * messages and make separate POST requests for sending messages. + * @deprecated SSEClientTransport is deprecated. Prefer to use StreamableHTTPClientTransport where possible instead. Note that because some servers are still using SSE, clients may need to support both transports during the migration period. */ export class SSEClientTransport implements Transport { private _eventSource?: EventSource; diff --git a/src/server/index.ts b/src/server/index.ts index 3eb0ba0d4..6d91b62e8 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -69,6 +69,7 @@ export type ServerOptions = ProtocolOptions & { * version: "1.0.0" * }) * ``` + * @deprecated Use `McpServer` instead for the high-level API. Only use `Server` for advanced use cases. */ export class Server< RequestT extends Request = Request, diff --git a/src/server/mcp.ts b/src/server/mcp.ts index cef1722d6..e689ca1f4 100644 --- a/src/server/mcp.ts +++ b/src/server/mcp.ts @@ -423,21 +423,25 @@ export class McpServer { /** * Registers a resource `name` at a fixed URI, which will use the given callback to respond to read requests. + * @deprecated Use `registerResource` instead. */ resource(name: string, uri: string, readCallback: ReadResourceCallback): RegisteredResource; /** * Registers a resource `name` at a fixed URI with metadata, which will use the given callback to respond to read requests. + * @deprecated Use `registerResource` instead. */ resource(name: string, uri: string, metadata: ResourceMetadata, readCallback: ReadResourceCallback): RegisteredResource; /** * Registers a resource `name` with a template pattern, which will use the given callback to respond to read requests. + * @deprecated Use `registerResource` instead. */ resource(name: string, template: ResourceTemplate, readCallback: ReadResourceTemplateCallback): RegisteredResourceTemplate; /** * Registers a resource `name` with a template pattern and metadata, which will use the given callback to respond to read requests. + * @deprecated Use `registerResource` instead. */ resource( name: string, @@ -687,11 +691,13 @@ export class McpServer { /** * Registers a zero-argument tool `name`, which will run the given function when the client calls it. + * @deprecated Use `registerTool` instead. */ tool(name: string, cb: ToolCallback): RegisteredTool; /** * Registers a zero-argument tool `name` (with a description) which will run the given function when the client calls it. + * @deprecated Use `registerTool` instead. */ tool(name: string, description: string, cb: ToolCallback): RegisteredTool; @@ -701,6 +707,7 @@ export class McpServer { * * Note: We use a union type for the second parameter because TypeScript cannot reliably disambiguate * between ToolAnnotations and ZodRawShape during overload resolution, as both are plain object types. + * @deprecated Use `registerTool` instead. */ tool(name: string, paramsSchemaOrAnnotations: Args | ToolAnnotations, cb: ToolCallback): RegisteredTool; @@ -711,6 +718,7 @@ export class McpServer { * * Note: We use a union type for the third parameter because TypeScript cannot reliably disambiguate * between ToolAnnotations and ZodRawShape during overload resolution, as both are plain object types. + * @deprecated Use `registerTool` instead. */ tool( name: string, @@ -721,11 +729,13 @@ export class McpServer { /** * Registers a tool with both parameter schema and annotations. + * @deprecated Use `registerTool` instead. */ tool(name: string, paramsSchema: Args, annotations: ToolAnnotations, cb: ToolCallback): RegisteredTool; /** * Registers a tool with description, parameter schema, and annotations. + * @deprecated Use `registerTool` instead. */ tool( name: string, @@ -818,21 +828,25 @@ export class McpServer { /** * Registers a zero-argument prompt `name`, which will run the given function when the client calls it. + * @deprecated Use `registerPrompt` instead. */ prompt(name: string, cb: PromptCallback): RegisteredPrompt; /** * Registers a zero-argument prompt `name` (with a description) which will run the given function when the client calls it. + * @deprecated Use `registerPrompt` instead. */ prompt(name: string, description: string, cb: PromptCallback): RegisteredPrompt; /** * Registers a prompt `name` accepting the given arguments, which must be an object containing named properties associated with Zod schemas. When the client calls it, the function will be run with the parsed and validated arguments. + * @deprecated Use `registerPrompt` instead. */ prompt(name: string, argsSchema: Args, cb: PromptCallback): RegisteredPrompt; /** * Registers a prompt `name` (with a description) accepting the given arguments, which must be an object containing named properties associated with Zod schemas. When the client calls it, the function will be run with the parsed and validated arguments. + * @deprecated Use `registerPrompt` instead. */ prompt( name: string, diff --git a/src/server/sse.ts b/src/server/sse.ts index 3405af705..a0fe0a3b4 100644 --- a/src/server/sse.ts +++ b/src/server/sse.ts @@ -36,6 +36,7 @@ export interface SSEServerTransportOptions { * Server transport for SSE: this will send messages over an SSE connection and receive messages from HTTP POST requests. * * This transport is only available in Node.js environments. + * @deprecated SSEServerTransport is deprecated. Use StreamableHTTPServerTransport instead. */ export class SSEServerTransport implements Transport { private _sseResponse?: ServerResponse;