Skip to content

Commit dcf708d

Browse files
v2 - clean deprecated methods and exports (#1419)
Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com>
1 parent 11e3266 commit dcf708d

File tree

12 files changed

+258
-565
lines changed

12 files changed

+258
-565
lines changed

.changeset/funky-baths-attack.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@modelcontextprotocol/node': patch
3+
'@modelcontextprotocol/test-integration': patch
4+
'@modelcontextprotocol/server': patch
5+
'@modelcontextprotocol/core': patch
6+
---
7+
8+
remove deprecated .tool, .prompt, .resource method signatures

.changeset/shy-times-learn.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@modelcontextprotocol/node': patch
3+
'@modelcontextprotocol/test-integration': patch
4+
'@modelcontextprotocol/server': patch
5+
'@modelcontextprotocol/core': patch
6+
---
7+
8+
deprecated .tool, .prompt, .resource method removal

examples/server/src/ssePollingExample.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ const server = new McpServer(
3535
);
3636

3737
// Register a long-running tool that demonstrates server-initiated disconnect
38-
server.tool(
38+
server.registerTool(
3939
'long-task',
40-
'A long-running task that sends progress updates. Server will disconnect mid-task to demonstrate polling.',
41-
{},
42-
async (_args, extra): Promise<CallToolResult> => {
40+
{
41+
description: 'A long-running task that sends progress updates. Server will disconnect mid-task to demonstrate polling.'
42+
},
43+
async (extra): Promise<CallToolResult> => {
4344
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
4445

4546
console.log(`[${extra.sessionId}] Starting long-task...`);

packages/core/src/types/types.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,6 @@ export const JSONRPCResultResponseSchema = z
215215
export const isJSONRPCResultResponse = (value: unknown): value is JSONRPCResultResponse =>
216216
JSONRPCResultResponseSchema.safeParse(value).success;
217217

218-
/**
219-
* @deprecated Use {@link isJSONRPCResultResponse} instead.
220-
*
221-
* 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})
222-
*/
223-
export const isJSONRPCResponse = isJSONRPCResultResponse;
224-
225218
/**
226219
* Error codes defined by the JSON-RPC specification.
227220
*/
@@ -265,11 +258,6 @@ export const JSONRPCErrorResponseSchema = z
265258
})
266259
.strict();
267260

268-
/**
269-
* @deprecated Use {@link JSONRPCErrorResponseSchema} instead.
270-
*/
271-
export const JSONRPCErrorSchema = JSONRPCErrorResponseSchema;
272-
273261
/**
274262
* Checks if a value is a valid JSONRPCErrorResponse.
275263
* @param value - The value to check.
@@ -279,11 +267,6 @@ export const JSONRPCErrorSchema = JSONRPCErrorResponseSchema;
279267
export const isJSONRPCErrorResponse = (value: unknown): value is JSONRPCErrorResponse =>
280268
JSONRPCErrorResponseSchema.safeParse(value).success;
281269

282-
/**
283-
* @deprecated Use {@link isJSONRPCErrorResponse} instead.
284-
*/
285-
export const isJSONRPCError = isJSONRPCErrorResponse;
286-
287270
export const JSONRPCMessageSchema = z.union([
288271
JSONRPCRequestSchema,
289272
JSONRPCNotificationSchema,
@@ -2115,11 +2098,6 @@ export const ResourceTemplateReferenceSchema = z.object({
21152098
uri: z.string()
21162099
});
21172100

2118-
/**
2119-
* @deprecated Use ResourceTemplateReferenceSchema instead
2120-
*/
2121-
export const ResourceReferenceSchema = ResourceTemplateReferenceSchema;
2122-
21232101
/**
21242102
* Identifies a prompt.
21252103
*/
@@ -2432,12 +2410,6 @@ export type JSONRPCRequest = Infer<typeof JSONRPCRequestSchema>;
24322410
export type JSONRPCNotification = Infer<typeof JSONRPCNotificationSchema>;
24332411
export type JSONRPCResponse = Infer<typeof JSONRPCResponseSchema>;
24342412
export type JSONRPCErrorResponse = Infer<typeof JSONRPCErrorResponseSchema>;
2435-
/**
2436-
* @deprecated Use {@link JSONRPCErrorResponse} instead.
2437-
*
2438-
* 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}.
2439-
*/
2440-
export type JSONRPCError = JSONRPCErrorResponse;
24412413
export type JSONRPCResultResponse = Infer<typeof JSONRPCResultResponseSchema>;
24422414

24432415
export type JSONRPCMessage = Infer<typeof JSONRPCMessageSchema>;
@@ -2609,10 +2581,6 @@ export type ElicitResult = Infer<typeof ElicitResultSchema>;
26092581

26102582
/* Autocomplete */
26112583
export type ResourceTemplateReference = Infer<typeof ResourceTemplateReferenceSchema>;
2612-
/**
2613-
* @deprecated Use ResourceTemplateReference instead
2614-
*/
2615-
export type ResourceReference = ResourceTemplateReference;
26162584
export type PromptReference = Infer<typeof PromptReferenceSchema>;
26172585
export type CompleteRequestParams = Infer<typeof CompleteRequestParamsSchema>;
26182586
export type CompleteRequest = Infer<typeof CompleteRequestSchema>;

packages/middleware/node/test/streamableHttp.test.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,12 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
161161
config ??= { sessionIdGenerator: () => randomUUID() };
162162
const mcpServer = new McpServer({ name: 'test-server', version: '1.0.0' }, { capabilities: { logging: {} } });
163163

164-
mcpServer.tool(
164+
mcpServer.registerTool(
165165
'greet',
166-
'A simple greeting tool',
167-
{ name: z.string().describe('Name to greet') },
166+
{
167+
description: 'A simple greeting tool',
168+
inputSchema: { name: z.string().describe('Name to greet') }
169+
},
168170
async ({ name }): Promise<CallToolResult> => {
169171
return { content: [{ type: 'text', text: `Hello, ${name}!` }] };
170172
}
@@ -206,10 +208,12 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
206208
}> {
207209
const mcpServer = new McpServer({ name: 'test-server', version: '1.0.0' }, { capabilities: { logging: {} } });
208210

209-
mcpServer.tool(
211+
mcpServer.registerTool(
210212
'profile',
211-
'A user profile data tool',
212-
{ active: z.boolean().describe('Profile status') },
213+
{
214+
description: 'A user profile data tool',
215+
inputSchema: { active: z.boolean().describe('Profile status') }
216+
},
213217
async ({ active }, { authInfo }): Promise<CallToolResult> => {
214218
return { content: [{ type: 'text', text: `${active ? 'Active' : 'Inactive'} profile from token: ${authInfo?.token}!` }] };
215219
}
@@ -394,10 +398,12 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
394398
it('should pass request info to tool callback', async () => {
395399
sessionId = await initializeServer();
396400

397-
mcpServer.tool(
401+
mcpServer.registerTool(
398402
'test-request-info',
399-
'A simple test tool with request info',
400-
{ name: z.string().describe('Name to greet') },
403+
{
404+
description: 'A simple test tool with request info',
405+
inputSchema: { name: z.string().describe('Name to greet') }
406+
},
401407
async ({ name }, { requestInfo }): Promise<CallToolResult> => {
402408
// Convert Headers object to plain object for JSON serialization
403409
// Headers is a Web API class that doesn't serialize with JSON.stringify
@@ -1845,7 +1851,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
18451851
});
18461852

18471853
// Register a tool that closes its own SSE stream via extra callback
1848-
mcpServer.tool('close-stream-tool', 'Closes its own stream', {}, async (_args, extra) => {
1854+
mcpServer.registerTool('close-stream-tool', { description: 'Closes its own stream' }, async extra => {
18491855
// Close the SSE stream for this request
18501856
extra.closeSSEStream?.();
18511857
streamCloseCalled = true;
@@ -1913,7 +1919,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
19131919
let receivedCloseSSEStream: (() => void) | undefined;
19141920

19151921
// Register a tool that captures the extra.closeSSEStream callback
1916-
mcpServer.tool('test-callback-tool', 'Test tool', {}, async (_args, extra) => {
1922+
mcpServer.registerTool('test-callback-tool', { description: 'Test tool' }, async extra => {
19171923
receivedCloseSSEStream = extra.closeSSEStream;
19181924
return { content: [{ type: 'text', text: 'Done' }] };
19191925
});
@@ -1972,7 +1978,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
19721978
let receivedCloseStandaloneSSEStream: (() => void) | undefined;
19731979

19741980
// Register a tool that captures the extra.closeSSEStream callback
1975-
mcpServer.tool('test-old-version-tool', 'Test tool', {}, async (_args, extra) => {
1981+
mcpServer.registerTool('test-old-version-tool', { description: 'Test tool' }, async extra => {
19761982
receivedCloseSSEStream = extra.closeSSEStream;
19771983
receivedCloseStandaloneSSEStream = extra.closeStandaloneSSEStream;
19781984
return { content: [{ type: 'text', text: 'Done' }] };
@@ -2031,7 +2037,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
20312037
let receivedCloseSSEStream: (() => void) | undefined;
20322038

20332039
// Register a tool that captures the extra.closeSSEStream callback
2034-
mcpServer.tool('test-no-callback-tool', 'Test tool', {}, async (_args, extra) => {
2040+
mcpServer.registerTool('test-no-callback-tool', { description: 'Test tool' }, async extra => {
20352041
receivedCloseSSEStream = extra.closeSSEStream;
20362042
return { content: [{ type: 'text', text: 'Done' }] };
20372043
});
@@ -2088,7 +2094,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
20882094
let receivedCloseStandaloneSSEStream: (() => void) | undefined;
20892095

20902096
// Register a tool that captures the extra.closeStandaloneSSEStream callback
2091-
mcpServer.tool('test-standalone-callback-tool', 'Test tool', {}, async (_args, extra) => {
2097+
mcpServer.registerTool('test-standalone-callback-tool', { description: 'Test tool' }, async extra => {
20922098
receivedCloseStandaloneSSEStream = extra.closeStandaloneSSEStream;
20932099
return { content: [{ type: 'text', text: 'Done' }] };
20942100
});
@@ -2143,7 +2149,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
21432149
mcpServer = result.mcpServer;
21442150

21452151
// Register a tool that closes the standalone SSE stream via extra callback
2146-
mcpServer.tool('close-standalone-stream-tool', 'Closes standalone stream', {}, async (_args, extra) => {
2152+
mcpServer.registerTool('close-standalone-stream-tool', { description: 'Closes standalone stream' }, async extra => {
21472153
extra.closeStandaloneSSEStream?.();
21482154
return { content: [{ type: 'text', text: 'Stream closed' }] };
21492155
});
@@ -2224,7 +2230,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
22242230
mcpServer = result.mcpServer;
22252231

22262232
// Register a tool that closes the standalone SSE stream
2227-
mcpServer.tool('close-standalone-for-reconnect', 'Closes standalone stream', {}, async (_args, extra) => {
2233+
mcpServer.registerTool('close-standalone-for-reconnect', { description: 'Closes standalone stream' }, async extra => {
22282234
extra.closeStandaloneSSEStream?.();
22292235
return { content: [{ type: 'text', text: 'Stream closed' }] };
22302236
});

0 commit comments

Comments
 (0)