@mcp-ts/sdk 2.0.0 → 2.2.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 +2 -2
- package/dist/adapters/agui-adapter.d.ts +2 -2
- package/dist/adapters/agui-adapter.js +1 -0
- package/dist/adapters/agui-adapter.js.map +1 -1
- package/dist/adapters/agui-adapter.mjs +1 -0
- package/dist/adapters/agui-adapter.mjs.map +1 -1
- package/dist/adapters/agui-middleware.d.mts +2 -2
- package/dist/adapters/agui-middleware.d.ts +2 -2
- package/dist/adapters/ai-adapter.d.mts +2 -2
- package/dist/adapters/ai-adapter.d.ts +2 -2
- package/dist/adapters/ai-adapter.js +1 -0
- package/dist/adapters/ai-adapter.js.map +1 -1
- package/dist/adapters/ai-adapter.mjs +1 -0
- package/dist/adapters/ai-adapter.mjs.map +1 -1
- package/dist/adapters/langchain-adapter.d.mts +2 -2
- package/dist/adapters/langchain-adapter.d.ts +2 -2
- package/dist/adapters/langchain-adapter.js +1 -0
- package/dist/adapters/langchain-adapter.js.map +1 -1
- package/dist/adapters/langchain-adapter.mjs +1 -0
- package/dist/adapters/langchain-adapter.mjs.map +1 -1
- package/dist/client/index.d.mts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/client/react.d.mts +4 -4
- package/dist/client/react.d.ts +4 -4
- package/dist/client/react.js.map +1 -1
- package/dist/client/react.mjs.map +1 -1
- package/dist/client/vue.d.mts +4 -4
- package/dist/client/vue.d.ts +4 -4
- package/dist/{index-eaH14_5u.d.mts → index-Cfjsme-a.d.mts} +1 -1
- package/dist/{index-C9gvpxy5.d.ts → index-CmjMd2ac.d.ts} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +47 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -7
- package/dist/index.mjs.map +1 -1
- package/dist/server/index.d.mts +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/shared/index.d.mts +6 -6
- package/dist/shared/index.d.ts +6 -6
- package/dist/shared/index.js +47 -7
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +47 -7
- package/dist/shared/index.mjs.map +1 -1
- package/dist/{tool-router-Dnd6IOKC.d.mts → tool-router-C8hIA-tg.d.mts} +26 -1
- package/dist/{tool-router-Ddtybmr0.d.ts → tool-router-CdX8e9bk.d.ts} +26 -1
- package/dist/{types-BCAG20P6.d.mts → types-CxFaaZrM.d.mts} +2 -1
- package/dist/{types-BCAG20P6.d.ts → types-CxFaaZrM.d.ts} +2 -1
- package/package.json +1 -1
- package/src/shared/meta-tools.ts +5 -4
- package/src/shared/tool-index.ts +1 -0
- package/src/shared/tool-router.ts +69 -6
- package/src/shared/types.ts +2 -1
package/dist/shared/index.mjs
CHANGED
|
@@ -762,7 +762,7 @@ function createRegexSearchToolDefinition() {
|
|
|
762
762
|
function createGetSchemaToolDefinition() {
|
|
763
763
|
return {
|
|
764
764
|
name: "mcp_get_tool_schema",
|
|
765
|
-
description: "Get the full input schema (parameters) for a specific tool. Call this after mcp_search_tools to get the parameter details needed to call a tool correctly. Do NOT call the discovered tool directly; after reading the schema, call mcp_execute_tool.",
|
|
765
|
+
description: "Get the full input schema (parameters) and output schema (result shape) for a specific tool. Call this after mcp_search_tools to get the parameter details needed to call a tool correctly and understand what it returns. Do NOT call the discovered tool directly; after reading the schema, call mcp_execute_tool.",
|
|
766
766
|
inputSchema: {
|
|
767
767
|
type: "object",
|
|
768
768
|
properties: {
|
|
@@ -947,6 +947,7 @@ async function executeMetaTool(toolName, args, router, callToolFn) {
|
|
|
947
947
|
name: tool.name,
|
|
948
948
|
description: tool.description,
|
|
949
949
|
inputSchema: tool.inputSchema,
|
|
950
|
+
outputSchema: tool.outputSchema,
|
|
950
951
|
executionInstructions: {
|
|
951
952
|
nextTool: "mcp_execute_tool",
|
|
952
953
|
toolName: tool.name,
|
|
@@ -1042,18 +1043,29 @@ var ToolRouter = class {
|
|
|
1042
1043
|
this.options = options;
|
|
1043
1044
|
__publicField(this, "index");
|
|
1044
1045
|
__publicField(this, "allTools", []);
|
|
1046
|
+
__publicField(this, "pinnedTools", []);
|
|
1047
|
+
__publicField(this, "deferredTools", []);
|
|
1048
|
+
__publicField(this, "discoverableTools", []);
|
|
1045
1049
|
__publicField(this, "groupsMap", /* @__PURE__ */ new Map());
|
|
1046
1050
|
__publicField(this, "strategy");
|
|
1047
1051
|
__publicField(this, "maxTools");
|
|
1048
1052
|
__publicField(this, "compactSchemas");
|
|
1049
1053
|
__publicField(this, "activeGroups");
|
|
1050
1054
|
__publicField(this, "customGroups");
|
|
1055
|
+
__publicField(this, "pinnedToolNames");
|
|
1056
|
+
__publicField(this, "deferredToolNames");
|
|
1057
|
+
__publicField(this, "excludeToolMatchers");
|
|
1051
1058
|
__publicField(this, "initialized", false);
|
|
1052
1059
|
this.strategy = options.strategy ?? "all";
|
|
1053
1060
|
this.maxTools = options.maxTools ?? 40;
|
|
1054
1061
|
this.compactSchemas = options.compactSchemas ?? false;
|
|
1055
1062
|
this.activeGroups = new Set(options.activeGroups ?? []);
|
|
1056
1063
|
this.customGroups = options.groups;
|
|
1064
|
+
this.pinnedToolNames = new Set(options.pinnedTools ?? []);
|
|
1065
|
+
this.deferredToolNames = new Set(options.deferredTools ?? []);
|
|
1066
|
+
this.excludeToolMatchers = (options.excludeTools ?? []).map(
|
|
1067
|
+
(pattern) => globToRegExp(pattern)
|
|
1068
|
+
);
|
|
1057
1069
|
this.index = new ToolIndex({
|
|
1058
1070
|
embedFn: options.embedFn,
|
|
1059
1071
|
keywordWeight: options.keywordWeight
|
|
@@ -1074,13 +1086,14 @@ var ToolRouter = class {
|
|
|
1074
1086
|
await this.ensureInitialized();
|
|
1075
1087
|
switch (this.strategy) {
|
|
1076
1088
|
case "search":
|
|
1077
|
-
return this.getMetaToolDefinitions();
|
|
1089
|
+
return [...this.getMetaToolDefinitions(), ...this.pinnedTools];
|
|
1078
1090
|
case "groups":
|
|
1079
1091
|
return this.getGroupFilteredTools();
|
|
1080
1092
|
case "all":
|
|
1081
1093
|
default:
|
|
1094
|
+
const directlyVisibleTools = this.getDirectlyVisibleTools();
|
|
1082
1095
|
if (this.compactSchemas) {
|
|
1083
|
-
return
|
|
1096
|
+
return directlyVisibleTools.map((t) => {
|
|
1084
1097
|
const compact = SchemaCompressor.toCompact(t);
|
|
1085
1098
|
return {
|
|
1086
1099
|
name: compact.name,
|
|
@@ -1089,7 +1102,7 @@ var ToolRouter = class {
|
|
|
1089
1102
|
};
|
|
1090
1103
|
});
|
|
1091
1104
|
}
|
|
1092
|
-
return [...
|
|
1105
|
+
return [...directlyVisibleTools];
|
|
1093
1106
|
}
|
|
1094
1107
|
}
|
|
1095
1108
|
/**
|
|
@@ -1201,8 +1214,14 @@ var ToolRouter = class {
|
|
|
1201
1214
|
/** Lazy initialization — fetches tools from all connected clients. */
|
|
1202
1215
|
async ensureInitialized() {
|
|
1203
1216
|
if (this.initialized) return;
|
|
1204
|
-
|
|
1205
|
-
|
|
1217
|
+
const fetchedTools = await this.fetchAllTools();
|
|
1218
|
+
this.allTools = fetchedTools.filter((tool) => !this.matchesExcludedTool(tool.name));
|
|
1219
|
+
this.pinnedTools = this.allTools.filter((tool) => this.matchesPinnedTool(tool.name));
|
|
1220
|
+
this.deferredTools = this.allTools.filter(
|
|
1221
|
+
(tool) => !this.matchesPinnedTool(tool.name) && this.matchesDeferredTool(tool)
|
|
1222
|
+
);
|
|
1223
|
+
this.discoverableTools = this.allTools.filter((tool) => !this.matchesPinnedTool(tool.name));
|
|
1224
|
+
await this.index.buildIndex(this.discoverableTools);
|
|
1206
1225
|
this.buildGroups();
|
|
1207
1226
|
this.initialized = true;
|
|
1208
1227
|
}
|
|
@@ -1278,7 +1297,7 @@ var ToolRouter = class {
|
|
|
1278
1297
|
}
|
|
1279
1298
|
}
|
|
1280
1299
|
}
|
|
1281
|
-
const filtered = this.
|
|
1300
|
+
const filtered = this.getDirectlyVisibleTools().filter((t) => activeToolNames.has(t.name));
|
|
1282
1301
|
if (this.compactSchemas) {
|
|
1283
1302
|
return filtered.slice(0, this.maxTools).map((t) => {
|
|
1284
1303
|
const compact = SchemaCompressor.toCompact(t);
|
|
@@ -1301,7 +1320,28 @@ var ToolRouter = class {
|
|
|
1301
1320
|
createExecuteToolDefinition()
|
|
1302
1321
|
];
|
|
1303
1322
|
}
|
|
1323
|
+
matchesPinnedTool(toolName) {
|
|
1324
|
+
return this.pinnedToolNames.has(toolName);
|
|
1325
|
+
}
|
|
1326
|
+
matchesDeferredTool(tool) {
|
|
1327
|
+
if (this.deferredToolNames.has(tool.name)) {
|
|
1328
|
+
return true;
|
|
1329
|
+
}
|
|
1330
|
+
const meta = tool._meta;
|
|
1331
|
+
return meta?.toolRouter?.deferred === true;
|
|
1332
|
+
}
|
|
1333
|
+
matchesExcludedTool(toolName) {
|
|
1334
|
+
return this.excludeToolMatchers.some((matcher) => matcher.test(toolName));
|
|
1335
|
+
}
|
|
1336
|
+
getDirectlyVisibleTools() {
|
|
1337
|
+
return this.allTools.filter((tool) => !this.matchesDeferredTool(tool) || this.matchesPinnedTool(tool.name));
|
|
1338
|
+
}
|
|
1304
1339
|
};
|
|
1340
|
+
function globToRegExp(pattern) {
|
|
1341
|
+
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
1342
|
+
const regexPattern = `^${escaped.replace(/\*/g, ".*")}$`;
|
|
1343
|
+
return new RegExp(regexPattern);
|
|
1344
|
+
}
|
|
1305
1345
|
|
|
1306
1346
|
export { AuthenticationError, ConfigurationError, ConnectionError, DEFAULT_CLIENT_NAME, DEFAULT_CLIENT_URI, DEFAULT_HEARTBEAT_INTERVAL_MS, DEFAULT_LOGO_URI, DEFAULT_POLICY_URI, DisposableStore, Emitter, InvalidStateError, MCP_CLIENT_NAME, MCP_CLIENT_VERSION, McpError, NotConnectedError, REDIS_KEY_PREFIX, RpcErrorCodes, SESSION_TTL_SECONDS, SOFTWARE_ID, SOFTWARE_VERSION, STATE_EXPIRATION_MS, SchemaCompressor, SessionNotFoundError, SessionValidationError, TOKEN_EXPIRY_BUFFER_MS, ToolExecutionError, ToolIndex, ToolRouter, UnauthorizedError, createExecuteToolDefinition, createGetSchemaToolDefinition, createListServersToolDefinition, createRegexSearchToolDefinition, createSearchToolDefinition, executeMetaTool, findToolByName, getToolUiResourceUri, isCallToolSuccess, isConnectAuthRequired, isConnectError, isConnectSuccess, isListToolsSuccess, isMetaTool, resolveMetaToolProxy, sanitizeServerLabel };
|
|
1307
1347
|
//# sourceMappingURL=index.mjs.map
|