@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/server/index.d.mts
CHANGED
|
@@ -4,8 +4,8 @@ import { OAuthClientInformationMixed, OAuthTokens } from '@modelcontextprotocol/
|
|
|
4
4
|
export { OAuthClientInformation, OAuthClientInformationFull, OAuthClientMetadata, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
5
5
|
import { M as McpConnectionEvent, d as McpObservabilityEvent } from '../events-CK3N--3g.mjs';
|
|
6
6
|
export { D as Disposable, E as Emitter, b as Event, c as McpConnectionState } from '../events-CK3N--3g.mjs';
|
|
7
|
-
import { r as McpRpcResponse, q as McpRpcRequest } from '../types-
|
|
8
|
-
export { a as CallToolRequest, b as CallToolResponse, f as ConnectRequest, g as ConnectResponse, n as ListToolsResponse, T as ToolClient, u as ToolClientProvider, v as ToolInfo } from '../types-
|
|
7
|
+
import { r as McpRpcResponse, q as McpRpcRequest } from '../types-CxFaaZrM.mjs';
|
|
8
|
+
export { a as CallToolRequest, b as CallToolResponse, f as ConnectRequest, g as ConnectResponse, n as ListToolsResponse, T as ToolClient, u as ToolClientProvider, v as ToolInfo } from '../types-CxFaaZrM.mjs';
|
|
9
9
|
export { CallToolResult, ListToolsResult, Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
10
10
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
11
11
|
|
package/dist/server/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { OAuthClientInformationMixed, OAuthTokens } from '@modelcontextprotocol/
|
|
|
4
4
|
export { OAuthClientInformation, OAuthClientInformationFull, OAuthClientMetadata, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
5
5
|
import { M as McpConnectionEvent, d as McpObservabilityEvent } from '../events-CK3N--3g.js';
|
|
6
6
|
export { D as Disposable, E as Emitter, b as Event, c as McpConnectionState } from '../events-CK3N--3g.js';
|
|
7
|
-
import { r as McpRpcResponse, q as McpRpcRequest } from '../types-
|
|
8
|
-
export { a as CallToolRequest, b as CallToolResponse, f as ConnectRequest, g as ConnectResponse, n as ListToolsResponse, T as ToolClient, u as ToolClientProvider, v as ToolInfo } from '../types-
|
|
7
|
+
import { r as McpRpcResponse, q as McpRpcRequest } from '../types-CxFaaZrM.js';
|
|
8
|
+
export { a as CallToolRequest, b as CallToolResponse, f as ConnectRequest, g as ConnectResponse, n as ListToolsResponse, T as ToolClient, u as ToolClientProvider, v as ToolInfo } from '../types-CxFaaZrM.js';
|
|
9
9
|
export { CallToolResult, ListToolsResult, Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
10
10
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
11
11
|
|
package/dist/shared/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { D as Disposable, a as DisposableStore, E as Emitter, b as Event, M as McpConnectionEvent, c as McpConnectionState, d as McpObservabilityEvent } from '../events-CK3N--3g.mjs';
|
|
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
|
-
import { v as ToolInfo } from '../types-
|
|
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-
|
|
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-
|
|
3
|
+
import { v as ToolInfo } from '../types-CxFaaZrM.mjs';
|
|
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-C8hIA-tg.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-C8hIA-tg.mjs';
|
|
7
7
|
import { Tool, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -102,8 +102,8 @@ declare function createRegexSearchToolDefinition(): Tool;
|
|
|
102
102
|
*
|
|
103
103
|
* After discovering tools via `mcp_search_tools` or
|
|
104
104
|
* `mcp_search_tool_regex`, the LLM calls this to load the full
|
|
105
|
-
*
|
|
106
|
-
* arguments.
|
|
105
|
+
* input and output schemas for a specific tool so it can construct the
|
|
106
|
+
* correct arguments and plan around the result shape.
|
|
107
107
|
*/
|
|
108
108
|
declare function createGetSchemaToolDefinition(): Tool;
|
|
109
109
|
/**
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { D as Disposable, a as DisposableStore, E as Emitter, b as Event, M as McpConnectionEvent, c as McpConnectionState, d as McpObservabilityEvent } from '../events-CK3N--3g.js';
|
|
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
|
-
import { v as ToolInfo } from '../types-
|
|
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-
|
|
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-
|
|
3
|
+
import { v as ToolInfo } from '../types-CxFaaZrM.js';
|
|
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-CdX8e9bk.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-CdX8e9bk.js';
|
|
7
7
|
import { Tool, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -102,8 +102,8 @@ declare function createRegexSearchToolDefinition(): Tool;
|
|
|
102
102
|
*
|
|
103
103
|
* After discovering tools via `mcp_search_tools` or
|
|
104
104
|
* `mcp_search_tool_regex`, the LLM calls this to load the full
|
|
105
|
-
*
|
|
106
|
-
* arguments.
|
|
105
|
+
* input and output schemas for a specific tool so it can construct the
|
|
106
|
+
* correct arguments and plan around the result shape.
|
|
107
107
|
*/
|
|
108
108
|
declare function createGetSchemaToolDefinition(): Tool;
|
|
109
109
|
/**
|
package/dist/shared/index.js
CHANGED
|
@@ -764,7 +764,7 @@ function createRegexSearchToolDefinition() {
|
|
|
764
764
|
function createGetSchemaToolDefinition() {
|
|
765
765
|
return {
|
|
766
766
|
name: "mcp_get_tool_schema",
|
|
767
|
-
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.",
|
|
767
|
+
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.",
|
|
768
768
|
inputSchema: {
|
|
769
769
|
type: "object",
|
|
770
770
|
properties: {
|
|
@@ -949,6 +949,7 @@ async function executeMetaTool(toolName, args, router, callToolFn) {
|
|
|
949
949
|
name: tool.name,
|
|
950
950
|
description: tool.description,
|
|
951
951
|
inputSchema: tool.inputSchema,
|
|
952
|
+
outputSchema: tool.outputSchema,
|
|
952
953
|
executionInstructions: {
|
|
953
954
|
nextTool: "mcp_execute_tool",
|
|
954
955
|
toolName: tool.name,
|
|
@@ -1044,18 +1045,29 @@ var ToolRouter = class {
|
|
|
1044
1045
|
this.options = options;
|
|
1045
1046
|
__publicField(this, "index");
|
|
1046
1047
|
__publicField(this, "allTools", []);
|
|
1048
|
+
__publicField(this, "pinnedTools", []);
|
|
1049
|
+
__publicField(this, "deferredTools", []);
|
|
1050
|
+
__publicField(this, "discoverableTools", []);
|
|
1047
1051
|
__publicField(this, "groupsMap", /* @__PURE__ */ new Map());
|
|
1048
1052
|
__publicField(this, "strategy");
|
|
1049
1053
|
__publicField(this, "maxTools");
|
|
1050
1054
|
__publicField(this, "compactSchemas");
|
|
1051
1055
|
__publicField(this, "activeGroups");
|
|
1052
1056
|
__publicField(this, "customGroups");
|
|
1057
|
+
__publicField(this, "pinnedToolNames");
|
|
1058
|
+
__publicField(this, "deferredToolNames");
|
|
1059
|
+
__publicField(this, "excludeToolMatchers");
|
|
1053
1060
|
__publicField(this, "initialized", false);
|
|
1054
1061
|
this.strategy = options.strategy ?? "all";
|
|
1055
1062
|
this.maxTools = options.maxTools ?? 40;
|
|
1056
1063
|
this.compactSchemas = options.compactSchemas ?? false;
|
|
1057
1064
|
this.activeGroups = new Set(options.activeGroups ?? []);
|
|
1058
1065
|
this.customGroups = options.groups;
|
|
1066
|
+
this.pinnedToolNames = new Set(options.pinnedTools ?? []);
|
|
1067
|
+
this.deferredToolNames = new Set(options.deferredTools ?? []);
|
|
1068
|
+
this.excludeToolMatchers = (options.excludeTools ?? []).map(
|
|
1069
|
+
(pattern) => globToRegExp(pattern)
|
|
1070
|
+
);
|
|
1059
1071
|
this.index = new ToolIndex({
|
|
1060
1072
|
embedFn: options.embedFn,
|
|
1061
1073
|
keywordWeight: options.keywordWeight
|
|
@@ -1076,13 +1088,14 @@ var ToolRouter = class {
|
|
|
1076
1088
|
await this.ensureInitialized();
|
|
1077
1089
|
switch (this.strategy) {
|
|
1078
1090
|
case "search":
|
|
1079
|
-
return this.getMetaToolDefinitions();
|
|
1091
|
+
return [...this.getMetaToolDefinitions(), ...this.pinnedTools];
|
|
1080
1092
|
case "groups":
|
|
1081
1093
|
return this.getGroupFilteredTools();
|
|
1082
1094
|
case "all":
|
|
1083
1095
|
default:
|
|
1096
|
+
const directlyVisibleTools = this.getDirectlyVisibleTools();
|
|
1084
1097
|
if (this.compactSchemas) {
|
|
1085
|
-
return
|
|
1098
|
+
return directlyVisibleTools.map((t) => {
|
|
1086
1099
|
const compact = SchemaCompressor.toCompact(t);
|
|
1087
1100
|
return {
|
|
1088
1101
|
name: compact.name,
|
|
@@ -1091,7 +1104,7 @@ var ToolRouter = class {
|
|
|
1091
1104
|
};
|
|
1092
1105
|
});
|
|
1093
1106
|
}
|
|
1094
|
-
return [...
|
|
1107
|
+
return [...directlyVisibleTools];
|
|
1095
1108
|
}
|
|
1096
1109
|
}
|
|
1097
1110
|
/**
|
|
@@ -1203,8 +1216,14 @@ var ToolRouter = class {
|
|
|
1203
1216
|
/** Lazy initialization — fetches tools from all connected clients. */
|
|
1204
1217
|
async ensureInitialized() {
|
|
1205
1218
|
if (this.initialized) return;
|
|
1206
|
-
|
|
1207
|
-
|
|
1219
|
+
const fetchedTools = await this.fetchAllTools();
|
|
1220
|
+
this.allTools = fetchedTools.filter((tool) => !this.matchesExcludedTool(tool.name));
|
|
1221
|
+
this.pinnedTools = this.allTools.filter((tool) => this.matchesPinnedTool(tool.name));
|
|
1222
|
+
this.deferredTools = this.allTools.filter(
|
|
1223
|
+
(tool) => !this.matchesPinnedTool(tool.name) && this.matchesDeferredTool(tool)
|
|
1224
|
+
);
|
|
1225
|
+
this.discoverableTools = this.allTools.filter((tool) => !this.matchesPinnedTool(tool.name));
|
|
1226
|
+
await this.index.buildIndex(this.discoverableTools);
|
|
1208
1227
|
this.buildGroups();
|
|
1209
1228
|
this.initialized = true;
|
|
1210
1229
|
}
|
|
@@ -1280,7 +1299,7 @@ var ToolRouter = class {
|
|
|
1280
1299
|
}
|
|
1281
1300
|
}
|
|
1282
1301
|
}
|
|
1283
|
-
const filtered = this.
|
|
1302
|
+
const filtered = this.getDirectlyVisibleTools().filter((t) => activeToolNames.has(t.name));
|
|
1284
1303
|
if (this.compactSchemas) {
|
|
1285
1304
|
return filtered.slice(0, this.maxTools).map((t) => {
|
|
1286
1305
|
const compact = SchemaCompressor.toCompact(t);
|
|
@@ -1303,7 +1322,28 @@ var ToolRouter = class {
|
|
|
1303
1322
|
createExecuteToolDefinition()
|
|
1304
1323
|
];
|
|
1305
1324
|
}
|
|
1325
|
+
matchesPinnedTool(toolName) {
|
|
1326
|
+
return this.pinnedToolNames.has(toolName);
|
|
1327
|
+
}
|
|
1328
|
+
matchesDeferredTool(tool) {
|
|
1329
|
+
if (this.deferredToolNames.has(tool.name)) {
|
|
1330
|
+
return true;
|
|
1331
|
+
}
|
|
1332
|
+
const meta = tool._meta;
|
|
1333
|
+
return meta?.toolRouter?.deferred === true;
|
|
1334
|
+
}
|
|
1335
|
+
matchesExcludedTool(toolName) {
|
|
1336
|
+
return this.excludeToolMatchers.some((matcher) => matcher.test(toolName));
|
|
1337
|
+
}
|
|
1338
|
+
getDirectlyVisibleTools() {
|
|
1339
|
+
return this.allTools.filter((tool) => !this.matchesDeferredTool(tool) || this.matchesPinnedTool(tool.name));
|
|
1340
|
+
}
|
|
1306
1341
|
};
|
|
1342
|
+
function globToRegExp(pattern) {
|
|
1343
|
+
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
1344
|
+
const regexPattern = `^${escaped.replace(/\*/g, ".*")}$`;
|
|
1345
|
+
return new RegExp(regexPattern);
|
|
1346
|
+
}
|
|
1307
1347
|
|
|
1308
1348
|
exports.AuthenticationError = AuthenticationError;
|
|
1309
1349
|
exports.ConfigurationError = ConfigurationError;
|