@mcp-ts/sdk 1.3.10 → 1.5.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.
Files changed (86) hide show
  1. package/README.md +20 -27
  2. package/dist/adapters/agui-adapter.d.mts +16 -0
  3. package/dist/adapters/agui-adapter.d.ts +16 -0
  4. package/dist/adapters/agui-adapter.js +185 -0
  5. package/dist/adapters/agui-adapter.js.map +1 -1
  6. package/dist/adapters/agui-adapter.mjs +185 -0
  7. package/dist/adapters/agui-adapter.mjs.map +1 -1
  8. package/dist/adapters/agui-middleware.d.mts +2 -0
  9. package/dist/adapters/agui-middleware.d.ts +2 -0
  10. package/dist/adapters/agui-middleware.js.map +1 -1
  11. package/dist/adapters/agui-middleware.mjs.map +1 -1
  12. package/dist/adapters/ai-adapter.d.mts +21 -0
  13. package/dist/adapters/ai-adapter.d.ts +21 -0
  14. package/dist/adapters/ai-adapter.js +175 -0
  15. package/dist/adapters/ai-adapter.js.map +1 -1
  16. package/dist/adapters/ai-adapter.mjs +175 -0
  17. package/dist/adapters/ai-adapter.mjs.map +1 -1
  18. package/dist/adapters/langchain-adapter.d.mts +16 -0
  19. package/dist/adapters/langchain-adapter.d.ts +16 -0
  20. package/dist/adapters/langchain-adapter.js +179 -0
  21. package/dist/adapters/langchain-adapter.js.map +1 -1
  22. package/dist/adapters/langchain-adapter.mjs +179 -0
  23. package/dist/adapters/langchain-adapter.mjs.map +1 -1
  24. package/dist/client/index.d.mts +4 -190
  25. package/dist/client/index.d.ts +4 -190
  26. package/dist/client/index.js +218 -54
  27. package/dist/client/index.js.map +1 -1
  28. package/dist/client/index.mjs +215 -55
  29. package/dist/client/index.mjs.map +1 -1
  30. package/dist/client/react.d.mts +31 -17
  31. package/dist/client/react.d.ts +31 -17
  32. package/dist/client/react.js +447 -103
  33. package/dist/client/react.js.map +1 -1
  34. package/dist/client/react.mjs +443 -105
  35. package/dist/client/react.mjs.map +1 -1
  36. package/dist/client/vue.d.mts +5 -4
  37. package/dist/client/vue.d.ts +5 -4
  38. package/dist/client/vue.js +239 -63
  39. package/dist/client/vue.js.map +1 -1
  40. package/dist/client/vue.mjs +236 -64
  41. package/dist/client/vue.mjs.map +1 -1
  42. package/dist/index-DcYfpY3H.d.mts +295 -0
  43. package/dist/index-GfC_eNEv.d.ts +295 -0
  44. package/dist/index.d.mts +5 -3
  45. package/dist/index.d.ts +5 -3
  46. package/dist/index.js +1120 -59
  47. package/dist/index.js.map +1 -1
  48. package/dist/index.mjs +1097 -60
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/server/index.d.mts +2 -2
  51. package/dist/server/index.d.ts +2 -2
  52. package/dist/server/index.js +18 -5
  53. package/dist/server/index.js.map +1 -1
  54. package/dist/server/index.mjs +18 -5
  55. package/dist/server/index.mjs.map +1 -1
  56. package/dist/shared/index.d.mts +86 -4
  57. package/dist/shared/index.d.ts +86 -4
  58. package/dist/shared/index.js +874 -0
  59. package/dist/shared/index.js.map +1 -1
  60. package/dist/shared/index.mjs +865 -1
  61. package/dist/shared/index.mjs.map +1 -1
  62. package/dist/tool-router-Bo8qZbsD.d.ts +325 -0
  63. package/dist/tool-router-XnWVxPzv.d.mts +325 -0
  64. package/dist/{types-CW6lghof.d.mts → types-CfCoIsWI.d.mts} +27 -1
  65. package/dist/{types-CW6lghof.d.ts → types-CfCoIsWI.d.ts} +27 -1
  66. package/package.json +15 -12
  67. package/src/adapters/agui-adapter.ts +79 -0
  68. package/src/adapters/ai-adapter.ts +75 -0
  69. package/src/adapters/langchain-adapter.ts +75 -1
  70. package/src/client/core/app-host.ts +252 -65
  71. package/src/client/core/constants.ts +30 -0
  72. package/src/client/index.ts +6 -1
  73. package/src/client/react/index.ts +3 -0
  74. package/src/client/react/use-app-host.ts +8 -15
  75. package/src/client/react/use-mcp-apps.tsx +262 -49
  76. package/src/client/react/use-mcp.ts +23 -12
  77. package/src/client/utils/app-host-utils.ts +62 -0
  78. package/src/client/vue/use-mcp.ts +23 -12
  79. package/src/server/index.ts +2 -0
  80. package/src/server/mcp/oauth-client.ts +34 -9
  81. package/src/shared/index.ts +36 -0
  82. package/src/shared/meta-tools.ts +387 -0
  83. package/src/shared/schema-compressor.ts +124 -0
  84. package/src/shared/tool-index.ts +499 -0
  85. package/src/shared/tool-router.ts +469 -0
  86. package/src/shared/types.ts +30 -0
