@smithery/sdk 1.5.2 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/integrations/llm/anthropic.js +2 -2
- package/dist/client/integrations/llm/openai.js +1 -1
- package/dist/client/integrations/wrap-error.js +1 -1
- package/dist/server/session.js +2 -2
- package/dist/server/stateful.js +34 -4
- package/dist/shared/config.js +1 -1
- package/package.json +3 -2
|
@@ -8,7 +8,7 @@ export class AnthropicChatAdapter {
|
|
|
8
8
|
}
|
|
9
9
|
async listTools() {
|
|
10
10
|
const toolResult = await this.client.listTools();
|
|
11
|
-
return toolResult.tools.map(
|
|
11
|
+
return toolResult.tools.map(tool => ({
|
|
12
12
|
name: tool.name,
|
|
13
13
|
description: tool.description,
|
|
14
14
|
input_schema: tool.inputSchema,
|
|
@@ -21,7 +21,7 @@ export class AnthropicChatAdapter {
|
|
|
21
21
|
return [];
|
|
22
22
|
}
|
|
23
23
|
// Find tool calls in the message content
|
|
24
|
-
const toolCalls = content.filter(
|
|
24
|
+
const toolCalls = content.filter(part => part.type === "tool_use");
|
|
25
25
|
if (toolCalls.length === 0) {
|
|
26
26
|
return [];
|
|
27
27
|
}
|
|
@@ -4,7 +4,7 @@ import { patch } from "../../shared/patch.js";
|
|
|
4
4
|
* Wraps each tool call so any errors get sent back to the LLM instead of throwing
|
|
5
5
|
*/
|
|
6
6
|
export function wrapError(client) {
|
|
7
|
-
patch(client, "callTool",
|
|
7
|
+
patch(client, "callTool", callTool => async (params, resultSchema = CallToolResultSchema, options) => {
|
|
8
8
|
try {
|
|
9
9
|
return await callTool(params, resultSchema, options);
|
|
10
10
|
}
|
package/dist/server/session.js
CHANGED
|
@@ -9,7 +9,7 @@ export const createLRUStore = (max = 1000) => {
|
|
|
9
9
|
// ECMA‑262 §23.1.3.13 - the order of keys in a Map object is the order of insertion; operations that remove a key drop it from that order, and set appends when the key is new or has just been removed.
|
|
10
10
|
const cache = new Map();
|
|
11
11
|
return {
|
|
12
|
-
get:
|
|
12
|
+
get: id => {
|
|
13
13
|
const t = cache.get(id);
|
|
14
14
|
if (!t)
|
|
15
15
|
return undefined;
|
|
@@ -31,6 +31,6 @@ export const createLRUStore = (max = 1000) => {
|
|
|
31
31
|
}
|
|
32
32
|
cache.set(id, transport);
|
|
33
33
|
},
|
|
34
|
-
delete:
|
|
34
|
+
delete: id => cache.delete(id),
|
|
35
35
|
};
|
|
36
36
|
};
|
package/dist/server/stateful.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
1
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
3
2
|
import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";
|
|
4
3
|
import express from "express";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { parseAndValidateConfig } from "../shared/config.js";
|
|
6
6
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
7
7
|
import { createLRUStore } from "./session.js";
|
|
@@ -31,7 +31,7 @@ export function createStatefulServer(createMcpServer, options) {
|
|
|
31
31
|
const newSessionId = randomUUID();
|
|
32
32
|
transport = new StreamableHTTPServerTransport({
|
|
33
33
|
sessionIdGenerator: () => newSessionId,
|
|
34
|
-
onsessioninitialized:
|
|
34
|
+
onsessioninitialized: sessionId => {
|
|
35
35
|
// Store the transport by session ID
|
|
36
36
|
sessionStore.set(sessionId, transport);
|
|
37
37
|
},
|
|
@@ -77,7 +77,7 @@ export function createStatefulServer(createMcpServer, options) {
|
|
|
77
77
|
jsonrpc: "2.0",
|
|
78
78
|
error: {
|
|
79
79
|
code: -32000,
|
|
80
|
-
message: "
|
|
80
|
+
message: "Session not found or expired",
|
|
81
81
|
},
|
|
82
82
|
id: null,
|
|
83
83
|
});
|
|
@@ -122,6 +122,36 @@ export function createStatefulServer(createMcpServer, options) {
|
|
|
122
122
|
// Handle GET requests for server-to-client notifications via SSE
|
|
123
123
|
app.get("/mcp", handleSessionRequest);
|
|
124
124
|
// Handle DELETE requests for session termination
|
|
125
|
-
|
|
125
|
+
// https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#session-management
|
|
126
|
+
app.delete("/mcp", async (req, res) => {
|
|
127
|
+
const sessionId = req.headers["mcp-session-id"];
|
|
128
|
+
if (!sessionId) {
|
|
129
|
+
res.status(400).json({
|
|
130
|
+
jsonrpc: "2.0",
|
|
131
|
+
error: {
|
|
132
|
+
code: -32600,
|
|
133
|
+
message: "Missing mcp-session-id header",
|
|
134
|
+
},
|
|
135
|
+
id: null,
|
|
136
|
+
});
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const transport = sessionStore.get(sessionId);
|
|
140
|
+
if (!transport) {
|
|
141
|
+
res.status(404).json({
|
|
142
|
+
jsonrpc: "2.0",
|
|
143
|
+
error: {
|
|
144
|
+
code: -32000,
|
|
145
|
+
message: "Session not found or expired",
|
|
146
|
+
},
|
|
147
|
+
id: null,
|
|
148
|
+
});
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
// Close the transport
|
|
152
|
+
transport.close?.();
|
|
153
|
+
// Acknowledge session termination with 204 No Content
|
|
154
|
+
res.status(204).end();
|
|
155
|
+
});
|
|
126
156
|
return { app };
|
|
127
157
|
}
|
package/dist/shared/config.js
CHANGED
|
@@ -82,7 +82,7 @@ export function parseAndValidateConfig(req, schema) {
|
|
|
82
82
|
const result = schema.safeParse(config);
|
|
83
83
|
if (!result.success) {
|
|
84
84
|
const jsonSchema = zodToJsonSchema(schema);
|
|
85
|
-
const errors = result.error.issues.map(
|
|
85
|
+
const errors = result.error.issues.map(issue => {
|
|
86
86
|
// Safely traverse the config object to get the received value
|
|
87
87
|
let received = config;
|
|
88
88
|
for (const key of issue.path) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithery/sdk",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "SDK to develop with Smithery",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@anthropic-ai/sdk": "^0.32.1",
|
|
24
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
24
|
+
"@modelcontextprotocol/sdk": "^1.15.0",
|
|
25
25
|
"ai": "^4.3.15",
|
|
26
26
|
"express": "^5.1.0",
|
|
27
27
|
"json-schema": "^0.4.0",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"zod-to-json-schema": "^3.24.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
+
"@biomejs/biome": "^2.0.6",
|
|
36
37
|
"@types/express": "^5.0.1",
|
|
37
38
|
"@types/json-schema": "^7.0.15",
|
|
38
39
|
"@types/lodash": "^4.17.17",
|