Skip to content

Commit 2e3a341

Browse files
waleedlatif1claude
andcommitted
chore(mcp): adopt native SDK types after @modelcontextprotocol/sdk 1.25.3 bump
Replace hand-written schema/annotation shapes with the SDK's exported Tool, JSONRPCResultResponse, and Tool['annotations'] types so changes upstream flow through automatically. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 22e2cde commit 2e3a341

3 files changed

Lines changed: 12 additions & 30 deletions

File tree

apps/sim/app/api/mcp/serve/[serverId]/route.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import {
1010
isJSONRPCRequest,
1111
type JSONRPCError,
1212
type JSONRPCMessage,
13-
type JSONRPCResponse,
13+
type JSONRPCResultResponse,
1414
type ListToolsResult,
1515
type RequestId,
16+
type Tool,
1617
} from '@modelcontextprotocol/sdk/types.js'
1718
import { db } from '@sim/db'
1819
import { workflow, workflowMcpServer, workflowMcpTool, workspace } from '@sim/db/schema'
@@ -41,11 +42,11 @@ interface ExecuteAuthContext {
4142
apiKey?: string | null
4243
}
4344

44-
function createResponse(id: RequestId, result: unknown): JSONRPCResponse {
45+
function createResponse(id: RequestId, result: unknown): JSONRPCResultResponse {
4546
return {
4647
jsonrpc: '2.0',
4748
id,
48-
result: result as JSONRPCResponse['result'],
49+
result: result as JSONRPCResultResponse['result'],
4950
}
5051
}
5152

@@ -235,11 +236,7 @@ async function handleToolsList(id: RequestId, serverId: string): Promise<NextRes
235236

236237
const result: ListToolsResult = {
237238
tools: tools.map((tool) => {
238-
const schema = tool.parameterSchema as {
239-
type?: string
240-
properties?: Record<string, unknown>
241-
required?: string[]
242-
} | null
239+
const schema = tool.parameterSchema as Partial<Tool['inputSchema']> | null
243240
return {
244241
name: tool.toolName,
245242
description: tool.toolDescription || `Execute workflow: ${tool.toolName}`,

apps/sim/lib/copilot/tools/mcp/definitions.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
1-
export type ToolAnnotations = {
2-
readOnlyHint?: boolean
3-
destructiveHint?: boolean
4-
idempotentHint?: boolean
5-
openWorldHint?: boolean
6-
}
1+
import type { Tool } from '@modelcontextprotocol/sdk/types.js'
2+
3+
export type ToolAnnotations = NonNullable<Tool['annotations']>
74

85
export type DirectToolDef = {
96
name: string
107
description: string
11-
inputSchema: { type: 'object'; properties?: Record<string, unknown>; required?: string[] }
8+
inputSchema: Tool['inputSchema']
129
toolId: string
1310
annotations?: ToolAnnotations
1411
}
1512

1613
export type SubagentToolDef = {
1714
name: string
1815
description: string
19-
inputSchema: { type: 'object'; properties?: Record<string, unknown>; required?: string[] }
16+
inputSchema: Tool['inputSchema']
2017
agentId: string
2118
annotations?: ToolAnnotations
2219
}

apps/sim/lib/mcp/client.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ export class McpClient {
9797
version: '1.0.0',
9898
},
9999
{
100-
capabilities: {
101-
tools: {},
102-
},
100+
capabilities: {},
103101
}
104102
)
105103
}
@@ -261,21 +259,11 @@ export class McpClient {
261259
}
262260
}
263261

264-
/**
265-
* Check if server has capability
266-
*/
267-
hasCapability(capability: string): boolean {
268-
const serverCapabilities = this.client.getServerCapabilities()
269-
return !!serverCapabilities?.[capability]
270-
}
271-
272262
/**
273263
* Check if the server declared `capabilities.tools.listChanged: true` during initialization.
274264
*/
275265
hasListChangedCapability(): boolean {
276-
const caps = this.client.getServerCapabilities()
277-
const toolsCap = caps?.tools as Record<string, unknown> | undefined
278-
return !!toolsCap?.listChanged
266+
return !!this.client.getServerCapabilities()?.tools?.listChanged
279267
}
280268

281269
/**

0 commit comments

Comments
 (0)