@@ -1,8 +1,10 @@
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-0qmYrqoa.mjs';
3
- import { T as ToolInfo } from '../types-CW6lghof.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 ListPromptsResult, l as ListResourcesResult, m as ListToolsResponse, n as ListToolsRpcResult, M as McpRpcMethod, o as McpRpcParams, p as McpRpcRequest, q as McpRpcResponse, R as ReadResourceParams, r as RestoreSessionResult, S as SessionInfo, s as SessionListResult, t as SessionParams, u as TransportType, v as isCallToolSuccess, w as isConnectAuthRequired, x as isConnectError, y as isConnectSuccess, z as isListToolsSuccess } from '../types-CW6lghof.mjs';
5
- import '@modelcontextprotocol/sdk/types.js';
3
+ import { v as ToolInfo } from '../types-CfCoIsWI.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 ListPromptsResult, l as ListResourcesResult, m as ListToolsResponse, n as ListToolsRpcResult, M as McpRpcMethod, o as McpRpcParams, p as McpRpcRequest, q as McpRpcResponse, R as ReadResourceParams, r as RestoreSessionResult, 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-CfCoIsWI.mjs';
5
+ import { d as ToolRouter } from '../tool-router-XnWVxPzv.mjs';
6
+ export { C as CompactTool, a as CompressionStats, E as EmbedFn, I as IndexedTool, S as SchemaCompressor, T as ToolGroupInfo, b as ToolIndex, c as ToolIndexOptions, e as ToolRouterClientInput, f as ToolRouterOptions, g as ToolRouterStrategy, h as ToolSummary } from '../tool-router-XnWVxPzv.mjs';
7
+ import { Tool, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
6
8
 
7
9
  /**
8
10
  * Centralized constants for MCP Redis library
@@ -57,4 +59,84 @@ declare function findToolByName(connections: Array<{
57
59
  tools: ToolInfo[];
58
60
  }>, toolName: string): ToolInfo | undefined;
59
61
 
60
- export { 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, ToolInfo, type ToolUiConfig, findToolByName, getToolUiResourceUri };
62
+ /**
63
+ * Meta-tools — Injectable tool definitions that let the LLM discover and
64
+ * load MCP tools on-demand, following Anthropic's Tool Search pattern.
65
+ *
66
+ * Instead of injecting 50+ full tool schemas into the context window, you
67
+ * inject just these 4 meta-tools. The LLM calls them to find and load
68
+ * only the tools it actually needs.
69
+ *
70
+ * Meta-tools:
71
+ * • `mcp_search_tool_bm25` — BM25 natural language search
72
+ * • `mcp_search_tool_regex` — Regex pattern search
73
+ * • `mcp_get_tool_schema` — Get full inputSchema for a discovered tool
74
+ * • `mcp_execute_tool` — Execute a discovered tool
75
+ *
76
+ * @packageDocumentation
77
+ */
78
+
79
+ /**
80
+ * Creates the `mcp_search_tool_bm25` tool definition.
81
+ *
82
+ * This tool lets the LLM search the full catalog of available MCP tools
83
+ * using a BM25 natural-language query. Returns tool names and descriptions
84
+ * without the full inputSchema to save context space.
85
+ */
86
+ declare function createSearchToolDefinition(): Tool;
87
+ /**
88
+ * Creates the `mcp_search_tool_regex` tool definition.
89
+ *
90
+ * Matches Anthropic's tool_search_tool_regex exactly (takes a 'query' regex pattern).
91
+ */
92
+ declare function createRegexSearchToolDefinition(): Tool;
93
+ /**
94
+ * Creates the `mcp_get_tool_schema` tool definition.
95
+ *
96
+ * After discovering tools via `mcp_search_tool_bm25` or
97
+ * `mcp_search_tool_regex`, the LLM calls this to load the full
98
+ * inputSchema for a specific tool so it can construct the correct
99
+ * arguments.
100
+ */
101
+ declare function createGetSchemaToolDefinition(): Tool;
102
+ /**
103
+ * Creates the `mcp_execute_tool` tool definition.
104
+ *
105
+ * This is the execution meta-tool — the LLM calls this to execute any
106
+ * tool discovered via `mcp_search_tool_bm25` or `mcp_search_tool_regex`.
107
+ * The LLM should first call `mcp_get_tool_schema` to know the correct
108
+ * arguments.
109
+ *
110
+ * Instead of registering every real tool with the framework, we proxy
111
+ * all execution through a single meta-tool.
112
+ */
113
+ declare function createExecuteToolDefinition(): Tool;
114
+ /**
115
+ * Callback for executing a real MCP tool via the correct client.
116
+ * Provided by adapters that wire up client routing.
117
+ */
118
+ type CallToolFn = (toolName: string, args: Record<string, unknown>, namespace?: string) => Promise<any>;
119
+ /**
120
+ * Execute a meta-tool call and return the result in MCP CallToolResult format.
121
+ *
122
+ * @param toolName - One of the meta-tool names (mcp_search_tool_bm25, mcp_search_tool_regex, etc.)
123
+ * @param args - The arguments from the LLM's tool call
124
+ * @param router - The ToolRouter to query
125
+ * @param callToolFn - Optional callback for executing real tools (required for mcp_execute_tool)
126
+ * @returns MCP-compatible CallToolResult, or null if this isn't a meta-tool
127
+ */
128
+ declare function executeMetaTool(toolName: string, args: Record<string, unknown>, router: ToolRouter, callToolFn?: CallToolFn): Promise<CallToolResult | null>;
129
+ /** Check if a tool name is one of the meta-tools. */
130
+ declare function isMetaTool(toolName: string): boolean;
131
+ /**
132
+ * Unwraps a meta-tool proxy call (like mcp_execute_tool) to find the real target tool name and arguments.
133
+ * Also automatically strips routing prefixes like tool_{serverId}_.
134
+ *
135
+ * Useful for frontend components that need to determine the actual tool being executed by an AI agent.
136
+ */
137
+ declare function resolveMetaToolProxy(toolName: string, args: Record<string, unknown> | null | undefined): {
138
+ toolName: string;
139
+ args: Record<string, unknown>;
140
+ };
141
+
142
+ export { type 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, ToolInfo, ToolRouter, type ToolUiConfig, createExecuteToolDefinition, createGetSchemaToolDefinition, createRegexSearchToolDefinition, createSearchToolDefinition, executeMetaTool, findToolByName, getToolUiResourceUri, isMetaTool, resolveMetaToolProxy };
@@ -1,8 +1,10 @@
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-0qmYrqoa.js';
3
- import { T as ToolInfo } from '../types-CW6lghof.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 ListPromptsResult, l as ListResourcesResult, m as ListToolsResponse, n as ListToolsRpcResult, M as McpRpcMethod, o as McpRpcParams, p as McpRpcRequest, q as McpRpcResponse, R as ReadResourceParams, r as RestoreSessionResult, S as SessionInfo, s as SessionListResult, t as SessionParams, u as TransportType, v as isCallToolSuccess, w as isConnectAuthRequired, x as isConnectError, y as isConnectSuccess, z as isListToolsSuccess } from '../types-CW6lghof.js';
5
- import '@modelcontextprotocol/sdk/types.js';
3
+ import { v as ToolInfo } from '../types-CfCoIsWI.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 ListPromptsResult, l as ListResourcesResult, m as ListToolsResponse, n as ListToolsRpcResult, M as McpRpcMethod, o as McpRpcParams, p as McpRpcRequest, q as McpRpcResponse, R as ReadResourceParams, r as RestoreSessionResult, 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-CfCoIsWI.js';
5
+ import { d as ToolRouter } from '../tool-router-Bo8qZbsD.js';
6
+ export { C as CompactTool, a as CompressionStats, E as EmbedFn, I as IndexedTool, S as SchemaCompressor, T as ToolGroupInfo, b as ToolIndex, c as ToolIndexOptions, e as ToolRouterClientInput, f as ToolRouterOptions, g as ToolRouterStrategy, h as ToolSummary } from '../tool-router-Bo8qZbsD.js';
7
+ import { Tool, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
6
8
 
7
9
  /**
8
10
  * Centralized constants for MCP Redis library
@@ -57,4 +59,84 @@ declare function findToolByName(connections: Array<{
57
59
  tools: ToolInfo[];
58
60
  }>, toolName: string): ToolInfo | undefined;
59
61
 
60
- export { 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, ToolInfo, type ToolUiConfig, findToolByName, getToolUiResourceUri };
62
+ /**
63
+ * Meta-tools — Injectable tool definitions that let the LLM discover and
64
+ * load MCP tools on-demand, following Anthropic's Tool Search pattern.
65
+ *
66
+ * Instead of injecting 50+ full tool schemas into the context window, you
67
+ * inject just these 4 meta-tools. The LLM calls them to find and load
68
+ * only the tools it actually needs.
69
+ *
70
+ * Meta-tools:
71
+ * • `mcp_search_tool_bm25` — BM25 natural language search
72
+ * • `mcp_search_tool_regex` — Regex pattern search
73
+ * • `mcp_get_tool_schema` — Get full inputSchema for a discovered tool
74
+ * • `mcp_execute_tool` — Execute a discovered tool
75
+ *
76
+ * @packageDocumentation
77
+ */
78
+
79
+ /**
80
+ * Creates the `mcp_search_tool_bm25` tool definition.
81
+ *
82
+ * This tool lets the LLM search the full catalog of available MCP tools
83
+ * using a BM25 natural-language query. Returns tool names and descriptions
84
+ * without the full inputSchema to save context space.
85
+ */
86
+ declare function createSearchToolDefinition(): Tool;
87
+ /**
88
+ * Creates the `mcp_search_tool_regex` tool definition.
89
+ *
90
+ * Matches Anthropic's tool_search_tool_regex exactly (takes a 'query' regex pattern).
91
+ */
92
+ declare function createRegexSearchToolDefinition(): Tool;
93
+ /**
94
+ * Creates the `mcp_get_tool_schema` tool definition.
95
+ *
96
+ * After discovering tools via `mcp_search_tool_bm25` or
97
+ * `mcp_search_tool_regex`, the LLM calls this to load the full
98
+ * inputSchema for a specific tool so it can construct the correct
99
+ * arguments.
100
+ */
101
+ declare function createGetSchemaToolDefinition(): Tool;
102
+ /**
103
+ * Creates the `mcp_execute_tool` tool definition.
104
+ *
105
+ * This is the execution meta-tool — the LLM calls this to execute any
106
+ * tool discovered via `mcp_search_tool_bm25` or `mcp_search_tool_regex`.
107
+ * The LLM should first call `mcp_get_tool_schema` to know the correct
108
+ * arguments.
109
+ *
110
+ * Instead of registering every real tool with the framework, we proxy
111
+ * all execution through a single meta-tool.
112
+ */
113
+ declare function createExecuteToolDefinition(): Tool;
114
+ /**
115
+ * Callback for executing a real MCP tool via the correct client.
116
+ * Provided by adapters that wire up client routing.
117
+ */
118
+ type CallToolFn = (toolName: string, args: Record<string, unknown>, namespace?: string) => Promise<any>;
119
+ /**
120
+ * Execute a meta-tool call and return the result in MCP CallToolResult format.
121
+ *
122
+ * @param toolName - One of the meta-tool names (mcp_search_tool_bm25, mcp_search_tool_regex, etc.)
123
+ * @param args - The arguments from the LLM's tool call
124
+ * @param router - The ToolRouter to query
125
+ * @param callToolFn - Optional callback for executing real tools (required for mcp_execute_tool)
126
+ * @returns MCP-compatible CallToolResult, or null if this isn't a meta-tool
127
+ */
128
+ declare function executeMetaTool(toolName: string, args: Record<string, unknown>, router: ToolRouter, callToolFn?: CallToolFn): Promise<CallToolResult | null>;
129
+ /** Check if a tool name is one of the meta-tools. */
130
+ declare function isMetaTool(toolName: string): boolean;
131
+ /**
132
+ * Unwraps a meta-tool proxy call (like mcp_execute_tool) to find the real target tool name and arguments.
133
+ * Also automatically strips routing prefixes like tool_{serverId}_.
134
+ *
135
+ * Useful for frontend components that need to determine the actual tool being executed by an AI agent.
136
+ */
137
+ declare function resolveMetaToolProxy(toolName: string, args: Record<string, unknown> | null | undefined): {
138
+ toolName: string;
139
+ args: Record<string, unknown>;
140
+ };
141
+
142
+ export { type 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, ToolInfo, ToolRouter, type ToolUiConfig, createExecuteToolDefinition, createGetSchemaToolDefinition, createRegexSearchToolDefinition, createSearchToolDefinition, executeMetaTool, findToolByName, getToolUiResourceUri, isMetaTool, resolveMetaToolProxy };