@mcp-ts/sdk 2.3.0 → 2.3.2
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-adapter.js +9 -5
- package/dist/adapters/agui-adapter.js.map +1 -1
- package/dist/adapters/agui-adapter.mjs +9 -5
- package/dist/adapters/agui-adapter.mjs.map +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/ai-adapter.js +9 -5
- package/dist/adapters/ai-adapter.js.map +1 -1
- package/dist/adapters/ai-adapter.mjs +9 -5
- package/dist/adapters/ai-adapter.mjs.map +1 -1
- package/dist/adapters/langchain-adapter.d.mts +1 -1
- package/dist/adapters/langchain-adapter.d.ts +1 -1
- package/dist/adapters/langchain-adapter.js +9 -5
- package/dist/adapters/langchain-adapter.js.map +1 -1
- package/dist/adapters/langchain-adapter.mjs +9 -5
- package/dist/adapters/langchain-adapter.mjs.map +1 -1
- package/dist/client/react.js.map +1 -1
- package/dist/client/react.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +35 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -6
- package/dist/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 +35 -6
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +35 -6
- package/dist/shared/index.mjs.map +1 -1
- package/dist/{tool-router-CdX8e9bk.d.ts → tool-router-BMzhoNYt.d.ts} +7 -0
- package/dist/{tool-router-C8hIA-tg.d.mts → tool-router-BhHsvBfP.d.mts} +7 -0
- package/package.json +1 -1
- package/src/shared/meta-tools.ts +16 -7
- package/src/shared/tool-router.ts +45 -1
package/dist/index.d.mts
CHANGED
|
@@ -7,6 +7,6 @@ export { OAuthClientInformation, OAuthClientInformationFull, OAuthClientMetadata
|
|
|
7
7
|
export { CallToolResult, ListToolsResult, Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
8
8
|
export { A as APP_HOST_DEFAULTS, a as AppHost, D as DEFAULT_MCP_APP_CSP, S as SANDBOX_PROXY_READY_METHOD, b as SANDBOX_RESOURCE_READY_METHOD, c as SSEClient, d as SSEClientOptions } from './index-Cfjsme-a.mjs';
|
|
9
9
|
export { CallToolFn, DEFAULT_CLIENT_NAME, DEFAULT_CLIENT_URI, DEFAULT_HEARTBEAT_INTERVAL_MS, DEFAULT_LOGO_URI, DEFAULT_POLICY_URI, MCP_CLIENT_NAME, MCP_CLIENT_VERSION, REDIS_KEY_PREFIX, SESSION_TTL_SECONDS, SOFTWARE_ID, SOFTWARE_VERSION, STATE_EXPIRATION_MS, TOKEN_EXPIRY_BUFFER_MS, ToolUiConfig, createExecuteToolDefinition, createGetSchemaToolDefinition, createListServersToolDefinition, createRegexSearchToolDefinition, createSearchToolDefinition, executeMetaTool, findToolByName, getToolUiResourceUri, isMetaTool, resolveMetaToolProxy } from './shared/index.mjs';
|
|
10
|
-
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, d as ToolRouter, e as ToolRouterClientInput, f as ToolRouterOptions, g as ToolRouterStrategy, h as ToolSearchOptions, i as ToolServerSummary, j as ToolSummary } from './tool-router-
|
|
10
|
+
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, d as ToolRouter, e as ToolRouterClientInput, f as ToolRouterOptions, g as ToolRouterStrategy, h as ToolSearchOptions, i as ToolServerSummary, j as ToolSummary } from './tool-router-BhHsvBfP.mjs';
|
|
11
11
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
12
12
|
import '@modelcontextprotocol/ext-apps/app-bridge';
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ export { OAuthClientInformation, OAuthClientInformationFull, OAuthClientMetadata
|
|
|
7
7
|
export { CallToolResult, ListToolsResult, Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
8
8
|
export { A as APP_HOST_DEFAULTS, a as AppHost, D as DEFAULT_MCP_APP_CSP, S as SANDBOX_PROXY_READY_METHOD, b as SANDBOX_RESOURCE_READY_METHOD, c as SSEClient, d as SSEClientOptions } from './index-CmjMd2ac.js';
|
|
9
9
|
export { CallToolFn, DEFAULT_CLIENT_NAME, DEFAULT_CLIENT_URI, DEFAULT_HEARTBEAT_INTERVAL_MS, DEFAULT_LOGO_URI, DEFAULT_POLICY_URI, MCP_CLIENT_NAME, MCP_CLIENT_VERSION, REDIS_KEY_PREFIX, SESSION_TTL_SECONDS, SOFTWARE_ID, SOFTWARE_VERSION, STATE_EXPIRATION_MS, TOKEN_EXPIRY_BUFFER_MS, ToolUiConfig, createExecuteToolDefinition, createGetSchemaToolDefinition, createListServersToolDefinition, createRegexSearchToolDefinition, createSearchToolDefinition, executeMetaTool, findToolByName, getToolUiResourceUri, isMetaTool, resolveMetaToolProxy } from './shared/index.js';
|
|
10
|
-
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, d as ToolRouter, e as ToolRouterClientInput, f as ToolRouterOptions, g as ToolRouterStrategy, h as ToolSearchOptions, i as ToolServerSummary, j as ToolSummary } from './tool-router-
|
|
10
|
+
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, d as ToolRouter, e as ToolRouterClientInput, f as ToolRouterOptions, g as ToolRouterStrategy, h as ToolSearchOptions, i as ToolServerSummary, j as ToolSummary } from './tool-router-BMzhoNYt.js';
|
|
11
11
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
12
12
|
import '@modelcontextprotocol/ext-apps/app-bridge';
|
package/dist/index.js
CHANGED
|
@@ -4854,8 +4854,13 @@ function createExecuteToolDefinition() {
|
|
|
4854
4854
|
};
|
|
4855
4855
|
}
|
|
4856
4856
|
async function executeMetaTool(toolName, args, router, callToolFn) {
|
|
4857
|
-
const resolveToolSchema = (name, namespace, options) => {
|
|
4857
|
+
const resolveToolSchema = async (name, namespace, options) => {
|
|
4858
4858
|
try {
|
|
4859
|
+
if (typeof router.resolveToolSchema === "function") {
|
|
4860
|
+
return {
|
|
4861
|
+
tool: await router.resolveToolSchema(name, namespace, options)
|
|
4862
|
+
};
|
|
4863
|
+
}
|
|
4859
4864
|
return { tool: router.getToolSchema(name, namespace, options) };
|
|
4860
4865
|
} catch (err) {
|
|
4861
4866
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
@@ -4907,13 +4912,12 @@ async function executeMetaTool(toolName, args, router, callToolFn) {
|
|
|
4907
4912
|
const searchOptions = { serverId, serverName };
|
|
4908
4913
|
const selectMatch = query.match(/^select:(.+)$/i);
|
|
4909
4914
|
if (selectMatch) {
|
|
4910
|
-
await router.listTools({ serverId, serverName, limit: 1 });
|
|
4911
4915
|
const requested = selectMatch[1].split(",").map((s) => s.trim()).filter(Boolean);
|
|
4912
4916
|
const found = [];
|
|
4913
4917
|
const errors = [];
|
|
4914
4918
|
const namespace = serverId ?? serverName;
|
|
4915
4919
|
for (const requestedToolName of requested) {
|
|
4916
|
-
const { tool, error } = resolveToolSchema(requestedToolName, namespace, {
|
|
4920
|
+
const { tool, error } = await resolveToolSchema(requestedToolName, namespace, {
|
|
4917
4921
|
allowServerNameFragment: Boolean(serverName && !serverId)
|
|
4918
4922
|
});
|
|
4919
4923
|
if (error) {
|
|
@@ -4977,7 +4981,7 @@ async function executeMetaTool(toolName, args, router, callToolFn) {
|
|
|
4977
4981
|
case "mcp_get_tool_schema": {
|
|
4978
4982
|
const name = String(args.toolName ?? "");
|
|
4979
4983
|
const namespace = String(args.serverId ?? "") || void 0;
|
|
4980
|
-
const { tool, error } = resolveToolSchema(name, namespace);
|
|
4984
|
+
const { tool, error } = await resolveToolSchema(name, namespace);
|
|
4981
4985
|
if (error) {
|
|
4982
4986
|
return error;
|
|
4983
4987
|
}
|
|
@@ -5019,7 +5023,7 @@ async function executeMetaTool(toolName, args, router, callToolFn) {
|
|
|
5019
5023
|
isError: true
|
|
5020
5024
|
};
|
|
5021
5025
|
}
|
|
5022
|
-
const { tool, error } = resolveToolSchema(targetToolName, namespace);
|
|
5026
|
+
const { tool, error } = await resolveToolSchema(targetToolName, namespace);
|
|
5023
5027
|
if (error) {
|
|
5024
5028
|
return error;
|
|
5025
5029
|
}
|
|
@@ -5186,7 +5190,7 @@ var ToolRouter = class {
|
|
|
5186
5190
|
* If tool name is ambiguous, use namespace to specify the server.
|
|
5187
5191
|
*/
|
|
5188
5192
|
getToolSchema(toolName, namespace, options = {}) {
|
|
5189
|
-
const matches = this.
|
|
5193
|
+
const matches = this.getIndexedToolMatches(toolName, namespace, options);
|
|
5190
5194
|
if (matches.length === 0) return void 0;
|
|
5191
5195
|
if (matches.length > 1) {
|
|
5192
5196
|
const servers = matches.map((m) => m.serverId).join(", ");
|
|
@@ -5196,6 +5200,14 @@ var ToolRouter = class {
|
|
|
5196
5200
|
}
|
|
5197
5201
|
return matches[0];
|
|
5198
5202
|
}
|
|
5203
|
+
/**
|
|
5204
|
+
* Resolve the full tool definition by name, ensuring the router index has
|
|
5205
|
+
* been initialized first.
|
|
5206
|
+
*/
|
|
5207
|
+
async resolveToolSchema(toolName, namespace, options = {}) {
|
|
5208
|
+
await this.ensureInitialized();
|
|
5209
|
+
return this.getToolSchema(toolName, namespace, options);
|
|
5210
|
+
}
|
|
5199
5211
|
/**
|
|
5200
5212
|
* Get compact (schema-less) summaries for all tools.
|
|
5201
5213
|
*/
|
|
@@ -5385,6 +5397,23 @@ var ToolRouter = class {
|
|
|
5385
5397
|
getDirectlyVisibleTools() {
|
|
5386
5398
|
return this.allTools.filter((tool) => !this.matchesDeferredTool(tool) || this.matchesPinnedTool(tool.name));
|
|
5387
5399
|
}
|
|
5400
|
+
getIndexedToolMatches(toolName, namespace, options = {}) {
|
|
5401
|
+
const indexedMatches = this.index.getTool(toolName, namespace, options);
|
|
5402
|
+
if (indexedMatches.length > 0 || !this.matchesPinnedTool(toolName)) {
|
|
5403
|
+
return indexedMatches;
|
|
5404
|
+
}
|
|
5405
|
+
return this.matchTools(this.pinnedTools.filter((tool) => tool.name === toolName), namespace, options);
|
|
5406
|
+
}
|
|
5407
|
+
matchTools(tools, namespace, options = {}) {
|
|
5408
|
+
if (!namespace) return tools;
|
|
5409
|
+
const exactMatches = tools.filter(
|
|
5410
|
+
(tool) => tool.sessionId === namespace || tool.serverId === namespace
|
|
5411
|
+
);
|
|
5412
|
+
if (exactMatches.length > 0) return exactMatches;
|
|
5413
|
+
if (!options.allowServerNameFragment) return [];
|
|
5414
|
+
const namespaceLower = namespace.toLowerCase();
|
|
5415
|
+
return tools.filter((tool) => tool.serverName.toLowerCase().includes(namespaceLower));
|
|
5416
|
+
}
|
|
5388
5417
|
};
|
|
5389
5418
|
function globToRegExp(pattern) {
|
|
5390
5419
|
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|