Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/funky-baths-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@modelcontextprotocol/node': patch
'@modelcontextprotocol/test-integration': patch
'@modelcontextprotocol/server': patch
'@modelcontextprotocol/core': patch
---

remove deprecated .tool, .prompt, .resource method signatures
8 changes: 8 additions & 0 deletions .changeset/shy-times-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@modelcontextprotocol/node': patch
'@modelcontextprotocol/test-integration': patch
'@modelcontextprotocol/server': patch
'@modelcontextprotocol/core': patch
---

deprecated .tool, .prompt, .resource method removal
9 changes: 5 additions & 4 deletions examples/server/src/ssePollingExample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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...`);
Expand Down
32 changes: 0 additions & 32 deletions packages/core/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
Expand All @@ -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,
Expand Down Expand Up @@ -2115,11 +2098,6 @@ export const ResourceTemplateReferenceSchema = z.object({
uri: z.string()
});

/**
* @deprecated Use ResourceTemplateReferenceSchema instead
*/
export const ResourceReferenceSchema = ResourceTemplateReferenceSchema;

/**
* Identifies a prompt.
*/
Expand Down Expand Up @@ -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>;
Expand Down Expand Up @@ -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>;
Expand Down
38 changes: 22 additions & 16 deletions packages/middleware/node/test/streamableHttp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}!` }] };
}
Expand Down Expand Up @@ -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}!` }] };
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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' }] };
});
Expand Down Expand Up @@ -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' }] };
Expand Down Expand Up @@ -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' }] };
});
Expand Down Expand Up @@ -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' }] };
});
Expand Down Expand Up @@ -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' }] };
});
Expand Down Expand Up @@ -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' }] };
});
Expand Down
Loading
Loading