@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/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-BhHsvBfP.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-BhHsvBfP.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-BMzhoNYt.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-BMzhoNYt.js';
|
|
7
7
|
import { Tool, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
8
8
|
|
|
9
9
|
/**
|
package/dist/shared/index.js
CHANGED
|
@@ -807,8 +807,13 @@ function createExecuteToolDefinition() {
|
|
|
807
807
|
};
|
|
808
808
|
}
|
|
809
809
|
async function executeMetaTool(toolName, args, router, callToolFn) {
|
|
810
|
-
const resolveToolSchema = (name, namespace, options) => {
|
|
810
|
+
const resolveToolSchema = async (name, namespace, options) => {
|
|
811
811
|
try {
|
|
812
|
+
if (typeof router.resolveToolSchema === "function") {
|
|
813
|
+
return {
|
|
814
|
+
tool: await router.resolveToolSchema(name, namespace, options)
|
|
815
|
+
};
|
|
816
|
+
}
|
|
812
817
|
return { tool: router.getToolSchema(name, namespace, options) };
|
|
813
818
|
} catch (err) {
|
|
814
819
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
@@ -860,13 +865,12 @@ async function executeMetaTool(toolName, args, router, callToolFn) {
|
|
|
860
865
|
const searchOptions = { serverId, serverName };
|
|
861
866
|
const selectMatch = query.match(/^select:(.+)$/i);
|
|
862
867
|
if (selectMatch) {
|
|
863
|
-
await router.listTools({ serverId, serverName, limit: 1 });
|
|
864
868
|
const requested = selectMatch[1].split(",").map((s) => s.trim()).filter(Boolean);
|
|
865
869
|
const found = [];
|
|
866
870
|
const errors = [];
|
|
867
871
|
const namespace = serverId ?? serverName;
|
|
868
872
|
for (const requestedToolName of requested) {
|
|
869
|
-
const { tool, error } = resolveToolSchema(requestedToolName, namespace, {
|
|
873
|
+
const { tool, error } = await resolveToolSchema(requestedToolName, namespace, {
|
|
870
874
|
allowServerNameFragment: Boolean(serverName && !serverId)
|
|
871
875
|
});
|
|
872
876
|
if (error) {
|
|
@@ -930,7 +934,7 @@ async function executeMetaTool(toolName, args, router, callToolFn) {
|
|
|
930
934
|
case "mcp_get_tool_schema": {
|
|
931
935
|
const name = String(args.toolName ?? "");
|
|
932
936
|
const namespace = String(args.serverId ?? "") || void 0;
|
|
933
|
-
const { tool, error } = resolveToolSchema(name, namespace);
|
|
937
|
+
const { tool, error } = await resolveToolSchema(name, namespace);
|
|
934
938
|
if (error) {
|
|
935
939
|
return error;
|
|
936
940
|
}
|
|
@@ -972,7 +976,7 @@ async function executeMetaTool(toolName, args, router, callToolFn) {
|
|
|
972
976
|
isError: true
|
|
973
977
|
};
|
|
974
978
|
}
|
|
975
|
-
const { tool, error } = resolveToolSchema(targetToolName, namespace);
|
|
979
|
+
const { tool, error } = await resolveToolSchema(targetToolName, namespace);
|
|
976
980
|
if (error) {
|
|
977
981
|
return error;
|
|
978
982
|
}
|
|
@@ -1139,7 +1143,7 @@ var ToolRouter = class {
|
|
|
1139
1143
|
* If tool name is ambiguous, use namespace to specify the server.
|
|
1140
1144
|
*/
|
|
1141
1145
|
getToolSchema(toolName, namespace, options = {}) {
|
|
1142
|
-
const matches = this.
|
|
1146
|
+
const matches = this.getIndexedToolMatches(toolName, namespace, options);
|
|
1143
1147
|
if (matches.length === 0) return void 0;
|
|
1144
1148
|
if (matches.length > 1) {
|
|
1145
1149
|
const servers = matches.map((m) => m.serverId).join(", ");
|
|
@@ -1149,6 +1153,14 @@ var ToolRouter = class {
|
|
|
1149
1153
|
}
|
|
1150
1154
|
return matches[0];
|
|
1151
1155
|
}
|
|
1156
|
+
/**
|
|
1157
|
+
* Resolve the full tool definition by name, ensuring the router index has
|
|
1158
|
+
* been initialized first.
|
|
1159
|
+
*/
|
|
1160
|
+
async resolveToolSchema(toolName, namespace, options = {}) {
|
|
1161
|
+
await this.ensureInitialized();
|
|
1162
|
+
return this.getToolSchema(toolName, namespace, options);
|
|
1163
|
+
}
|
|
1152
1164
|
/**
|
|
1153
1165
|
* Get compact (schema-less) summaries for all tools.
|
|
1154
1166
|
*/
|
|
@@ -1338,6 +1350,23 @@ var ToolRouter = class {
|
|
|
1338
1350
|
getDirectlyVisibleTools() {
|
|
1339
1351
|
return this.allTools.filter((tool) => !this.matchesDeferredTool(tool) || this.matchesPinnedTool(tool.name));
|
|
1340
1352
|
}
|
|
1353
|
+
getIndexedToolMatches(toolName, namespace, options = {}) {
|
|
1354
|
+
const indexedMatches = this.index.getTool(toolName, namespace, options);
|
|
1355
|
+
if (indexedMatches.length > 0 || !this.matchesPinnedTool(toolName)) {
|
|
1356
|
+
return indexedMatches;
|
|
1357
|
+
}
|
|
1358
|
+
return this.matchTools(this.pinnedTools.filter((tool) => tool.name === toolName), namespace, options);
|
|
1359
|
+
}
|
|
1360
|
+
matchTools(tools, namespace, options = {}) {
|
|
1361
|
+
if (!namespace) return tools;
|
|
1362
|
+
const exactMatches = tools.filter(
|
|
1363
|
+
(tool) => tool.sessionId === namespace || tool.serverId === namespace
|
|
1364
|
+
);
|
|
1365
|
+
if (exactMatches.length > 0) return exactMatches;
|
|
1366
|
+
if (!options.allowServerNameFragment) return [];
|
|
1367
|
+
const namespaceLower = namespace.toLowerCase();
|
|
1368
|
+
return tools.filter((tool) => tool.serverName.toLowerCase().includes(namespaceLower));
|
|
1369
|
+
}
|
|
1341
1370
|
};
|
|
1342
1371
|
function globToRegExp(pattern) {
|
|
1343
1372
|
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|