@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/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-BkQnso27.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-BkQnso27.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-BP8TT9mI.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-BP8TT9mI.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,26 @@ 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, "discoverableTools", []);
|
|
1047
1050
|
__publicField(this, "groupsMap", /* @__PURE__ */ new Map());
|
|
1048
1051
|
__publicField(this, "strategy");
|
|
1049
1052
|
__publicField(this, "maxTools");
|
|
1050
1053
|
__publicField(this, "compactSchemas");
|
|
1051
1054
|
__publicField(this, "activeGroups");
|
|
1052
1055
|
__publicField(this, "customGroups");
|
|
1056
|
+
__publicField(this, "pinnedToolNames");
|
|
1057
|
+
__publicField(this, "excludeToolMatchers");
|
|
1053
1058
|
__publicField(this, "initialized", false);
|
|
1054
1059
|
this.strategy = options.strategy ?? "all";
|
|
1055
1060
|
this.maxTools = options.maxTools ?? 40;
|
|
1056
1061
|
this.compactSchemas = options.compactSchemas ?? false;
|
|
1057
1062
|
this.activeGroups = new Set(options.activeGroups ?? []);
|
|
1058
1063
|
this.customGroups = options.groups;
|
|
1064
|
+
this.pinnedToolNames = new Set(options.pinnedTools ?? []);
|
|
1065
|
+
this.excludeToolMatchers = (options.excludeTools ?? []).map(
|
|
1066
|
+
(pattern) => globToRegExp(pattern)
|
|
1067
|
+
);
|
|
1059
1068
|
this.index = new ToolIndex({
|
|
1060
1069
|
embedFn: options.embedFn,
|
|
1061
1070
|
keywordWeight: options.keywordWeight
|
|
@@ -1076,7 +1085,7 @@ var ToolRouter = class {
|
|
|
1076
1085
|
await this.ensureInitialized();
|
|
1077
1086
|
switch (this.strategy) {
|
|
1078
1087
|
case "search":
|
|
1079
|
-
return this.getMetaToolDefinitions();
|
|
1088
|
+
return [...this.getMetaToolDefinitions(), ...this.pinnedTools];
|
|
1080
1089
|
case "groups":
|
|
1081
1090
|
return this.getGroupFilteredTools();
|
|
1082
1091
|
case "all":
|
|
@@ -1203,8 +1212,11 @@ var ToolRouter = class {
|
|
|
1203
1212
|
/** Lazy initialization — fetches tools from all connected clients. */
|
|
1204
1213
|
async ensureInitialized() {
|
|
1205
1214
|
if (this.initialized) return;
|
|
1206
|
-
|
|
1207
|
-
|
|
1215
|
+
const fetchedTools = await this.fetchAllTools();
|
|
1216
|
+
this.allTools = fetchedTools.filter((tool) => !this.matchesExcludedTool(tool.name));
|
|
1217
|
+
this.pinnedTools = this.allTools.filter((tool) => this.matchesPinnedTool(tool.name));
|
|
1218
|
+
this.discoverableTools = this.allTools.filter((tool) => !this.matchesPinnedTool(tool.name));
|
|
1219
|
+
await this.index.buildIndex(this.discoverableTools);
|
|
1208
1220
|
this.buildGroups();
|
|
1209
1221
|
this.initialized = true;
|
|
1210
1222
|
}
|
|
@@ -1303,7 +1315,18 @@ var ToolRouter = class {
|
|
|
1303
1315
|
createExecuteToolDefinition()
|
|
1304
1316
|
];
|
|
1305
1317
|
}
|
|
1318
|
+
matchesPinnedTool(toolName) {
|
|
1319
|
+
return this.pinnedToolNames.has(toolName);
|
|
1320
|
+
}
|
|
1321
|
+
matchesExcludedTool(toolName) {
|
|
1322
|
+
return this.excludeToolMatchers.some((matcher) => matcher.test(toolName));
|
|
1323
|
+
}
|
|
1306
1324
|
};
|
|
1325
|
+
function globToRegExp(pattern) {
|
|
1326
|
+
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
1327
|
+
const regexPattern = `^${escaped.replace(/\*/g, ".*")}$`;
|
|
1328
|
+
return new RegExp(regexPattern);
|
|
1329
|
+
}
|
|
1307
1330
|
|
|
1308
1331
|
exports.AuthenticationError = AuthenticationError;
|
|
1309
1332
|
exports.ConfigurationError = ConfigurationError;
|