@mcp-ts/sdk 2.0.0 → 2.1.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 +27 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -4
- 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 +27 -4
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +27 -4
- package/dist/shared/index.mjs.map +1 -1
- package/dist/{tool-router-Ddtybmr0.d.ts → tool-router-BP8TT9mI.d.ts} +17 -1
- package/dist/{tool-router-Dnd6IOKC.d.mts → tool-router-BkQnso27.d.mts} +17 -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 +38 -3
- 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,26 @@ 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, "discoverableTools", []);
|
|
1045
1048
|
__publicField(this, "groupsMap", /* @__PURE__ */ new Map());
|
|
1046
1049
|
__publicField(this, "strategy");
|
|
1047
1050
|
__publicField(this, "maxTools");
|
|
1048
1051
|
__publicField(this, "compactSchemas");
|
|
1049
1052
|
__publicField(this, "activeGroups");
|
|
1050
1053
|
__publicField(this, "customGroups");
|
|
1054
|
+
__publicField(this, "pinnedToolNames");
|
|
1055
|
+
__publicField(this, "excludeToolMatchers");
|
|
1051
1056
|
__publicField(this, "initialized", false);
|
|
1052
1057
|
this.strategy = options.strategy ?? "all";
|
|
1053
1058
|
this.maxTools = options.maxTools ?? 40;
|
|
1054
1059
|
this.compactSchemas = options.compactSchemas ?? false;
|
|
1055
1060
|
this.activeGroups = new Set(options.activeGroups ?? []);
|
|
1056
1061
|
this.customGroups = options.groups;
|
|
1062
|
+
this.pinnedToolNames = new Set(options.pinnedTools ?? []);
|
|
1063
|
+
this.excludeToolMatchers = (options.excludeTools ?? []).map(
|
|
1064
|
+
(pattern) => globToRegExp(pattern)
|
|
1065
|
+
);
|
|
1057
1066
|
this.index = new ToolIndex({
|
|
1058
1067
|
embedFn: options.embedFn,
|
|
1059
1068
|
keywordWeight: options.keywordWeight
|
|
@@ -1074,7 +1083,7 @@ var ToolRouter = class {
|
|
|
1074
1083
|
await this.ensureInitialized();
|
|
1075
1084
|
switch (this.strategy) {
|
|
1076
1085
|
case "search":
|
|
1077
|
-
return this.getMetaToolDefinitions();
|
|
1086
|
+
return [...this.getMetaToolDefinitions(), ...this.pinnedTools];
|
|
1078
1087
|
case "groups":
|
|
1079
1088
|
return this.getGroupFilteredTools();
|
|
1080
1089
|
case "all":
|
|
@@ -1201,8 +1210,11 @@ var ToolRouter = class {
|
|
|
1201
1210
|
/** Lazy initialization — fetches tools from all connected clients. */
|
|
1202
1211
|
async ensureInitialized() {
|
|
1203
1212
|
if (this.initialized) return;
|
|
1204
|
-
|
|
1205
|
-
|
|
1213
|
+
const fetchedTools = await this.fetchAllTools();
|
|
1214
|
+
this.allTools = fetchedTools.filter((tool) => !this.matchesExcludedTool(tool.name));
|
|
1215
|
+
this.pinnedTools = this.allTools.filter((tool) => this.matchesPinnedTool(tool.name));
|
|
1216
|
+
this.discoverableTools = this.allTools.filter((tool) => !this.matchesPinnedTool(tool.name));
|
|
1217
|
+
await this.index.buildIndex(this.discoverableTools);
|
|
1206
1218
|
this.buildGroups();
|
|
1207
1219
|
this.initialized = true;
|
|
1208
1220
|
}
|
|
@@ -1301,7 +1313,18 @@ var ToolRouter = class {
|
|
|
1301
1313
|
createExecuteToolDefinition()
|
|
1302
1314
|
];
|
|
1303
1315
|
}
|
|
1316
|
+
matchesPinnedTool(toolName) {
|
|
1317
|
+
return this.pinnedToolNames.has(toolName);
|
|
1318
|
+
}
|
|
1319
|
+
matchesExcludedTool(toolName) {
|
|
1320
|
+
return this.excludeToolMatchers.some((matcher) => matcher.test(toolName));
|
|
1321
|
+
}
|
|
1304
1322
|
};
|
|
1323
|
+
function globToRegExp(pattern) {
|
|
1324
|
+
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
1325
|
+
const regexPattern = `^${escaped.replace(/\*/g, ".*")}$`;
|
|
1326
|
+
return new RegExp(regexPattern);
|
|
1327
|
+
}
|
|
1305
1328
|
|
|
1306
1329
|
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
1330
|
//# sourceMappingURL=index.mjs.map
|