@mcp-ts/sdk 2.2.0 → 2.3.1

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.
Files changed (48) hide show
  1. package/dist/adapters/agui-adapter.d.mts +1 -1
  2. package/dist/adapters/agui-adapter.d.ts +1 -1
  3. package/dist/adapters/agui-adapter.js +9 -5
  4. package/dist/adapters/agui-adapter.js.map +1 -1
  5. package/dist/adapters/agui-adapter.mjs +9 -5
  6. package/dist/adapters/agui-adapter.mjs.map +1 -1
  7. package/dist/adapters/agui-middleware.d.mts +1 -1
  8. package/dist/adapters/agui-middleware.d.ts +1 -1
  9. package/dist/adapters/ai-adapter.d.mts +1 -1
  10. package/dist/adapters/ai-adapter.d.ts +1 -1
  11. package/dist/adapters/ai-adapter.js +9 -5
  12. package/dist/adapters/ai-adapter.js.map +1 -1
  13. package/dist/adapters/ai-adapter.mjs +9 -5
  14. package/dist/adapters/ai-adapter.mjs.map +1 -1
  15. package/dist/adapters/langchain-adapter.d.mts +1 -1
  16. package/dist/adapters/langchain-adapter.d.ts +1 -1
  17. package/dist/adapters/langchain-adapter.js +9 -5
  18. package/dist/adapters/langchain-adapter.js.map +1 -1
  19. package/dist/adapters/langchain-adapter.mjs +9 -5
  20. package/dist/adapters/langchain-adapter.mjs.map +1 -1
  21. package/dist/client/react.js.map +1 -1
  22. package/dist/client/react.mjs.map +1 -1
  23. package/dist/index.d.mts +2 -2
  24. package/dist/index.d.ts +2 -2
  25. package/dist/index.js +83 -6
  26. package/dist/index.js.map +1 -1
  27. package/dist/index.mjs +83 -7
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/server/index.d.mts +13 -1
  30. package/dist/server/index.d.ts +13 -1
  31. package/dist/server/index.js +66 -1
  32. package/dist/server/index.js.map +1 -1
  33. package/dist/server/index.mjs +66 -2
  34. package/dist/server/index.mjs.map +1 -1
  35. package/dist/shared/index.d.mts +2 -2
  36. package/dist/shared/index.d.ts +2 -2
  37. package/dist/shared/index.js +17 -5
  38. package/dist/shared/index.js.map +1 -1
  39. package/dist/shared/index.mjs +17 -5
  40. package/dist/shared/index.mjs.map +1 -1
  41. package/dist/{tool-router-C8hIA-tg.d.mts → tool-router-BfE_9tay.d.mts} +5 -0
  42. package/dist/{tool-router-CdX8e9bk.d.ts → tool-router-CP7qLk1J.d.ts} +5 -0
  43. package/package.json +1 -1
  44. package/src/server/index.ts +8 -1
  45. package/src/server/storage/index.ts +77 -2
  46. package/src/server/storage/types.ts +14 -0
  47. package/src/shared/meta-tools.ts +16 -7
  48. package/src/shared/tool-router.ts +13 -0
@@ -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-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';
5
+ import { d as ToolRouter } from '../tool-router-BfE_9tay.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-BfE_9tay.mjs';
7
7
  import { Tool, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
8
8
 
9
9
  /**
@@ -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-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';
5
+ import { d as ToolRouter } from '../tool-router-CP7qLk1J.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-CP7qLk1J.js';
7
7
  import { Tool, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
8
8
 
9
9
  /**
@@ -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
  }
@@ -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
  */