@mcp-ts/sdk 1.4.0 → 1.5.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.
- package/README.md +20 -27
- package/dist/adapters/agui-adapter.d.mts +16 -0
- package/dist/adapters/agui-adapter.d.ts +16 -0
- package/dist/adapters/agui-adapter.js +185 -0
- package/dist/adapters/agui-adapter.js.map +1 -1
- package/dist/adapters/agui-adapter.mjs +185 -0
- package/dist/adapters/agui-adapter.mjs.map +1 -1
- package/dist/adapters/agui-middleware.d.mts +2 -0
- package/dist/adapters/agui-middleware.d.ts +2 -0
- package/dist/adapters/agui-middleware.js.map +1 -1
- package/dist/adapters/agui-middleware.mjs.map +1 -1
- package/dist/adapters/ai-adapter.d.mts +21 -0
- package/dist/adapters/ai-adapter.d.ts +21 -0
- package/dist/adapters/ai-adapter.js +175 -0
- package/dist/adapters/ai-adapter.js.map +1 -1
- package/dist/adapters/ai-adapter.mjs +175 -0
- package/dist/adapters/ai-adapter.mjs.map +1 -1
- package/dist/adapters/langchain-adapter.d.mts +16 -0
- package/dist/adapters/langchain-adapter.d.ts +16 -0
- package/dist/adapters/langchain-adapter.js +179 -0
- package/dist/adapters/langchain-adapter.js.map +1 -1
- package/dist/adapters/langchain-adapter.mjs +179 -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 +94 -8
- package/dist/client/react.d.ts +94 -8
- package/dist/client/react.js +364 -26
- package/dist/client/react.js.map +1 -1
- package/dist/client/react.mjs +358 -27
- 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/client/vue.js +11 -2
- package/dist/client/vue.js.map +1 -1
- package/dist/client/vue.mjs +11 -2
- package/dist/client/vue.mjs.map +1 -1
- package/dist/{index-CQr9q0bF.d.mts → index-DcYfpY3H.d.mts} +1 -1
- package/dist/{index-nE_7Io0I.d.ts → index-GfC_eNEv.d.ts} +1 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +938 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +923 -13
- 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/server/index.js +58 -12
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +58 -12
- package/dist/server/index.mjs.map +1 -1
- package/dist/shared/index.d.mts +86 -4
- package/dist/shared/index.d.ts +86 -4
- package/dist/shared/index.js +874 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +865 -1
- package/dist/shared/index.mjs.map +1 -1
- package/dist/tool-router-Bo8qZbsD.d.ts +325 -0
- package/dist/tool-router-XnWVxPzv.d.mts +325 -0
- package/dist/{types-CW6lghof.d.mts → types-CfCoIsWI.d.mts} +27 -1
- package/dist/{types-CW6lghof.d.ts → types-CfCoIsWI.d.ts} +27 -1
- package/package.json +3 -2
- package/src/adapters/agui-adapter.ts +79 -0
- package/src/adapters/ai-adapter.ts +75 -0
- package/src/adapters/langchain-adapter.ts +74 -0
- package/src/client/react/index.ts +16 -0
- package/src/client/react/oauth-popup.tsx +446 -0
- package/src/client/react/use-mcp-apps.tsx +50 -32
- package/src/client/react/use-mcp.ts +36 -3
- package/src/client/vue/use-mcp.ts +38 -3
- package/src/server/handlers/sse-handler.ts +39 -0
- package/src/server/index.ts +2 -0
- package/src/server/mcp/oauth-client.ts +35 -15
- package/src/shared/index.ts +36 -0
- package/src/shared/meta-tools.ts +387 -0
- package/src/shared/schema-compressor.ts +124 -0
- package/src/shared/tool-index.ts +499 -0
- package/src/shared/tool-router.ts +469 -0
- package/src/shared/types.ts +30 -0
- package/supabase/migrations/20260421010000_add_session_cleanup_cron.sql +32 -0
package/dist/shared/index.d.mts
CHANGED
|
@@ -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 {
|
|
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,
|
|
5
|
-
import '
|
|
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
|
-
|
|
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 };
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -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 {
|
|
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,
|
|
5
|
-
import '
|
|
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
|
-
|
|
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 };
|