@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/index.mjs
CHANGED
|
@@ -4647,7 +4647,7 @@ function createRegexSearchToolDefinition() {
|
|
|
4647
4647
|
function createGetSchemaToolDefinition() {
|
|
4648
4648
|
return {
|
|
4649
4649
|
name: "mcp_get_tool_schema",
|
|
4650
|
-
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.",
|
|
4650
|
+
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.",
|
|
4651
4651
|
inputSchema: {
|
|
4652
4652
|
type: "object",
|
|
4653
4653
|
properties: {
|
|
@@ -4832,6 +4832,7 @@ async function executeMetaTool(toolName, args, router, callToolFn) {
|
|
|
4832
4832
|
name: tool.name,
|
|
4833
4833
|
description: tool.description,
|
|
4834
4834
|
inputSchema: tool.inputSchema,
|
|
4835
|
+
outputSchema: tool.outputSchema,
|
|
4835
4836
|
executionInstructions: {
|
|
4836
4837
|
nextTool: "mcp_execute_tool",
|
|
4837
4838
|
toolName: tool.name,
|
|
@@ -4927,18 +4928,29 @@ var ToolRouter = class {
|
|
|
4927
4928
|
this.options = options;
|
|
4928
4929
|
__publicField(this, "index");
|
|
4929
4930
|
__publicField(this, "allTools", []);
|
|
4931
|
+
__publicField(this, "pinnedTools", []);
|
|
4932
|
+
__publicField(this, "deferredTools", []);
|
|
4933
|
+
__publicField(this, "discoverableTools", []);
|
|
4930
4934
|
__publicField(this, "groupsMap", /* @__PURE__ */ new Map());
|
|
4931
4935
|
__publicField(this, "strategy");
|
|
4932
4936
|
__publicField(this, "maxTools");
|
|
4933
4937
|
__publicField(this, "compactSchemas");
|
|
4934
4938
|
__publicField(this, "activeGroups");
|
|
4935
4939
|
__publicField(this, "customGroups");
|
|
4940
|
+
__publicField(this, "pinnedToolNames");
|
|
4941
|
+
__publicField(this, "deferredToolNames");
|
|
4942
|
+
__publicField(this, "excludeToolMatchers");
|
|
4936
4943
|
__publicField(this, "initialized", false);
|
|
4937
4944
|
this.strategy = options.strategy ?? "all";
|
|
4938
4945
|
this.maxTools = options.maxTools ?? 40;
|
|
4939
4946
|
this.compactSchemas = options.compactSchemas ?? false;
|
|
4940
4947
|
this.activeGroups = new Set(options.activeGroups ?? []);
|
|
4941
4948
|
this.customGroups = options.groups;
|
|
4949
|
+
this.pinnedToolNames = new Set(options.pinnedTools ?? []);
|
|
4950
|
+
this.deferredToolNames = new Set(options.deferredTools ?? []);
|
|
4951
|
+
this.excludeToolMatchers = (options.excludeTools ?? []).map(
|
|
4952
|
+
(pattern) => globToRegExp(pattern)
|
|
4953
|
+
);
|
|
4942
4954
|
this.index = new ToolIndex({
|
|
4943
4955
|
embedFn: options.embedFn,
|
|
4944
4956
|
keywordWeight: options.keywordWeight
|
|
@@ -4959,13 +4971,14 @@ var ToolRouter = class {
|
|
|
4959
4971
|
await this.ensureInitialized();
|
|
4960
4972
|
switch (this.strategy) {
|
|
4961
4973
|
case "search":
|
|
4962
|
-
return this.getMetaToolDefinitions();
|
|
4974
|
+
return [...this.getMetaToolDefinitions(), ...this.pinnedTools];
|
|
4963
4975
|
case "groups":
|
|
4964
4976
|
return this.getGroupFilteredTools();
|
|
4965
4977
|
case "all":
|
|
4966
4978
|
default:
|
|
4979
|
+
const directlyVisibleTools = this.getDirectlyVisibleTools();
|
|
4967
4980
|
if (this.compactSchemas) {
|
|
4968
|
-
return
|
|
4981
|
+
return directlyVisibleTools.map((t) => {
|
|
4969
4982
|
const compact = SchemaCompressor.toCompact(t);
|
|
4970
4983
|
return {
|
|
4971
4984
|
name: compact.name,
|
|
@@ -4974,7 +4987,7 @@ var ToolRouter = class {
|
|
|
4974
4987
|
};
|
|
4975
4988
|
});
|
|
4976
4989
|
}
|
|
4977
|
-
return [...
|
|
4990
|
+
return [...directlyVisibleTools];
|
|
4978
4991
|
}
|
|
4979
4992
|
}
|
|
4980
4993
|
/**
|
|
@@ -5086,8 +5099,14 @@ var ToolRouter = class {
|
|
|
5086
5099
|
/** Lazy initialization — fetches tools from all connected clients. */
|
|
5087
5100
|
async ensureInitialized() {
|
|
5088
5101
|
if (this.initialized) return;
|
|
5089
|
-
|
|
5090
|
-
|
|
5102
|
+
const fetchedTools = await this.fetchAllTools();
|
|
5103
|
+
this.allTools = fetchedTools.filter((tool) => !this.matchesExcludedTool(tool.name));
|
|
5104
|
+
this.pinnedTools = this.allTools.filter((tool) => this.matchesPinnedTool(tool.name));
|
|
5105
|
+
this.deferredTools = this.allTools.filter(
|
|
5106
|
+
(tool) => !this.matchesPinnedTool(tool.name) && this.matchesDeferredTool(tool)
|
|
5107
|
+
);
|
|
5108
|
+
this.discoverableTools = this.allTools.filter((tool) => !this.matchesPinnedTool(tool.name));
|
|
5109
|
+
await this.index.buildIndex(this.discoverableTools);
|
|
5091
5110
|
this.buildGroups();
|
|
5092
5111
|
this.initialized = true;
|
|
5093
5112
|
}
|
|
@@ -5163,7 +5182,7 @@ var ToolRouter = class {
|
|
|
5163
5182
|
}
|
|
5164
5183
|
}
|
|
5165
5184
|
}
|
|
5166
|
-
const filtered = this.
|
|
5185
|
+
const filtered = this.getDirectlyVisibleTools().filter((t) => activeToolNames.has(t.name));
|
|
5167
5186
|
if (this.compactSchemas) {
|
|
5168
5187
|
return filtered.slice(0, this.maxTools).map((t) => {
|
|
5169
5188
|
const compact = SchemaCompressor.toCompact(t);
|
|
@@ -5186,7 +5205,28 @@ var ToolRouter = class {
|
|
|
5186
5205
|
createExecuteToolDefinition()
|
|
5187
5206
|
];
|
|
5188
5207
|
}
|
|
5208
|
+
matchesPinnedTool(toolName) {
|
|
5209
|
+
return this.pinnedToolNames.has(toolName);
|
|
5210
|
+
}
|
|
5211
|
+
matchesDeferredTool(tool) {
|
|
5212
|
+
if (this.deferredToolNames.has(tool.name)) {
|
|
5213
|
+
return true;
|
|
5214
|
+
}
|
|
5215
|
+
const meta = tool._meta;
|
|
5216
|
+
return meta?.toolRouter?.deferred === true;
|
|
5217
|
+
}
|
|
5218
|
+
matchesExcludedTool(toolName) {
|
|
5219
|
+
return this.excludeToolMatchers.some((matcher) => matcher.test(toolName));
|
|
5220
|
+
}
|
|
5221
|
+
getDirectlyVisibleTools() {
|
|
5222
|
+
return this.allTools.filter((tool) => !this.matchesDeferredTool(tool) || this.matchesPinnedTool(tool.name));
|
|
5223
|
+
}
|
|
5189
5224
|
};
|
|
5225
|
+
function globToRegExp(pattern) {
|
|
5226
|
+
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
5227
|
+
const regexPattern = `^${escaped.replace(/\*/g, ".*")}$`;
|
|
5228
|
+
return new RegExp(regexPattern);
|
|
5229
|
+
}
|
|
5190
5230
|
|
|
5191
5231
|
export { APP_HOST_DEFAULTS, AppHost, AuthenticationError, ConfigurationError, ConnectionError, DEFAULT_CLIENT_NAME, DEFAULT_CLIENT_URI, DEFAULT_HEARTBEAT_INTERVAL_MS, DEFAULT_LOGO_URI, DEFAULT_MCP_APP_CSP, DEFAULT_POLICY_URI, DisposableStore, Emitter, InvalidStateError, MCPClient, MCP_CLIENT_NAME, MCP_CLIENT_VERSION, McpError, MultiSessionClient, NotConnectedError, REDIS_KEY_PREFIX, RpcErrorCodes, SANDBOX_PROXY_READY_METHOD, SANDBOX_RESOURCE_READY_METHOD, SESSION_TTL_SECONDS, SOFTWARE_ID, SOFTWARE_VERSION, SSEClient, SSEConnectionManager, STATE_EXPIRATION_MS, SchemaCompressor, SessionNotFoundError, SessionValidationError, StorageOAuthClientProvider, TOKEN_EXPIRY_BUFFER_MS, ToolExecutionError, ToolIndex, ToolRouter, UnauthorizedError, createExecuteToolDefinition, createGetSchemaToolDefinition, createListServersToolDefinition, createNextMcpHandler, createRegexSearchToolDefinition, createSSEHandler, createSearchToolDefinition, executeMetaTool, findToolByName, getToolUiResourceUri, isCallToolSuccess, isConnectAuthRequired, isConnectError, isConnectSuccess, isListToolsSuccess, isMetaTool, resolveMetaToolProxy, sanitizeServerLabel, sessions };
|
|
5192
5232
|
//# sourceMappingURL=index.mjs.map
|