v2 - clean deprecated methods and exports (#1419)

Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com>
This commit is contained in:
Konstantin Konstantinov 2026-01-23 18:39:14 +02:00 • committed by GitHub
commit dcf708d892
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 258 additions and 565 deletions

View file

@ -0,0 +1,8 @@
---
'@modelcontextprotocol/node': patch
'@modelcontextprotocol/test-integration': patch
'@modelcontextprotocol/server': patch
'@modelcontextprotocol/core': patch
---
remove deprecated .tool, .prompt, .resource method signatures

View file

@ -0,0 +1,8 @@
---
'@modelcontextprotocol/node': patch
'@modelcontextprotocol/test-integration': patch
'@modelcontextprotocol/server': patch
'@modelcontextprotocol/core': patch
---
deprecated .tool, .prompt, .resource method removal

View file

@ -35,11 +35,12 @@ const server = new McpServer(
);
// Register a long-running tool that demonstrates server-initiated disconnect
server.tool(
server.registerTool(
'long-task',
'A long-running task that sends progress updates. Server will disconnect mid-task to demonstrate polling.',
{},
async (_args, extra): Promise<CallToolResult> => {
{
description: 'A long-running task that sends progress updates. Server will disconnect mid-task to demonstrate polling.'
},
async (extra): Promise<CallToolResult> => {
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
console.log(`[${extra.sessionId}] Starting long-task...`);

View file

@ -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<typeof JSONRPCRequestSchema>;
export type JSONRPCNotification = Infer<typeof JSONRPCNotificationSchema>;
export type JSONRPCResponse = Infer<typeof JSONRPCResponseSchema>;
export type JSONRPCErrorResponse = Infer<typeof JSONRPCErrorResponseSchema>;
/**
* @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<typeof JSONRPCResultResponseSchema>;
export type JSONRPCMessage = Infer<typeof JSONRPCMessageSchema>;
@ -2609,10 +2581,6 @@ export type ElicitResult = Infer<typeof ElicitResultSchema>;
/* Autocomplete */
export type ResourceTemplateReference = Infer<typeof ResourceTemplateReferenceSchema>;
/**
* @deprecated Use ResourceTemplateReference instead
*/
export type ResourceReference = ResourceTemplateReference;
export type PromptReference = Infer<typeof PromptReferenceSchema>;
export type CompleteRequestParams = Infer<typeof CompleteRequestParamsSchema>;
export type CompleteRequest = Infer<typeof CompleteRequestSchema>;

View file

@ -161,10 +161,12 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
config ??= { sessionIdGenerator: () => randomUUID() };
const mcpServer = new McpServer({ name: 'test-server', version: '1.0.0' }, { capabilities: { logging: {} } });
mcpServer.tool(
mcpServer.registerTool(
'greet',
'A simple greeting tool',
{ name: z.string().describe('Name to greet') },
{
description: 'A simple greeting tool',
inputSchema: { name: z.string().describe('Name to greet') }
},
async ({ name }): Promise<CallToolResult> => {
return { content: [{ type: 'text', text: `Hello, ${name}!` }] };
}
@ -206,10 +208,12 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
}> {
const mcpServer = new McpServer({ name: 'test-server', version: '1.0.0' }, { capabilities: { logging: {} } });
mcpServer.tool(
mcpServer.registerTool(
'profile',
'A user profile data tool',
{ active: z.boolean().describe('Profile status') },
{
description: 'A user profile data tool',
inputSchema: { active: z.boolean().describe('Profile status') }
},
async ({ active }, { authInfo }): Promise<CallToolResult> => {
return { content: [{ type: 'text', text: `${active ? 'Active' : 'Inactive'} profile from token: ${authInfo?.token}!` }] };
}
@ -394,10 +398,12 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
it('should pass request info to tool callback', async () => {
sessionId = await initializeServer();
mcpServer.tool(
mcpServer.registerTool(
'test-request-info',
'A simple test tool with request info',
{ name: z.string().describe('Name to greet') },
{
description: 'A simple test tool with request info',
inputSchema: { name: z.string().describe('Name to greet') }
},
async ({ name }, { requestInfo }): Promise<CallToolResult> => {
// Convert Headers object to plain object for JSON serialization
// Headers is a Web API class that doesn't serialize with JSON.stringify
@ -1845,7 +1851,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
});
// Register a tool that closes its own SSE stream via extra callback
mcpServer.tool('close-stream-tool', 'Closes its own stream', {}, async (_args, extra) => {
mcpServer.registerTool('close-stream-tool', { description: 'Closes its own stream' }, async extra => {
// Close the SSE stream for this request
extra.closeSSEStream?.();
streamCloseCalled = true;
@ -1913,7 +1919,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
let receivedCloseSSEStream: (() => void) | undefined;
// Register a tool that captures the extra.closeSSEStream callback
mcpServer.tool('test-callback-tool', 'Test tool', {}, async (_args, extra) => {
mcpServer.registerTool('test-callback-tool', { description: 'Test tool' }, async extra => {
receivedCloseSSEStream = extra.closeSSEStream;
return { content: [{ type: 'text', text: 'Done' }] };
});
@ -1972,7 +1978,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
let receivedCloseStandaloneSSEStream: (() => void) | undefined;
// Register a tool that captures the extra.closeSSEStream callback
mcpServer.tool('test-old-version-tool', 'Test tool', {}, async (_args, extra) => {
mcpServer.registerTool('test-old-version-tool', { description: 'Test tool' }, async extra => {
receivedCloseSSEStream = extra.closeSSEStream;
receivedCloseStandaloneSSEStream = extra.closeStandaloneSSEStream;
return { content: [{ type: 'text', text: 'Done' }] };
@ -2031,7 +2037,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
let receivedCloseSSEStream: (() => void) | undefined;
// Register a tool that captures the extra.closeSSEStream callback
mcpServer.tool('test-no-callback-tool', 'Test tool', {}, async (_args, extra) => {
mcpServer.registerTool('test-no-callback-tool', { description: 'Test tool' }, async extra => {
receivedCloseSSEStream = extra.closeSSEStream;
return { content: [{ type: 'text', text: 'Done' }] };
});
@ -2088,7 +2094,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
let receivedCloseStandaloneSSEStream: (() => void) | undefined;
// Register a tool that captures the extra.closeStandaloneSSEStream callback
mcpServer.tool('test-standalone-callback-tool', 'Test tool', {}, async (_args, extra) => {
mcpServer.registerTool('test-standalone-callback-tool', { description: 'Test tool' }, async extra => {
receivedCloseStandaloneSSEStream = extra.closeStandaloneSSEStream;
return { content: [{ type: 'text', text: 'Done' }] };
});
@ -2143,7 +2149,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
mcpServer = result.mcpServer;
// Register a tool that closes the standalone SSE stream via extra callback
mcpServer.tool('close-standalone-stream-tool', 'Closes standalone stream', {}, async (_args, extra) => {
mcpServer.registerTool('close-standalone-stream-tool', { description: 'Closes standalone stream' }, async extra => {
extra.closeStandaloneSSEStream?.();
return { content: [{ type: 'text', text: 'Stream closed' }] };
});
@ -2224,7 +2230,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
mcpServer = result.mcpServer;
// Register a tool that closes the standalone SSE stream
mcpServer.tool('close-standalone-for-reconnect', 'Closes standalone stream', {}, async (_args, extra) => {
mcpServer.registerTool('close-standalone-for-reconnect', { description: 'Closes standalone stream' }, async extra => {
extra.closeStandaloneSSEStream?.();
return { content: [{ type: 'text', text: 'Stream closed' }] };
});

View file

@ -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<Args extends ZodRawShapeCompat>(
name: string,
paramsSchemaOrAnnotations: Args | ToolAnnotations,
cb: ToolCallback<Args>
): 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<Args extends ZodRawShapeCompat>(
name: string,
description: string,
paramsSchemaOrAnnotations: Args | ToolAnnotations,
cb: ToolCallback<Args>
): RegisteredTool;
/**
* Registers a tool with both parameter schema and annotations.
* @deprecated Use `registerTool` instead.
*/
tool<Args extends ZodRawShapeCompat>(
name: string,
paramsSchema: Args,
annotations: ToolAnnotations,
cb: ToolCallback<Args>
): RegisteredTool;
/**
* Registers a tool with description, parameter schema, and annotations.
* @deprecated Use `registerTool` instead.
*/
tool<Args extends ZodRawShapeCompat>(
name: string,
description: string,
paramsSchema: Args,
annotations: ToolAnnotations,
cb: ToolCallback<Args>
): 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<ZodRawShapeCompat | undefined>;
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<Args extends PromptArgsRawShape>(name: string, argsSchema: Args, cb: PromptCallback<Args>): 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<Args extends PromptArgsRawShape>(
name: string,
description: string,
argsSchema: Args,
cb: PromptCallback<Args>
): 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<PromptArgsRawShape | undefined>;
const registeredPrompt = this._createRegisteredPrompt(name, undefined, description, argsSchema, cb);
this.setPromptRequestHandlers();
this.sendPromptListChanged();
return registeredPrompt;
}
/**
* Registers a prompt with a config object and callback.
*/

View file

@ -129,10 +129,12 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
beforeEach(async () => {
mcpServer = new McpServer({ name: 'test-server', version: '1.0.0' }, { capabilities: { logging: {} } });
mcpServer.tool(
mcpServer.registerTool(
'greet',
'A simple greeting tool',
{ name: z.string().describe('Name to greet') },
{
description: 'A simple greeting tool',
inputSchema: { name: z.string().describe('Name to greet') }
},
async ({ name }): Promise<CallToolResult> => {
return { content: [{ type: 'text', text: `Hello, ${name}!` }] };
}
@ -435,9 +437,13 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
beforeEach(async () => {
mcpServer = new McpServer({ name: 'test-server', version: '1.0.0' }, { capabilities: { logging: {} } });
mcpServer.tool('echo', 'Echo tool', { message: z.string() }, async ({ message }): Promise<CallToolResult> => {
return { content: [{ type: 'text', text: message }] };
});
mcpServer.registerTool(
'echo',
{ description: 'Echo tool', inputSchema: { message: z.string() } },
async ({ message }): Promise<CallToolResult> => {
return { content: [{ type: 'text', text: message }] };
}
);
transport = new WebStandardStreamableHTTPServerTransport({
sessionIdGenerator: undefined
@ -479,9 +485,13 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
beforeEach(async () => {
mcpServer = new McpServer({ name: 'test-server', version: '1.0.0' }, { capabilities: { logging: {} } });
mcpServer.tool('greet', 'Greeting tool', { name: z.string() }, async ({ name }): Promise<CallToolResult> => {
return { content: [{ type: 'text', text: `Hello, ${name}!` }] };
});
mcpServer.registerTool(
'greet',
{ description: 'Greeting tool', inputSchema: { name: z.string() } },
async ({ name }): Promise<CallToolResult> => {
return { content: [{ type: 'text', text: `Hello, ${name}!` }] };
}
);
transport = new WebStandardStreamableHTTPServerTransport({
sessionIdGenerator: () => randomUUID(),
@ -647,9 +657,13 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
mcpServer = new McpServer({ name: 'test-server', version: '1.0.0' }, { capabilities: { logging: {} } });
mcpServer.tool('greet', 'Greeting tool', { name: z.string() }, async ({ name }): Promise<CallToolResult> => {
return { content: [{ type: 'text', text: `Hello, ${name}!` }] };
});
mcpServer.registerTool(
'greet',
{ description: 'Greeting tool', inputSchema: { name: z.string() } },
async ({ name }): Promise<CallToolResult> => {
return { content: [{ type: 'text', text: `Hello, ${name}!` }] };
}
);
transport = new WebStandardStreamableHTTPServerTransport({
sessionIdGenerator: () => randomUUID(),

View file

@ -25,11 +25,13 @@ describe.each(zodTestMatrix)('Issue #1277: $zodVersionLabel', (entry: ZodMatrixE
version: '1.0'
});
mcpServer.prompt(
mcpServer.registerPrompt(
'test',
{
name: z.string().describe('The user name'),
value: z.string().describe('The value to set')
argsSchema: {
name: z.string().describe('The user name'),
value: z.string().describe('The value to set')
}
},
async ({ name, value }) => ({
messages: [

File diff suppressed because it is too large Load diff

View file

@ -30,7 +30,7 @@ async function setupServer(withSessionManagement: boolean, z: ZNamespace) {
);
// Add a simple resource
mcpServer.resource('test-resource', '/test', { description: 'A test resource' }, async () => ({
mcpServer.registerResource('test-resource', '/test', { description: 'A test resource' }, async () => ({
contents: [
{
uri: '/test',
@ -39,7 +39,7 @@ async function setupServer(withSessionManagement: boolean, z: ZNamespace) {
]
}));
mcpServer.prompt('test-prompt', 'A test prompt', async () => ({
mcpServer.registerPrompt('test-prompt', { description: 'A test prompt' }, async () => ({
messages: [
{
role: 'user',
@ -51,11 +51,13 @@ async function setupServer(withSessionManagement: boolean, z: ZNamespace) {
]
}));
mcpServer.tool(
mcpServer.registerTool(
'greet',
'A simple greeting tool',
{
name: z.string().describe('Name to greet').default('World')
description: 'A simple greeting tool',
inputSchema: {
name: z.string().describe('Name to greet').default('World')
}
},
async ({ name }) => {
return {

View file

@ -60,11 +60,13 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
mcpServer = new McpServer({ name: 'test-server', version: '1.0.0' }, { capabilities: { logging: {} } });
// Add a simple notification tool that completes quickly
mcpServer.tool(
mcpServer.registerTool(
'send-notification',
'Sends a single notification',
{
message: z.string().describe('Message to send').default('Test notification')
description: 'Sends a single notification',
inputSchema: {
message: z.string().describe('Message to send').default('Test notification')
}
},
async ({ message }, { sendNotification }) => {
// Send notification immediately
@ -83,12 +85,14 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
);
// Add a long-running tool that sends multiple notifications
mcpServer.tool(
mcpServer.registerTool(
'run-notifications',
'Sends multiple notifications over time',
{
count: z.number().describe('Number of notifications to send').default(10),
interval: z.number().describe('Interval between notifications in ms').default(50)
description: 'Sends multiple notifications over time',
inputSchema: {
count: z.number().describe('Number of notifications to send').default(10),
interval: z.number().describe('Interval between notifications in ms').default(50)
}
},
async ({ count, interval }, { sendNotification }) => {
// Send notifications at specified intervals

View file

@ -44,7 +44,9 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
const server = new McpServer({ name: 'test-server', version: '1.0.0' }, { capabilities: {} });
// Register tool without title
server.tool('test-tool', 'A test tool', { value: z.string() }, async () => ({ content: [{ type: 'text', text: 'result' }] }));
server.registerTool('test-tool', { description: 'A test tool', inputSchema: { value: z.string() } }, async () => ({
content: [{ type: 'text', text: 'result' }]
}));
const client = new Client({ name: 'test-client', version: '1.0.0' });
@ -64,7 +66,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
const server = new McpServer({ name: 'test-server', version: '1.0.0' }, { capabilities: {} });
// Register prompt with title by updating after creation
const prompt = server.prompt('test-prompt', 'A test prompt', async () => ({
const prompt = server.registerPrompt('test-prompt', { description: 'A test prompt' }, async () => ({
messages: [{ role: 'user', content: { type: 'text', text: 'test' } }]
}));
prompt.update({ title: 'Test Prompt Display Name' });