@mcp-ts/sdk 2.1.0 → 2.3.0
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/adapters/agui-adapter.d.mts +1 -1
- package/dist/adapters/agui-adapter.d.ts +1 -1
- package/dist/adapters/agui-middleware.d.mts +1 -1
- package/dist/adapters/agui-middleware.d.ts +1 -1
- package/dist/adapters/ai-adapter.d.mts +1 -1
- package/dist/adapters/ai-adapter.d.ts +1 -1
- package/dist/adapters/langchain-adapter.d.mts +1 -1
- package/dist/adapters/langchain-adapter.d.ts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +86 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -5
- package/dist/index.mjs.map +1 -1
- package/dist/server/index.d.mts +13 -1
- package/dist/server/index.d.ts +13 -1
- package/dist/server/index.js +66 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +66 -2
- package/dist/server/index.mjs.map +1 -1
- package/dist/shared/index.d.mts +2 -2
- package/dist/shared/index.d.ts +2 -2
- package/dist/shared/index.js +20 -3
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +20 -3
- package/dist/shared/index.mjs.map +1 -1
- package/dist/{tool-router-BkQnso27.d.mts → tool-router-C8hIA-tg.d.mts} +9 -0
- package/dist/{tool-router-BP8TT9mI.d.ts → tool-router-CdX8e9bk.d.ts} +9 -0
- package/package.json +1 -1
- package/src/server/index.ts +8 -1
- package/src/server/storage/index.ts +77 -2
- package/src/server/storage/types.ts +14 -0
- package/src/shared/tool-router.ts +31 -3
package/dist/shared/index.d.mts
CHANGED
|
@@ -2,8 +2,8 @@ export { D as Disposable, a as DisposableStore, E as Emitter, b as Event, M as M
|
|
|
2
2
|
export { A as AuthenticationError, C as ConfigurationError, a as ConnectionError, I as InvalidStateError, M as McpError, N as NotConnectedError, R as RpcErrorCode, b as RpcErrorCodes, S as SessionNotFoundError, c as SessionValidationError, T as ToolExecutionError, U as UnauthorizedError, s as sanitizeServerLabel } from '../utils-DELRKQPU.mjs';
|
|
3
3
|
import { v as ToolInfo } from '../types-CxFaaZrM.mjs';
|
|
4
4
|
export { C as CallToolParams, a as CallToolRequest, b as CallToolResponse, c as ConnectAuthRequiredResponse, d as ConnectErrorResponse, e as ConnectParams, f as ConnectRequest, g as ConnectResponse, h as ConnectResult, i as ConnectSuccessResponse, D as DisconnectParams, j as DisconnectResult, F as FinishAuthParams, k as FinishAuthResult, G as GetPromptParams, l as GetSessionResult, L as ListPromptsResult, m as ListResourcesResult, n as ListToolsResponse, o as ListToolsRpcResult, M as McpRpcMethod, p as McpRpcParams, q as McpRpcRequest, r as McpRpcResponse, R as ReadResourceParams, S as SessionInfo, s as SessionListResult, t as SessionParams, T as ToolClient, u as ToolClientProvider, w as TransportType, x as isCallToolSuccess, y as isConnectAuthRequired, z as isConnectError, A as isConnectSuccess, B as isListToolsSuccess } from '../types-CxFaaZrM.mjs';
|
|
5
|
-
import { d as ToolRouter } from '../tool-router-
|
|
6
|
-
export { C as CompactTool, E as EmbedFn, I as IndexedTool, S as SchemaCompressor, T as ToolGroupInfo, a as ToolIndex, b as ToolIndexOptions, c as ToolListResult, e as ToolRouterClientInput, f as ToolRouterOptions, g as ToolRouterStrategy, h as ToolSearchOptions, i as ToolServerSummary, j as ToolSummary } from '../tool-router-
|
|
5
|
+
import { d as ToolRouter } from '../tool-router-C8hIA-tg.mjs';
|
|
6
|
+
export { C as CompactTool, E as EmbedFn, I as IndexedTool, S as SchemaCompressor, T as ToolGroupInfo, a as ToolIndex, b as ToolIndexOptions, c as ToolListResult, e as ToolRouterClientInput, f as ToolRouterOptions, g as ToolRouterStrategy, h as ToolSearchOptions, i as ToolServerSummary, j as ToolSummary } from '../tool-router-C8hIA-tg.mjs';
|
|
7
7
|
import { Tool, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
8
8
|
|
|
9
9
|
/**
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ export { D as Disposable, a as DisposableStore, E as Emitter, b as Event, M as M
|
|
|
2
2
|
export { A as AuthenticationError, C as ConfigurationError, a as ConnectionError, I as InvalidStateError, M as McpError, N as NotConnectedError, R as RpcErrorCode, b as RpcErrorCodes, S as SessionNotFoundError, c as SessionValidationError, T as ToolExecutionError, U as UnauthorizedError, s as sanitizeServerLabel } from '../utils-DELRKQPU.js';
|
|
3
3
|
import { v as ToolInfo } from '../types-CxFaaZrM.js';
|
|
4
4
|
export { C as CallToolParams, a as CallToolRequest, b as CallToolResponse, c as ConnectAuthRequiredResponse, d as ConnectErrorResponse, e as ConnectParams, f as ConnectRequest, g as ConnectResponse, h as ConnectResult, i as ConnectSuccessResponse, D as DisconnectParams, j as DisconnectResult, F as FinishAuthParams, k as FinishAuthResult, G as GetPromptParams, l as GetSessionResult, L as ListPromptsResult, m as ListResourcesResult, n as ListToolsResponse, o as ListToolsRpcResult, M as McpRpcMethod, p as McpRpcParams, q as McpRpcRequest, r as McpRpcResponse, R as ReadResourceParams, S as SessionInfo, s as SessionListResult, t as SessionParams, T as ToolClient, u as ToolClientProvider, w as TransportType, x as isCallToolSuccess, y as isConnectAuthRequired, z as isConnectError, A as isConnectSuccess, B as isListToolsSuccess } from '../types-CxFaaZrM.js';
|
|
5
|
-
import { d as ToolRouter } from '../tool-router-
|
|
6
|
-
export { C as CompactTool, E as EmbedFn, I as IndexedTool, S as SchemaCompressor, T as ToolGroupInfo, a as ToolIndex, b as ToolIndexOptions, c as ToolListResult, e as ToolRouterClientInput, f as ToolRouterOptions, g as ToolRouterStrategy, h as ToolSearchOptions, i as ToolServerSummary, j as ToolSummary } from '../tool-router-
|
|
5
|
+
import { d as ToolRouter } from '../tool-router-CdX8e9bk.js';
|
|
6
|
+
export { C as CompactTool, E as EmbedFn, I as IndexedTool, S as SchemaCompressor, T as ToolGroupInfo, a as ToolIndex, b as ToolIndexOptions, c as ToolListResult, e as ToolRouterClientInput, f as ToolRouterOptions, g as ToolRouterStrategy, h as ToolSearchOptions, i as ToolServerSummary, j as ToolSummary } from '../tool-router-CdX8e9bk.js';
|
|
7
7
|
import { Tool, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
8
8
|
|
|
9
9
|
/**
|
package/dist/shared/index.js
CHANGED
|
@@ -1046,6 +1046,7 @@ var ToolRouter = class {
|
|
|
1046
1046
|
__publicField(this, "index");
|
|
1047
1047
|
__publicField(this, "allTools", []);
|
|
1048
1048
|
__publicField(this, "pinnedTools", []);
|
|
1049
|
+
__publicField(this, "deferredTools", []);
|
|
1049
1050
|
__publicField(this, "discoverableTools", []);
|
|
1050
1051
|
__publicField(this, "groupsMap", /* @__PURE__ */ new Map());
|
|
1051
1052
|
__publicField(this, "strategy");
|
|
@@ -1054,6 +1055,7 @@ var ToolRouter = class {
|
|
|
1054
1055
|
__publicField(this, "activeGroups");
|
|
1055
1056
|
__publicField(this, "customGroups");
|
|
1056
1057
|
__publicField(this, "pinnedToolNames");
|
|
1058
|
+
__publicField(this, "deferredToolNames");
|
|
1057
1059
|
__publicField(this, "excludeToolMatchers");
|
|
1058
1060
|
__publicField(this, "initialized", false);
|
|
1059
1061
|
this.strategy = options.strategy ?? "all";
|
|
@@ -1062,6 +1064,7 @@ var ToolRouter = class {
|
|
|
1062
1064
|
this.activeGroups = new Set(options.activeGroups ?? []);
|
|
1063
1065
|
this.customGroups = options.groups;
|
|
1064
1066
|
this.pinnedToolNames = new Set(options.pinnedTools ?? []);
|
|
1067
|
+
this.deferredToolNames = new Set(options.deferredTools ?? []);
|
|
1065
1068
|
this.excludeToolMatchers = (options.excludeTools ?? []).map(
|
|
1066
1069
|
(pattern) => globToRegExp(pattern)
|
|
1067
1070
|
);
|
|
@@ -1090,8 +1093,9 @@ var ToolRouter = class {
|
|
|
1090
1093
|
return this.getGroupFilteredTools();
|
|
1091
1094
|
case "all":
|
|
1092
1095
|
default:
|
|
1096
|
+
const directlyVisibleTools = this.getDirectlyVisibleTools();
|
|
1093
1097
|
if (this.compactSchemas) {
|
|
1094
|
-
return
|
|
1098
|
+
return directlyVisibleTools.map((t) => {
|
|
1095
1099
|
const compact = SchemaCompressor.toCompact(t);
|
|
1096
1100
|
return {
|
|
1097
1101
|
name: compact.name,
|
|
@@ -1100,7 +1104,7 @@ var ToolRouter = class {
|
|
|
1100
1104
|
};
|
|
1101
1105
|
});
|
|
1102
1106
|
}
|
|
1103
|
-
return [...
|
|
1107
|
+
return [...directlyVisibleTools];
|
|
1104
1108
|
}
|
|
1105
1109
|
}
|
|
1106
1110
|
/**
|
|
@@ -1215,6 +1219,9 @@ var ToolRouter = class {
|
|
|
1215
1219
|
const fetchedTools = await this.fetchAllTools();
|
|
1216
1220
|
this.allTools = fetchedTools.filter((tool) => !this.matchesExcludedTool(tool.name));
|
|
1217
1221
|
this.pinnedTools = this.allTools.filter((tool) => this.matchesPinnedTool(tool.name));
|
|
1222
|
+
this.deferredTools = this.allTools.filter(
|
|
1223
|
+
(tool) => !this.matchesPinnedTool(tool.name) && this.matchesDeferredTool(tool)
|
|
1224
|
+
);
|
|
1218
1225
|
this.discoverableTools = this.allTools.filter((tool) => !this.matchesPinnedTool(tool.name));
|
|
1219
1226
|
await this.index.buildIndex(this.discoverableTools);
|
|
1220
1227
|
this.buildGroups();
|
|
@@ -1292,7 +1299,7 @@ var ToolRouter = class {
|
|
|
1292
1299
|
}
|
|
1293
1300
|
}
|
|
1294
1301
|
}
|
|
1295
|
-
const filtered = this.
|
|
1302
|
+
const filtered = this.getDirectlyVisibleTools().filter((t) => activeToolNames.has(t.name));
|
|
1296
1303
|
if (this.compactSchemas) {
|
|
1297
1304
|
return filtered.slice(0, this.maxTools).map((t) => {
|
|
1298
1305
|
const compact = SchemaCompressor.toCompact(t);
|
|
@@ -1318,9 +1325,19 @@ var ToolRouter = class {
|
|
|
1318
1325
|
matchesPinnedTool(toolName) {
|
|
1319
1326
|
return this.pinnedToolNames.has(toolName);
|
|
1320
1327
|
}
|
|
1328
|
+
matchesDeferredTool(tool) {
|
|
1329
|
+
if (this.deferredToolNames.has(tool.name)) {
|
|
1330
|
+
return true;
|
|
1331
|
+
}
|
|
1332
|
+
const meta = tool._meta;
|
|
1333
|
+
return meta?.toolRouter?.deferred === true;
|
|
1334
|
+
}
|
|
1321
1335
|
matchesExcludedTool(toolName) {
|
|
1322
1336
|
return this.excludeToolMatchers.some((matcher) => matcher.test(toolName));
|
|
1323
1337
|
}
|
|
1338
|
+
getDirectlyVisibleTools() {
|
|
1339
|
+
return this.allTools.filter((tool) => !this.matchesDeferredTool(tool) || this.matchesPinnedTool(tool.name));
|
|
1340
|
+
}
|
|
1324
1341
|
};
|
|
1325
1342
|
function globToRegExp(pattern) {
|
|
1326
1343
|
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|