From a13ad77353d2b2c94eb20829cd3afd72d223a64f Mon Sep 17 00:00:00 2001 From: Konstantin Konstantinov Date: Thu, 22 Jan 2026 08:53:58 +0200 Subject: [PATCH 1/4] v2 - clean deprecated methods and exports --- packages/core/src/types/types.ts | 32 ---- packages/server/src/server/mcp.ts | 248 ------------------------------ 2 files changed, 280 deletions(-) diff --git a/packages/core/src/types/types.ts b/packages/core/src/types/types.ts index 63d6f2d23..d3e404c58 100644 --- a/packages/core/src/types/types.ts +++ b/packages/core/src/types/types.ts @@ -215,13 +215,6 @@ export const JSONRPCResultResponseSchema = z export const isJSONRPCResultResponse = (value: unknown): value is JSONRPCResultResponse => JSONRPCResultResponseSchema.safeParse(value).success; -/** - * @deprecated Use {@link isJSONRPCResultResponse} instead. - * - * Please note that {@link JSONRPCResponse} is a union of {@link JSONRPCResultResponse} and {@link JSONRPCErrorResponse} as per the updated JSON-RPC specification. (was previously just {@link JSONRPCResultResponse}) - */ -export const isJSONRPCResponse = isJSONRPCResultResponse; - /** * Error codes defined by the JSON-RPC specification. */ @@ -265,11 +258,6 @@ export const JSONRPCErrorResponseSchema = z }) .strict(); -/** - * @deprecated Use {@link JSONRPCErrorResponseSchema} instead. - */ -export const JSONRPCErrorSchema = JSONRPCErrorResponseSchema; - /** * Checks if a value is a valid JSONRPCErrorResponse. * @param value - The value to check. @@ -279,11 +267,6 @@ export const JSONRPCErrorSchema = JSONRPCErrorResponseSchema; export const isJSONRPCErrorResponse = (value: unknown): value is JSONRPCErrorResponse => JSONRPCErrorResponseSchema.safeParse(value).success; -/** - * @deprecated Use {@link isJSONRPCErrorResponse} instead. - */ -export const isJSONRPCError = isJSONRPCErrorResponse; - export const JSONRPCMessageSchema = z.union([ JSONRPCRequestSchema, JSONRPCNotificationSchema, @@ -2115,11 +2098,6 @@ export const ResourceTemplateReferenceSchema = z.object({ uri: z.string() }); -/** - * @deprecated Use ResourceTemplateReferenceSchema instead - */ -export const ResourceReferenceSchema = ResourceTemplateReferenceSchema; - /** * Identifies a prompt. */ @@ -2432,12 +2410,6 @@ export type JSONRPCRequest = Infer; export type JSONRPCNotification = Infer; export type JSONRPCResponse = Infer; export type JSONRPCErrorResponse = Infer; -/** - * @deprecated Use {@link JSONRPCErrorResponse} instead. - * - * Please note that spec types have renamed {@link JSONRPCError} to {@link JSONRPCErrorResponse} as per the updated JSON-RPC specification. (was previously just {@link JSONRPCError}) and future versions will remove {@link JSONRPCError}. - */ -export type JSONRPCError = JSONRPCErrorResponse; export type JSONRPCResultResponse = Infer; export type JSONRPCMessage = Infer; @@ -2609,10 +2581,6 @@ export type ElicitResult = Infer; /* Autocomplete */ export type ResourceTemplateReference = Infer; -/** - * @deprecated Use ResourceTemplateReference instead - */ -export type ResourceReference = ResourceTemplateReference; export type PromptReference = Infer; export type CompleteRequestParams = Infer; export type CompleteRequest = Infer; diff --git a/packages/server/src/server/mcp.ts b/packages/server/src/server/mcp.ts index 9e3be719f..2b9672d03 100644 --- a/packages/server/src/server/mcp.ts +++ b/packages/server/src/server/mcp.ts @@ -628,78 +628,6 @@ export class McpServer { this._promptHandlersInitialized = true; } - /** - * 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, - template: ResourceTemplate, - metadata: ResourceMetadata, - readCallback: ReadResourceTemplateCallback - ): RegisteredResourceTemplate; - - resource(name: string, uriOrTemplate: string | ResourceTemplate, ...rest: unknown[]): RegisteredResource | RegisteredResourceTemplate { - let metadata: ResourceMetadata | undefined; - if (typeof rest[0] === 'object') { - metadata = rest.shift() as ResourceMetadata; - } - - const readCallback = rest[0] as ReadResourceCallback | ReadResourceTemplateCallback; - - if (typeof uriOrTemplate === 'string') { - if (this._registeredResources[uriOrTemplate]) { - throw new Error(`Resource ${uriOrTemplate} is already registered`); - } - - const registeredResource = this._createRegisteredResource( - name, - undefined, - uriOrTemplate, - metadata, - readCallback as ReadResourceCallback - ); - - this.setResourceRequestHandlers(); - this.sendResourceListChanged(); - return registeredResource; - } else { - if (this._registeredResourceTemplates[name]) { - throw new Error(`Resource template ${name} is already registered`); - } - - const registeredResourceTemplate = this._createRegisteredResourceTemplate( - name, - undefined, - uriOrTemplate, - metadata, - readCallback as ReadResourceTemplateCallback - ); - - this.setResourceRequestHandlers(); - this.sendResourceListChanged(); - return registeredResourceTemplate; - } - } - /** * Registers a resource with a config object and callback. * For static resources, use a URI string. For dynamic resources, use a ResourceTemplate. @@ -925,129 +853,6 @@ export class McpServer { return registeredTool; } - /** - * 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; - - /** - * Registers a tool taking either a parameter schema for validation or annotations for additional metadata. - * This unified overload handles both `tool(name, paramsSchema, cb)` and `tool(name, annotations, cb)` cases. - * - * Note: We use a union type for the second parameter because TypeScript cannot reliably disambiguate - * between ToolAnnotations and ZodRawShapeCompat during overload resolution, as both are plain object types. - * @deprecated Use `registerTool` instead. - */ - tool( - name: string, - paramsSchemaOrAnnotations: Args | ToolAnnotations, - cb: ToolCallback - ): RegisteredTool; - - /** - * Registers a tool `name` (with a description) taking either parameter schema or annotations. - * This unified overload handles both `tool(name, description, paramsSchema, cb)` and - * `tool(name, description, annotations, cb)` cases. - * - * Note: We use a union type for the third parameter because TypeScript cannot reliably disambiguate - * between ToolAnnotations and ZodRawShapeCompat during overload resolution, as both are plain object types. - * @deprecated Use `registerTool` instead. - */ - tool( - name: string, - description: string, - paramsSchemaOrAnnotations: Args | ToolAnnotations, - cb: ToolCallback - ): RegisteredTool; - - /** - * 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, - description: string, - paramsSchema: Args, - annotations: ToolAnnotations, - cb: ToolCallback - ): RegisteredTool; - - /** - * tool() implementation. Parses arguments passed to overrides defined above. - */ - tool(name: string, ...rest: unknown[]): RegisteredTool { - if (this._registeredTools[name]) { - throw new Error(`Tool ${name} is already registered`); - } - - let description: string | undefined; - let inputSchema: ZodRawShapeCompat | undefined; - let outputSchema: ZodRawShapeCompat | undefined; - let annotations: ToolAnnotations | undefined; - - // Tool properties are passed as separate arguments, with omissions allowed. - // Support for this style is frozen as of protocol version 2025-03-26. Future additions - // to tool definition should *NOT* be added. - - if (typeof rest[0] === 'string') { - description = rest.shift() as string; - } - - // Handle the different overload combinations - if (rest.length > 1) { - // We have at least one more arg before the callback - const firstArg = rest[0]; - - if (isZodRawShapeCompat(firstArg)) { - // We have a params schema as the first arg - inputSchema = rest.shift() as ZodRawShapeCompat; - - // Check if the next arg is potentially annotations - if (rest.length > 1 && typeof rest[0] === 'object' && rest[0] !== null && !isZodRawShapeCompat(rest[0])) { - // Case: tool(name, paramsSchema, annotations, cb) - // Or: tool(name, description, paramsSchema, annotations, cb) - annotations = rest.shift() as ToolAnnotations; - } - } else if (typeof firstArg === 'object' && firstArg !== null) { - // Not a ZodRawShapeCompat, so must be annotations in this position - // Case: tool(name, annotations, cb) - // Or: tool(name, description, annotations, cb) - annotations = rest.shift() as ToolAnnotations; - } - } - const callback = rest[0] as ToolCallback; - - return this._createRegisteredTool( - name, - undefined, - description, - inputSchema, - outputSchema, - annotations, - { taskSupport: 'forbidden' }, - undefined, - callback - ); - } - /** * Registers a tool with a config object and callback. */ @@ -1082,59 +887,6 @@ 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, - description: string, - argsSchema: Args, - cb: PromptCallback - ): RegisteredPrompt; - - prompt(name: string, ...rest: unknown[]): RegisteredPrompt { - if (this._registeredPrompts[name]) { - throw new Error(`Prompt ${name} is already registered`); - } - - let description: string | undefined; - if (typeof rest[0] === 'string') { - description = rest.shift() as string; - } - - let argsSchema: PromptArgsRawShape | undefined; - if (rest.length > 1) { - argsSchema = rest.shift() as PromptArgsRawShape; - } - - const cb = rest[0] as PromptCallback; - const registeredPrompt = this._createRegisteredPrompt(name, undefined, description, argsSchema, cb); - - this.setPromptRequestHandlers(); - this.sendPromptListChanged(); - - return registeredPrompt; - } - /** * Registers a prompt with a config object and callback. */ From 9ab18b5d2953b2fbccdf31a2221dc025f434b51a Mon Sep 17 00:00:00 2001 From: Konstantin Konstantinov Date: Thu, 22 Jan 2026 11:31:49 +0200 Subject: [PATCH 2/4] prettier fix, deprecations migrate from tests --- .changeset/brave-lions-glow.md | 2 +- .github/pages/index.html | 28 +- docs/documents.md | 8 +- examples/server/src/ssePollingExample.ts | 9 +- .../node/test/streamableHttp.test.ts | 38 +- .../server/test/server/streamableHttp.test.ts | 38 +- .../test1277.zod.v4.description.test.ts | 8 +- test/integration/test/server/mcp.test.ts | 398 +++++++----------- .../stateManagementStreamableHttp.test.ts | 12 +- .../integration/test/taskResumability.test.ts | 18 +- test/integration/test/title.test.ts | 6 +- typedoc.config.mjs | 27 +- 12 files changed, 280 insertions(+), 312 deletions(-) diff --git a/.changeset/brave-lions-glow.md b/.changeset/brave-lions-glow.md index 59a1f3a3a..587183899 100644 --- a/.changeset/brave-lions-glow.md +++ b/.changeset/brave-lions-glow.md @@ -1,5 +1,5 @@ --- -"@modelcontextprotocol/node": patch +'@modelcontextprotocol/node': patch --- Prevent Hono from overriding global Response object by passing `overrideGlobalObjects: false` to `getRequestListener()`. This fixes compatibility with frameworks like Next.js whose response classes extend the native Response. diff --git a/.github/pages/index.html b/.github/pages/index.html index 4dd2f3ba7..5dd7adeaf 100644 --- a/.github/pages/index.html +++ b/.github/pages/index.html @@ -124,7 +124,7 @@

MCP TypeScript SDK

- + @@ -142,31 +142,39 @@

All Documentation Versions