@yourgpt/copilot-sdk 2.0.1 → 2.0.2-beta.2
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 +42 -0
- package/dist/{ThreadManager-JT0sqSSD.d.ts → ThreadManager-Dkp_eLty.d.ts} +1 -1
- package/dist/{ThreadManager-CUq5Ocu2.d.cts → ThreadManager-LfFRhr4e.d.cts} +1 -1
- package/dist/anthropic-6F5GRE3B.js +4 -0
- package/dist/anthropic-6F5GRE3B.js.map +1 -0
- package/dist/anthropic-DGalr_Fw.d.cts +17 -0
- package/dist/anthropic-DkCEDYOt.d.ts +17 -0
- package/dist/anthropic-NMTRABEH.cjs +21 -0
- package/dist/anthropic-NMTRABEH.cjs.map +1 -0
- package/dist/brave-DdnWb7Gb.d.cts +17 -0
- package/dist/brave-DsI9n7Wr.d.ts +17 -0
- package/dist/brave-OYKCOZEM.cjs +21 -0
- package/dist/brave-OYKCOZEM.cjs.map +1 -0
- package/dist/brave-XSASGGH2.js +4 -0
- package/dist/brave-XSASGGH2.js.map +1 -0
- package/dist/chunk-2FAWEBZS.cjs +88 -0
- package/dist/chunk-2FAWEBZS.cjs.map +1 -0
- package/dist/chunk-53UGJNHN.js +92 -0
- package/dist/chunk-53UGJNHN.js.map +1 -0
- package/dist/chunk-6T5XXJEP.cjs +80 -0
- package/dist/chunk-6T5XXJEP.cjs.map +1 -0
- package/dist/chunk-7K7HZMP4.cjs +1170 -0
- package/dist/chunk-7K7HZMP4.cjs.map +1 -0
- package/dist/chunk-7W7QLZNC.js +72 -0
- package/dist/chunk-7W7QLZNC.js.map +1 -0
- package/dist/{chunk-JM7PB2LP.js → chunk-7XFFRV7D.js} +10 -66
- package/dist/chunk-7XFFRV7D.js.map +1 -0
- package/dist/chunk-ASV6JLYG.cjs +99 -0
- package/dist/chunk-ASV6JLYG.cjs.map +1 -0
- package/dist/chunk-BH7MNDWW.js +1152 -0
- package/dist/chunk-BH7MNDWW.js.map +1 -0
- package/dist/chunk-BKO7DSPU.js +67 -0
- package/dist/chunk-BKO7DSPU.js.map +1 -0
- package/dist/chunk-CBAHCI4R.cjs +76 -0
- package/dist/chunk-CBAHCI4R.cjs.map +1 -0
- package/dist/chunk-CEKAYA2Q.cjs +74 -0
- package/dist/chunk-CEKAYA2Q.cjs.map +1 -0
- package/dist/chunk-CEOMTQTP.js +85 -0
- package/dist/chunk-CEOMTQTP.js.map +1 -0
- package/dist/chunk-DABZYCVX.js +84 -0
- package/dist/chunk-DABZYCVX.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +10 -0
- package/dist/chunk-DGUM43GV.js.map +1 -0
- package/dist/chunk-G4SF2PNQ.js +33 -0
- package/dist/chunk-G4SF2PNQ.js.map +1 -0
- package/dist/chunk-GANCV72Z.cjs +110 -0
- package/dist/chunk-GANCV72Z.cjs.map +1 -0
- package/dist/{chunk-BLSI67J6.cjs → chunk-H5XMKBBA.cjs} +425 -30
- package/dist/chunk-H5XMKBBA.cjs.map +1 -0
- package/dist/{chunk-CJ7UWN2Y.js → chunk-IXFV6AW6.js} +397 -7
- package/dist/chunk-IXFV6AW6.js.map +1 -0
- package/dist/chunk-JEQ2X3Z6.cjs +12 -0
- package/dist/chunk-JEQ2X3Z6.cjs.map +1 -0
- package/dist/chunk-JO4BHPAD.cjs +40 -0
- package/dist/chunk-JO4BHPAD.cjs.map +1 -0
- package/dist/chunk-MEBXW75C.cjs +89 -0
- package/dist/chunk-MEBXW75C.cjs.map +1 -0
- package/dist/chunk-MNDGIW47.js +76 -0
- package/dist/chunk-MNDGIW47.js.map +1 -0
- package/dist/chunk-PPFHA6IL.js +83 -0
- package/dist/chunk-PPFHA6IL.js.map +1 -0
- package/dist/chunk-RQ74USYU.js +128 -0
- package/dist/chunk-RQ74USYU.js.map +1 -0
- package/dist/chunk-TXLIY7GF.cjs +132 -0
- package/dist/chunk-TXLIY7GF.cjs.map +1 -0
- package/dist/chunk-UIWFYMAO.cjs +82 -0
- package/dist/chunk-UIWFYMAO.cjs.map +1 -0
- package/dist/{chunk-4PRWNAXQ.cjs → chunk-UOWLKFXK.cjs} +27 -89
- package/dist/chunk-UOWLKFXK.cjs.map +1 -0
- package/dist/chunk-VD74IPKB.js +106 -0
- package/dist/chunk-VD74IPKB.js.map +1 -0
- package/dist/chunk-W73FBYIH.cjs +87 -0
- package/dist/chunk-W73FBYIH.cjs.map +1 -0
- package/dist/chunk-XGITAEXU.js +93 -0
- package/dist/chunk-XGITAEXU.js.map +1 -0
- package/dist/chunk-XWOHNY3F.cjs +96 -0
- package/dist/chunk-XWOHNY3F.cjs.map +1 -0
- package/dist/chunk-ZPYQDMUX.js +79 -0
- package/dist/chunk-ZPYQDMUX.js.map +1 -0
- package/dist/core/index.cjs +156 -84
- package/dist/core/index.d.cts +16 -4
- package/dist/core/index.d.ts +16 -4
- package/dist/core/index.js +13 -1
- package/dist/exa-72KFY5A7.cjs +21 -0
- package/dist/exa-72KFY5A7.cjs.map +1 -0
- package/dist/exa-Dp9U-WTc.d.ts +17 -0
- package/dist/exa-NNVPBC2M.js +4 -0
- package/dist/exa-NNVPBC2M.js.map +1 -0
- package/dist/exa-jJSPhyUW.d.cts +17 -0
- package/dist/google-CHU2yycE.d.cts +17 -0
- package/dist/google-CTEK6SV2.js +4 -0
- package/dist/google-CTEK6SV2.js.map +1 -0
- package/dist/google-Da8IQxaI.d.ts +17 -0
- package/dist/google-IIUXFFVF.cjs +21 -0
- package/dist/google-IIUXFFVF.cjs.map +1 -0
- package/dist/index-2VtgKM8S.d.cts +206 -0
- package/dist/index-pWEH7pUE.d.ts +206 -0
- package/dist/mcp/index.cjs +670 -0
- package/dist/mcp/index.cjs.map +1 -0
- package/dist/mcp/index.d.cts +779 -0
- package/dist/mcp/index.d.ts +779 -0
- package/dist/mcp/index.js +574 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/openai-6KTCQ7PZ.cjs +21 -0
- package/dist/openai-6KTCQ7PZ.cjs.map +1 -0
- package/dist/openai-7W2PCNW5.js +4 -0
- package/dist/openai-7W2PCNW5.js.map +1 -0
- package/dist/openai-Cam8hF4f.d.ts +17 -0
- package/dist/openai-HVSCuXgO.d.cts +17 -0
- package/dist/react/index.cjs +75 -42
- package/dist/react/index.d.cts +270 -45
- package/dist/react/index.d.ts +270 -45
- package/dist/react/index.js +15 -2
- package/dist/searxng-AXLVGY7Z.js +4 -0
- package/dist/searxng-AXLVGY7Z.js.map +1 -0
- package/dist/searxng-EJKNY236.cjs +21 -0
- package/dist/searxng-EJKNY236.cjs.map +1 -0
- package/dist/searxng-K0qtY9vp.d.ts +17 -0
- package/dist/searxng-QGOte_Gq.d.cts +17 -0
- package/dist/serper-3JYJHJX6.js +4 -0
- package/dist/serper-3JYJHJX6.js.map +1 -0
- package/dist/serper-63FT4AOL.cjs +21 -0
- package/dist/serper-63FT4AOL.cjs.map +1 -0
- package/dist/serper-7Czya3PW.d.ts +17 -0
- package/dist/serper-JzdaSnS9.d.cts +17 -0
- package/dist/styles.css +38 -0
- package/dist/tavily-AWFP4RM7.cjs +21 -0
- package/dist/tavily-AWFP4RM7.cjs.map +1 -0
- package/dist/tavily-C8cXXojE.d.cts +17 -0
- package/dist/tavily-CIWAAZPH.js +4 -0
- package/dist/tavily-CIWAAZPH.js.map +1 -0
- package/dist/tavily-DdSGVgkE.d.ts +17 -0
- package/dist/themes/catppuccin.css +2 -0
- package/dist/themes/claude.css +2 -0
- package/dist/themes/linear.css +2 -0
- package/dist/themes/modern-minimal.css +2 -0
- package/dist/themes/posthog.css +2 -0
- package/dist/themes/supabase.css +2 -0
- package/dist/themes/twitter.css +2 -0
- package/dist/themes/vercel.css +2 -0
- package/dist/tools/anthropic/index.cjs +61 -0
- package/dist/tools/anthropic/index.cjs.map +1 -0
- package/dist/tools/anthropic/index.d.cts +67 -0
- package/dist/tools/anthropic/index.d.ts +67 -0
- package/dist/tools/anthropic/index.js +56 -0
- package/dist/tools/anthropic/index.js.map +1 -0
- package/dist/tools/brave/index.cjs +85 -0
- package/dist/tools/brave/index.cjs.map +1 -0
- package/dist/tools/brave/index.d.cts +91 -0
- package/dist/tools/brave/index.d.ts +91 -0
- package/dist/tools/brave/index.js +80 -0
- package/dist/tools/brave/index.js.map +1 -0
- package/dist/tools/exa/index.cjs +90 -0
- package/dist/tools/exa/index.cjs.map +1 -0
- package/dist/tools/exa/index.d.cts +92 -0
- package/dist/tools/exa/index.d.ts +92 -0
- package/dist/tools/exa/index.js +85 -0
- package/dist/tools/exa/index.js.map +1 -0
- package/dist/tools/google/index.cjs +81 -0
- package/dist/tools/google/index.cjs.map +1 -0
- package/dist/tools/google/index.d.cts +81 -0
- package/dist/tools/google/index.d.ts +81 -0
- package/dist/tools/google/index.js +76 -0
- package/dist/tools/google/index.js.map +1 -0
- package/dist/tools/openai/index.cjs +83 -0
- package/dist/tools/openai/index.cjs.map +1 -0
- package/dist/tools/openai/index.d.cts +84 -0
- package/dist/tools/openai/index.d.ts +84 -0
- package/dist/tools/openai/index.js +78 -0
- package/dist/tools/openai/index.js.map +1 -0
- package/dist/tools/searxng/index.cjs +85 -0
- package/dist/tools/searxng/index.cjs.map +1 -0
- package/dist/tools/searxng/index.d.cts +91 -0
- package/dist/tools/searxng/index.d.ts +91 -0
- package/dist/tools/searxng/index.js +80 -0
- package/dist/tools/searxng/index.js.map +1 -0
- package/dist/tools/serper/index.cjs +85 -0
- package/dist/tools/serper/index.cjs.map +1 -0
- package/dist/tools/serper/index.d.cts +91 -0
- package/dist/tools/serper/index.d.ts +91 -0
- package/dist/tools/serper/index.js +80 -0
- package/dist/tools/serper/index.js.map +1 -0
- package/dist/tools/tavily/index.cjs +91 -0
- package/dist/tools/tavily/index.cjs.map +1 -0
- package/dist/tools/tavily/index.d.cts +95 -0
- package/dist/tools/tavily/index.d.ts +95 -0
- package/dist/tools/tavily/index.js +86 -0
- package/dist/tools/tavily/index.js.map +1 -0
- package/dist/tools/web-search/index.cjs +31 -0
- package/dist/tools/web-search/index.cjs.map +1 -0
- package/dist/tools/web-search/index.d.cts +3 -0
- package/dist/tools/web-search/index.d.ts +3 -0
- package/dist/tools/web-search/index.js +14 -0
- package/dist/tools/web-search/index.js.map +1 -0
- package/dist/{types-BtAaOV07.d.cts → tools-DDWrco4h.d.cts} +43 -367
- package/dist/{types-BtAaOV07.d.ts → tools-DDWrco4h.d.ts} +43 -367
- package/dist/types-B20VCJXL.d.cts +347 -0
- package/dist/types-B20VCJXL.d.ts +347 -0
- package/dist/types-Cizh9K_f.d.ts +441 -0
- package/dist/types-DG2ya08y.d.cts +367 -0
- package/dist/types-DG2ya08y.d.ts +367 -0
- package/dist/types-DjSfYNKj.d.cts +441 -0
- package/dist/types-ZguuKEs_.d.cts +127 -0
- package/dist/types-ZguuKEs_.d.ts +127 -0
- package/dist/ui/index.cjs +1075 -148
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +410 -4
- package/dist/ui/index.d.ts +410 -4
- package/dist/ui/index.js +1007 -96
- package/dist/ui/index.js.map +1 -1
- package/package.json +52 -2
- package/dist/chunk-4PRWNAXQ.cjs.map +0 -1
- package/dist/chunk-BLSI67J6.cjs.map +0 -1
- package/dist/chunk-CJ7UWN2Y.js.map +0 -1
- package/dist/chunk-JM7PB2LP.js.map +0 -1
|
@@ -0,0 +1,779 @@
|
|
|
1
|
+
import { M as MCPClientConfig, a as MCPClientEvents, b as MCPClientState, c as MCPToolCallResult, d as MCPToolDefinition, e as MCPServerInfo, f as MCPServerCapabilities, g as MCPConnectionState, J as JsonRpcRequest, h as JsonRpcNotification, i as JsonRpcMessage, j as JsonRpcResponse, k as MCPClientInfo, l as MCPClientCapabilities, m as MCPInitializeParams, n as MCPToolCallParams } from '../types-Cizh9K_f.js';
|
|
2
|
+
export { I as JSON_RPC_ERROR_CODES, t as JsonRpcError, C as MCPElicitationOption, A as MCPElicitationRequest, B as MCPElicitationResponse, G as MCPError, q as MCPHttpTransportConfig, x as MCPImageContent, y as MCPResourceContent, r as MCPSSETransportConfig, s as MCPStdioTransportConfig, w as MCPTextContent, u as MCPToolInputSchema, v as MCPToolResultContent, p as MCPTransportConfig, o as MCPTransportType, z as MCPUIContent, H as MCP_PROTOCOL_VERSION, U as UseMCPClientConfig, D as UseMCPClientReturn, E as UseMCPToolsConfig, F as UseMCPToolsReturn } from '../types-Cizh9K_f.js';
|
|
3
|
+
import { T as ToolDefinition } from '../tools-DDWrco4h.js';
|
|
4
|
+
export { D as DEFAULT_MCP_UI_SANDBOX, f as MCPUIActionIntent, n as MCPUIFrameProps, d as MCPUIIntent, l as MCPUIIntentContext, k as MCPUIIntentHandler, i as MCPUILinkIntent, j as MCPUIMessage, h as MCPUINotifyIntent, g as MCPUIPromptIntent, M as MCPUIResource, a as MCPUIResourceContent, c as MCPUIResourceMetadata, b as MCPUIResourceMimeType, e as MCPUIToolIntent, R as RESTRICTED_MCP_UI_SANDBOX, U as UseMCPUIIntentsConfig, m as UseMCPUIIntentsReturn, p as isMCPUIIntent, q as isMCPUIMessage, o as isMCPUIResourceContent, r as parseMCPUIMessage } from '../types-B20VCJXL.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* MCP Client
|
|
8
|
+
*
|
|
9
|
+
* The core client class for connecting to MCP servers and managing
|
|
10
|
+
* tools, resources, and the connection lifecycle.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* MCP Client
|
|
15
|
+
*
|
|
16
|
+
* Provides a simple interface for connecting to MCP servers and using their tools.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const client = new MCPClient({
|
|
21
|
+
* name: "github",
|
|
22
|
+
* transport: "http",
|
|
23
|
+
* url: "https://mcp.github.com",
|
|
24
|
+
* headers: { Authorization: `Bearer ${token}` },
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* await client.connect();
|
|
28
|
+
* const tools = client.toToolDefinitions();
|
|
29
|
+
* const result = await client.callTool("create_issue", { title: "Bug" });
|
|
30
|
+
* await client.disconnect();
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
declare class MCPClient {
|
|
34
|
+
private config;
|
|
35
|
+
private transport?;
|
|
36
|
+
private rpcHandler;
|
|
37
|
+
private state;
|
|
38
|
+
private events;
|
|
39
|
+
private toolAdapter;
|
|
40
|
+
constructor(config: MCPClientConfig, events?: MCPClientEvents);
|
|
41
|
+
/**
|
|
42
|
+
* Get the current client state
|
|
43
|
+
*/
|
|
44
|
+
getState(): Readonly<MCPClientState>;
|
|
45
|
+
/**
|
|
46
|
+
* Get the client name
|
|
47
|
+
*/
|
|
48
|
+
getName(): string;
|
|
49
|
+
/**
|
|
50
|
+
* Check if client is connected
|
|
51
|
+
*/
|
|
52
|
+
isConnected(): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Connect to the MCP server
|
|
55
|
+
*/
|
|
56
|
+
connect(): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Disconnect from the MCP server
|
|
59
|
+
*/
|
|
60
|
+
disconnect(): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Call an MCP tool
|
|
63
|
+
*/
|
|
64
|
+
callTool(name: string, args?: Record<string, unknown>): Promise<MCPToolCallResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Refresh the list of available tools
|
|
67
|
+
*/
|
|
68
|
+
refreshTools(): Promise<MCPToolDefinition[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Convert MCP tools to ToolDefinition format for use with CopilotProvider
|
|
71
|
+
*/
|
|
72
|
+
toToolDefinitions(options?: {
|
|
73
|
+
prefixToolNames?: boolean;
|
|
74
|
+
serverLocation?: boolean;
|
|
75
|
+
}): ToolDefinition[];
|
|
76
|
+
/**
|
|
77
|
+
* Get the list of MCP tools
|
|
78
|
+
*/
|
|
79
|
+
getTools(): MCPToolDefinition[];
|
|
80
|
+
/**
|
|
81
|
+
* Get server info
|
|
82
|
+
*/
|
|
83
|
+
getServerInfo(): MCPServerInfo | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Get server capabilities
|
|
86
|
+
*/
|
|
87
|
+
getServerCapabilities(): MCPServerCapabilities | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Ping the server to check connectivity
|
|
90
|
+
*/
|
|
91
|
+
ping(): Promise<boolean>;
|
|
92
|
+
/**
|
|
93
|
+
* Create transport based on config
|
|
94
|
+
*/
|
|
95
|
+
private createTransport;
|
|
96
|
+
/**
|
|
97
|
+
* Perform MCP initialization handshake
|
|
98
|
+
*/
|
|
99
|
+
private initialize;
|
|
100
|
+
/**
|
|
101
|
+
* Send a JSON-RPC request and wait for response
|
|
102
|
+
*/
|
|
103
|
+
private request;
|
|
104
|
+
/**
|
|
105
|
+
* Send a JSON-RPC notification (no response expected)
|
|
106
|
+
*/
|
|
107
|
+
private notify;
|
|
108
|
+
/**
|
|
109
|
+
* Handle incoming JSON-RPC message
|
|
110
|
+
*/
|
|
111
|
+
private handleMessage;
|
|
112
|
+
/**
|
|
113
|
+
* Handle server notification
|
|
114
|
+
*/
|
|
115
|
+
private handleNotification;
|
|
116
|
+
/**
|
|
117
|
+
* Handle server-initiated request (e.g., elicitation)
|
|
118
|
+
*/
|
|
119
|
+
private handleServerRequest;
|
|
120
|
+
/**
|
|
121
|
+
* Handle transport error
|
|
122
|
+
*/
|
|
123
|
+
private handleError;
|
|
124
|
+
/**
|
|
125
|
+
* Handle transport close
|
|
126
|
+
*/
|
|
127
|
+
private handleClose;
|
|
128
|
+
/**
|
|
129
|
+
* Update connection state
|
|
130
|
+
*/
|
|
131
|
+
private setConnectionState;
|
|
132
|
+
/**
|
|
133
|
+
* Ensure client is connected
|
|
134
|
+
*/
|
|
135
|
+
private ensureConnected;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Create an MCP client
|
|
139
|
+
*
|
|
140
|
+
* Factory function for creating MCPClient instances.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const client = createMCPClient({
|
|
145
|
+
* name: "github",
|
|
146
|
+
* transport: "http",
|
|
147
|
+
* url: "https://mcp.github.com",
|
|
148
|
+
* });
|
|
149
|
+
*
|
|
150
|
+
* await client.connect();
|
|
151
|
+
* const tools = client.toToolDefinitions();
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
declare function createMCPClient(config: MCPClientConfig, events?: MCPClientEvents): MCPClient;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* MCP Client Manager configuration for a single client
|
|
158
|
+
*/
|
|
159
|
+
interface MCPManagedClientConfig extends MCPClientConfig {
|
|
160
|
+
/** Enable this client (default: true) */
|
|
161
|
+
enabled?: boolean;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* MCP Client Manager events
|
|
165
|
+
*/
|
|
166
|
+
interface MCPClientManagerEvents {
|
|
167
|
+
/** Called when any client's connection state changes */
|
|
168
|
+
onConnectionStateChange?: (clientName: string, state: MCPConnectionState) => void;
|
|
169
|
+
/** Called when any client's tools change */
|
|
170
|
+
onToolsChange?: (clientName: string, tools: MCPToolDefinition[]) => void;
|
|
171
|
+
/** Called when any client encounters an error */
|
|
172
|
+
onError?: (clientName: string, error: Error) => void;
|
|
173
|
+
/** Called when all clients are connected */
|
|
174
|
+
onAllConnected?: () => void;
|
|
175
|
+
/** Called when all clients are disconnected */
|
|
176
|
+
onAllDisconnected?: () => void;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Aggregated state for all managed clients
|
|
180
|
+
*/
|
|
181
|
+
interface MCPClientManagerState {
|
|
182
|
+
/** Individual client states */
|
|
183
|
+
clients: Record<string, MCPClientState>;
|
|
184
|
+
/** All tools from all connected clients */
|
|
185
|
+
allTools: MCPToolDefinition[];
|
|
186
|
+
/** Whether all enabled clients are connected */
|
|
187
|
+
allConnected: boolean;
|
|
188
|
+
/** Whether any client is connecting */
|
|
189
|
+
anyConnecting: boolean;
|
|
190
|
+
/** Whether any client has an error */
|
|
191
|
+
anyError: boolean;
|
|
192
|
+
/** Total number of tools across all clients */
|
|
193
|
+
totalToolCount: number;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* MCP Client Manager
|
|
197
|
+
*
|
|
198
|
+
* Manages multiple MCP client connections for scenarios where you need
|
|
199
|
+
* to connect to multiple MCP servers simultaneously.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```typescript
|
|
203
|
+
* const manager = new MCPClientManager([
|
|
204
|
+
* { name: "github", transport: "http", url: "https://mcp.github.com" },
|
|
205
|
+
* { name: "slack", transport: "http", url: "https://mcp.slack.com" },
|
|
206
|
+
* { name: "filesystem", transport: "stdio", command: "npx", args: ["-y", "@anthropic/filesystem-mcp-server"] },
|
|
207
|
+
* ]);
|
|
208
|
+
*
|
|
209
|
+
* await manager.connectAll();
|
|
210
|
+
*
|
|
211
|
+
* // Get all tools from all clients
|
|
212
|
+
* const tools = manager.getAllToolDefinitions();
|
|
213
|
+
*
|
|
214
|
+
* // Call a tool on a specific client
|
|
215
|
+
* const result = await manager.callTool("github", "create_issue", { title: "Bug" });
|
|
216
|
+
*
|
|
217
|
+
* await manager.disconnectAll();
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
declare class MCPClientManager {
|
|
221
|
+
private clients;
|
|
222
|
+
private configs;
|
|
223
|
+
private events;
|
|
224
|
+
constructor(configs: MCPManagedClientConfig[], events?: MCPClientManagerEvents);
|
|
225
|
+
/**
|
|
226
|
+
* Get the current aggregated state
|
|
227
|
+
*/
|
|
228
|
+
getState(): MCPClientManagerState;
|
|
229
|
+
/**
|
|
230
|
+
* Connect all enabled clients
|
|
231
|
+
*/
|
|
232
|
+
connectAll(): Promise<void>;
|
|
233
|
+
/**
|
|
234
|
+
* Connect a specific client
|
|
235
|
+
*/
|
|
236
|
+
connect(name: string): Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* Disconnect all clients
|
|
239
|
+
*/
|
|
240
|
+
disconnectAll(): Promise<void>;
|
|
241
|
+
/**
|
|
242
|
+
* Disconnect a specific client
|
|
243
|
+
*/
|
|
244
|
+
disconnect(name: string): Promise<void>;
|
|
245
|
+
/**
|
|
246
|
+
* Get a specific client
|
|
247
|
+
*/
|
|
248
|
+
getClient(name: string): MCPClient | undefined;
|
|
249
|
+
/**
|
|
250
|
+
* Get all connected clients
|
|
251
|
+
*/
|
|
252
|
+
getConnectedClients(): MCPClient[];
|
|
253
|
+
/**
|
|
254
|
+
* Get all tool definitions from all connected clients
|
|
255
|
+
*/
|
|
256
|
+
getAllToolDefinitions(options?: {
|
|
257
|
+
prefixToolNames?: boolean;
|
|
258
|
+
}): ToolDefinition[];
|
|
259
|
+
/**
|
|
260
|
+
* Get tool definitions from a specific client
|
|
261
|
+
*/
|
|
262
|
+
getToolDefinitions(name: string, options?: {
|
|
263
|
+
prefixToolNames?: boolean;
|
|
264
|
+
}): ToolDefinition[];
|
|
265
|
+
/**
|
|
266
|
+
* Call a tool on a specific client
|
|
267
|
+
*/
|
|
268
|
+
callTool(clientName: string, toolName: string, args?: Record<string, unknown>): Promise<MCPToolCallResult>;
|
|
269
|
+
/**
|
|
270
|
+
* Refresh tools for all connected clients
|
|
271
|
+
*/
|
|
272
|
+
refreshAllTools(): Promise<void>;
|
|
273
|
+
/**
|
|
274
|
+
* Check if a specific client is connected
|
|
275
|
+
*/
|
|
276
|
+
isConnected(name: string): boolean;
|
|
277
|
+
/**
|
|
278
|
+
* Create a client with event forwarding
|
|
279
|
+
*/
|
|
280
|
+
private createClient;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Create an MCP Client Manager
|
|
284
|
+
*/
|
|
285
|
+
declare function createMCPClientManager(configs: MCPManagedClientConfig[], events?: MCPClientManagerEvents): MCPClientManager;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* MCP Transport Types
|
|
289
|
+
*
|
|
290
|
+
* Defines the base transport interface and common types.
|
|
291
|
+
*/
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* MCP transport interface
|
|
295
|
+
*
|
|
296
|
+
* All transports (HTTP, SSE, stdio) must implement this interface.
|
|
297
|
+
*/
|
|
298
|
+
interface MCPTransport {
|
|
299
|
+
/**
|
|
300
|
+
* Connect the transport
|
|
301
|
+
*/
|
|
302
|
+
connect(): Promise<void>;
|
|
303
|
+
/**
|
|
304
|
+
* Disconnect the transport
|
|
305
|
+
*/
|
|
306
|
+
disconnect(): Promise<void>;
|
|
307
|
+
/**
|
|
308
|
+
* Send a JSON-RPC message
|
|
309
|
+
*/
|
|
310
|
+
send(message: JsonRpcRequest | JsonRpcNotification): Promise<void>;
|
|
311
|
+
/**
|
|
312
|
+
* Set message handler for incoming messages
|
|
313
|
+
*/
|
|
314
|
+
onMessage(handler: MessageHandler): void;
|
|
315
|
+
/**
|
|
316
|
+
* Set error handler
|
|
317
|
+
*/
|
|
318
|
+
onError(handler: ErrorHandler): void;
|
|
319
|
+
/**
|
|
320
|
+
* Set close handler
|
|
321
|
+
*/
|
|
322
|
+
onClose(handler: CloseHandler): void;
|
|
323
|
+
/**
|
|
324
|
+
* Check if transport is connected
|
|
325
|
+
*/
|
|
326
|
+
isConnected(): boolean;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Message handler callback
|
|
330
|
+
*/
|
|
331
|
+
type MessageHandler = (message: JsonRpcMessage) => void;
|
|
332
|
+
/**
|
|
333
|
+
* Error handler callback
|
|
334
|
+
*/
|
|
335
|
+
type ErrorHandler = (error: Error) => void;
|
|
336
|
+
/**
|
|
337
|
+
* Close handler callback
|
|
338
|
+
*/
|
|
339
|
+
type CloseHandler = () => void;
|
|
340
|
+
/**
|
|
341
|
+
* Base transport options
|
|
342
|
+
*/
|
|
343
|
+
interface TransportOptions {
|
|
344
|
+
/** Request timeout in milliseconds */
|
|
345
|
+
timeout?: number;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* HTTP transport options
|
|
349
|
+
*/
|
|
350
|
+
interface HttpTransportOptions extends TransportOptions {
|
|
351
|
+
/** Server URL */
|
|
352
|
+
url: string;
|
|
353
|
+
/** Custom headers */
|
|
354
|
+
headers?: Record<string, string>;
|
|
355
|
+
/** Session ID (managed internally) */
|
|
356
|
+
sessionId?: string;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* SSE transport options
|
|
360
|
+
*/
|
|
361
|
+
interface SSETransportOptions extends TransportOptions {
|
|
362
|
+
/** Server URL */
|
|
363
|
+
url: string;
|
|
364
|
+
/** Custom headers */
|
|
365
|
+
headers?: Record<string, string>;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Stdio transport options
|
|
369
|
+
*/
|
|
370
|
+
interface StdioTransportOptions extends TransportOptions {
|
|
371
|
+
/** Command to execute */
|
|
372
|
+
command: string;
|
|
373
|
+
/** Command arguments */
|
|
374
|
+
args?: string[];
|
|
375
|
+
/** Environment variables */
|
|
376
|
+
env?: Record<string, string>;
|
|
377
|
+
/** Working directory */
|
|
378
|
+
cwd?: string;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Abstract base transport class
|
|
382
|
+
*
|
|
383
|
+
* Provides common functionality for all transports.
|
|
384
|
+
*/
|
|
385
|
+
declare abstract class BaseTransport implements MCPTransport {
|
|
386
|
+
protected messageHandler?: MessageHandler;
|
|
387
|
+
protected errorHandler?: ErrorHandler;
|
|
388
|
+
protected closeHandler?: CloseHandler;
|
|
389
|
+
protected connected: boolean;
|
|
390
|
+
abstract connect(): Promise<void>;
|
|
391
|
+
abstract disconnect(): Promise<void>;
|
|
392
|
+
abstract send(message: JsonRpcRequest | JsonRpcNotification): Promise<void>;
|
|
393
|
+
onMessage(handler: MessageHandler): void;
|
|
394
|
+
onError(handler: ErrorHandler): void;
|
|
395
|
+
onClose(handler: CloseHandler): void;
|
|
396
|
+
isConnected(): boolean;
|
|
397
|
+
/**
|
|
398
|
+
* Emit a message to the handler
|
|
399
|
+
*/
|
|
400
|
+
protected emitMessage(message: JsonRpcMessage): void;
|
|
401
|
+
/**
|
|
402
|
+
* Emit an error to the handler
|
|
403
|
+
*/
|
|
404
|
+
protected emitError(error: Error): void;
|
|
405
|
+
/**
|
|
406
|
+
* Emit close event
|
|
407
|
+
*/
|
|
408
|
+
protected emitClose(): void;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* HTTP Streamable Transport for MCP
|
|
413
|
+
*
|
|
414
|
+
* Implements the HTTP Streamable transport as recommended by the MCP specification.
|
|
415
|
+
* This transport uses HTTP POST requests for sending messages and can handle
|
|
416
|
+
* streaming responses via SSE when needed.
|
|
417
|
+
*/
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* HTTP Streamable Transport
|
|
421
|
+
*
|
|
422
|
+
* The recommended transport for MCP over HTTP. Supports both request/response
|
|
423
|
+
* and server-initiated messages via SSE.
|
|
424
|
+
*/
|
|
425
|
+
declare class HttpTransport extends BaseTransport {
|
|
426
|
+
private url;
|
|
427
|
+
private headers;
|
|
428
|
+
private timeout;
|
|
429
|
+
private sessionId?;
|
|
430
|
+
private eventSource?;
|
|
431
|
+
private abortController?;
|
|
432
|
+
constructor(options: HttpTransportOptions);
|
|
433
|
+
/**
|
|
434
|
+
* Connect the HTTP transport
|
|
435
|
+
*
|
|
436
|
+
* For HTTP transport, "connecting" means verifying the endpoint is reachable.
|
|
437
|
+
* The actual session is established during the initialize handshake.
|
|
438
|
+
*/
|
|
439
|
+
connect(): Promise<void>;
|
|
440
|
+
/**
|
|
441
|
+
* Disconnect the HTTP transport
|
|
442
|
+
*/
|
|
443
|
+
disconnect(): Promise<void>;
|
|
444
|
+
/**
|
|
445
|
+
* Send a JSON-RPC message and handle the response
|
|
446
|
+
*/
|
|
447
|
+
send(message: JsonRpcRequest | JsonRpcNotification): Promise<void>;
|
|
448
|
+
/**
|
|
449
|
+
* Send an HTTP request
|
|
450
|
+
*/
|
|
451
|
+
private sendRequest;
|
|
452
|
+
/**
|
|
453
|
+
* Handle an SSE response stream
|
|
454
|
+
*/
|
|
455
|
+
private handleSSEResponse;
|
|
456
|
+
/**
|
|
457
|
+
* Parse response text into JSON-RPC messages
|
|
458
|
+
*/
|
|
459
|
+
private parseResponseText;
|
|
460
|
+
/**
|
|
461
|
+
* Validate a JSON-RPC message
|
|
462
|
+
*/
|
|
463
|
+
private isValidJsonRpcMessage;
|
|
464
|
+
/**
|
|
465
|
+
* Start listening for server-initiated events via SSE
|
|
466
|
+
*
|
|
467
|
+
* This is optional and used when the server supports server-initiated
|
|
468
|
+
* notifications (e.g., tools/list_changed).
|
|
469
|
+
*/
|
|
470
|
+
startEventStream(): void;
|
|
471
|
+
/**
|
|
472
|
+
* Stop the event stream
|
|
473
|
+
*/
|
|
474
|
+
stopEventStream(): void;
|
|
475
|
+
/**
|
|
476
|
+
* Get the current session ID
|
|
477
|
+
*/
|
|
478
|
+
getSessionId(): string | undefined;
|
|
479
|
+
/**
|
|
480
|
+
* Set the session ID (used after initialization)
|
|
481
|
+
*/
|
|
482
|
+
setSessionId(sessionId: string): void;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* SSE (Server-Sent Events) Transport for MCP
|
|
487
|
+
*
|
|
488
|
+
* Implements SSE transport for MCP servers that prefer server-push
|
|
489
|
+
* communication. Sends requests via HTTP POST and receives responses
|
|
490
|
+
* and notifications via SSE.
|
|
491
|
+
*/
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* SSE Transport
|
|
495
|
+
*
|
|
496
|
+
* Uses HTTP POST for sending requests and Server-Sent Events for
|
|
497
|
+
* receiving responses and server-initiated notifications.
|
|
498
|
+
*/
|
|
499
|
+
declare class SSETransport extends BaseTransport {
|
|
500
|
+
private url;
|
|
501
|
+
private headers;
|
|
502
|
+
private timeout;
|
|
503
|
+
private eventSource?;
|
|
504
|
+
private messageEndpoint?;
|
|
505
|
+
private sessionId?;
|
|
506
|
+
constructor(options: SSETransportOptions);
|
|
507
|
+
/**
|
|
508
|
+
* Connect to the SSE endpoint
|
|
509
|
+
*/
|
|
510
|
+
connect(): Promise<void>;
|
|
511
|
+
/**
|
|
512
|
+
* Disconnect from the SSE endpoint
|
|
513
|
+
*/
|
|
514
|
+
disconnect(): Promise<void>;
|
|
515
|
+
/**
|
|
516
|
+
* Send a JSON-RPC message via HTTP POST
|
|
517
|
+
*/
|
|
518
|
+
send(message: JsonRpcRequest | JsonRpcNotification): Promise<void>;
|
|
519
|
+
/**
|
|
520
|
+
* Handle an SSE message
|
|
521
|
+
*/
|
|
522
|
+
private handleSSEMessage;
|
|
523
|
+
/**
|
|
524
|
+
* Parse response text into JSON-RPC messages
|
|
525
|
+
*/
|
|
526
|
+
private parseResponseText;
|
|
527
|
+
/**
|
|
528
|
+
* Validate a JSON-RPC message
|
|
529
|
+
*/
|
|
530
|
+
private isValidJsonRpcMessage;
|
|
531
|
+
/**
|
|
532
|
+
* Get the current session ID
|
|
533
|
+
*/
|
|
534
|
+
getSessionId(): string | undefined;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Stdio Transport for MCP
|
|
539
|
+
*
|
|
540
|
+
* Implements stdio transport for local MCP servers.
|
|
541
|
+
* This transport spawns a child process and communicates via stdin/stdout.
|
|
542
|
+
*
|
|
543
|
+
* NOTE: This transport only works in Node.js environments (server-side).
|
|
544
|
+
* It will not work in browser environments.
|
|
545
|
+
*/
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Stdio Transport
|
|
549
|
+
*
|
|
550
|
+
* Spawns a local MCP server process and communicates via stdin/stdout
|
|
551
|
+
* using newline-delimited JSON.
|
|
552
|
+
*
|
|
553
|
+
* @example
|
|
554
|
+
* ```typescript
|
|
555
|
+
* const transport = new StdioTransport({
|
|
556
|
+
* command: "npx",
|
|
557
|
+
* args: ["-y", "@anthropic/filesystem-mcp-server", "/path/to/dir"],
|
|
558
|
+
* });
|
|
559
|
+
*
|
|
560
|
+
* await transport.connect();
|
|
561
|
+
* await transport.send({ jsonrpc: "2.0", method: "initialize", ... });
|
|
562
|
+
* ```
|
|
563
|
+
*/
|
|
564
|
+
declare class StdioTransport extends BaseTransport {
|
|
565
|
+
private command;
|
|
566
|
+
private args;
|
|
567
|
+
private env?;
|
|
568
|
+
private cwd?;
|
|
569
|
+
private process?;
|
|
570
|
+
private buffer;
|
|
571
|
+
private spawn?;
|
|
572
|
+
constructor(options: StdioTransportOptions);
|
|
573
|
+
/**
|
|
574
|
+
* Connect by spawning the MCP server process
|
|
575
|
+
*/
|
|
576
|
+
connect(): Promise<void>;
|
|
577
|
+
/**
|
|
578
|
+
* Disconnect by killing the process
|
|
579
|
+
*/
|
|
580
|
+
disconnect(): Promise<void>;
|
|
581
|
+
/**
|
|
582
|
+
* Send a JSON-RPC message via stdin
|
|
583
|
+
*/
|
|
584
|
+
send(message: JsonRpcRequest | JsonRpcNotification): Promise<void>;
|
|
585
|
+
/**
|
|
586
|
+
* Handle incoming data from stdout
|
|
587
|
+
*/
|
|
588
|
+
private handleData;
|
|
589
|
+
/**
|
|
590
|
+
* Validate a JSON-RPC message
|
|
591
|
+
*/
|
|
592
|
+
private isValidJsonRpcMessage;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* JSON-RPC 2.0 Handler for MCP
|
|
597
|
+
*
|
|
598
|
+
* Handles creation, parsing, and validation of JSON-RPC messages.
|
|
599
|
+
*/
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* JSON-RPC 2.0 Handler
|
|
603
|
+
*
|
|
604
|
+
* Manages request/response lifecycle, message creation, and parsing.
|
|
605
|
+
*/
|
|
606
|
+
declare class JsonRpcHandler {
|
|
607
|
+
private requestId;
|
|
608
|
+
private pendingRequests;
|
|
609
|
+
private defaultTimeout;
|
|
610
|
+
constructor(options?: {
|
|
611
|
+
timeout?: number;
|
|
612
|
+
});
|
|
613
|
+
/**
|
|
614
|
+
* Generate a unique request ID
|
|
615
|
+
*/
|
|
616
|
+
generateId(): string;
|
|
617
|
+
/**
|
|
618
|
+
* Create a JSON-RPC request
|
|
619
|
+
*/
|
|
620
|
+
createRequest(method: string, params?: Record<string, unknown>): JsonRpcRequest;
|
|
621
|
+
/**
|
|
622
|
+
* Create a JSON-RPC notification (no response expected)
|
|
623
|
+
*/
|
|
624
|
+
createNotification(method: string, params?: Record<string, unknown>): JsonRpcNotification;
|
|
625
|
+
/**
|
|
626
|
+
* Register a pending request and return a promise that resolves when response is received
|
|
627
|
+
*/
|
|
628
|
+
registerRequest(request: JsonRpcRequest, timeout?: number): Promise<unknown>;
|
|
629
|
+
/**
|
|
630
|
+
* Handle an incoming JSON-RPC response
|
|
631
|
+
*/
|
|
632
|
+
handleResponse(response: JsonRpcResponse): boolean;
|
|
633
|
+
/**
|
|
634
|
+
* Parse a JSON-RPC message from string
|
|
635
|
+
*/
|
|
636
|
+
parse(data: string): JsonRpcMessage;
|
|
637
|
+
/**
|
|
638
|
+
* Serialize a JSON-RPC message to string
|
|
639
|
+
*/
|
|
640
|
+
serialize(message: JsonRpcMessage): string;
|
|
641
|
+
/**
|
|
642
|
+
* Validate a JSON-RPC message
|
|
643
|
+
*/
|
|
644
|
+
isValidMessage(message: unknown): message is JsonRpcMessage;
|
|
645
|
+
/**
|
|
646
|
+
* Check if message is a request
|
|
647
|
+
*/
|
|
648
|
+
isRequest(message: JsonRpcMessage): message is JsonRpcRequest;
|
|
649
|
+
/**
|
|
650
|
+
* Check if message is a notification
|
|
651
|
+
*/
|
|
652
|
+
isNotification(message: JsonRpcMessage): message is JsonRpcNotification;
|
|
653
|
+
/**
|
|
654
|
+
* Check if message is a response
|
|
655
|
+
*/
|
|
656
|
+
isResponse(message: JsonRpcMessage): message is JsonRpcResponse;
|
|
657
|
+
/**
|
|
658
|
+
* Cancel all pending requests
|
|
659
|
+
*/
|
|
660
|
+
cancelAllPending(reason?: string): void;
|
|
661
|
+
/**
|
|
662
|
+
* Get number of pending requests
|
|
663
|
+
*/
|
|
664
|
+
getPendingCount(): number;
|
|
665
|
+
/**
|
|
666
|
+
* Check if a specific request is pending
|
|
667
|
+
*/
|
|
668
|
+
isPending(id: string | number): boolean;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
declare const MCP_METHODS: {
|
|
672
|
+
readonly INITIALIZE: "initialize";
|
|
673
|
+
readonly INITIALIZED: "notifications/initialized";
|
|
674
|
+
readonly PING: "ping";
|
|
675
|
+
readonly TOOLS_LIST: "tools/list";
|
|
676
|
+
readonly TOOLS_CALL: "tools/call";
|
|
677
|
+
readonly RESOURCES_LIST: "resources/list";
|
|
678
|
+
readonly RESOURCES_READ: "resources/read";
|
|
679
|
+
readonly RESOURCES_SUBSCRIBE: "resources/subscribe";
|
|
680
|
+
readonly RESOURCES_UNSUBSCRIBE: "resources/unsubscribe";
|
|
681
|
+
readonly PROMPTS_LIST: "prompts/list";
|
|
682
|
+
readonly PROMPTS_GET: "prompts/get";
|
|
683
|
+
readonly TOOLS_LIST_CHANGED: "notifications/tools/list_changed";
|
|
684
|
+
readonly RESOURCES_LIST_CHANGED: "notifications/resources/list_changed";
|
|
685
|
+
readonly RESOURCES_UPDATED: "notifications/resources/updated";
|
|
686
|
+
readonly PROMPTS_LIST_CHANGED: "notifications/prompts/list_changed";
|
|
687
|
+
readonly ELICITATION_REQUEST: "elicitation/request";
|
|
688
|
+
readonly ELICITATION_RESPONSE: "elicitation/response";
|
|
689
|
+
readonly LOGGING_SET_LEVEL: "logging/setLevel";
|
|
690
|
+
readonly LOGGING_MESSAGE: "notifications/message";
|
|
691
|
+
readonly CANCEL: "notifications/cancelled";
|
|
692
|
+
};
|
|
693
|
+
/**
|
|
694
|
+
* Default client info for YourGPT Copilot SDK
|
|
695
|
+
*/
|
|
696
|
+
declare const DEFAULT_CLIENT_INFO: MCPClientInfo;
|
|
697
|
+
/**
|
|
698
|
+
* Default client capabilities
|
|
699
|
+
*/
|
|
700
|
+
declare const DEFAULT_CLIENT_CAPABILITIES: MCPClientCapabilities;
|
|
701
|
+
/**
|
|
702
|
+
* Create initialize params
|
|
703
|
+
*/
|
|
704
|
+
declare function createInitializeParams(clientInfo?: Partial<MCPClientInfo>, capabilities?: MCPClientCapabilities): MCPInitializeParams;
|
|
705
|
+
/**
|
|
706
|
+
* Create tools/list params
|
|
707
|
+
*/
|
|
708
|
+
declare function createToolsListParams(cursor?: string): {
|
|
709
|
+
cursor?: string;
|
|
710
|
+
};
|
|
711
|
+
/**
|
|
712
|
+
* Create tools/call params
|
|
713
|
+
*/
|
|
714
|
+
declare function createToolCallParams(name: string, args?: Record<string, unknown>): MCPToolCallParams;
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* MCP Tool Adapter
|
|
718
|
+
*
|
|
719
|
+
* Converts MCP tool definitions to the SDK's ToolDefinition format.
|
|
720
|
+
*/
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Options for converting MCP tools to ToolDefinitions
|
|
724
|
+
*/
|
|
725
|
+
interface MCPToolAdapterOptions {
|
|
726
|
+
/** Prefix tool names with client name */
|
|
727
|
+
prefix?: boolean;
|
|
728
|
+
/** Register as server-side tool (default: true for MCP tools) */
|
|
729
|
+
asServerTool?: boolean;
|
|
730
|
+
/** Function to call the MCP tool */
|
|
731
|
+
callTool: (name: string, args?: Record<string, unknown>) => Promise<MCPToolCallResult>;
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* MCP Tool Adapter
|
|
735
|
+
*
|
|
736
|
+
* Handles conversion between MCP tool format and SDK ToolDefinition format.
|
|
737
|
+
*/
|
|
738
|
+
declare class MCPToolAdapter {
|
|
739
|
+
private clientName;
|
|
740
|
+
constructor(clientName: string);
|
|
741
|
+
/**
|
|
742
|
+
* Convert an MCP tool to a ToolDefinition
|
|
743
|
+
*/
|
|
744
|
+
toToolDefinition(mcpTool: MCPToolDefinition, options: MCPToolAdapterOptions): ToolDefinition;
|
|
745
|
+
/**
|
|
746
|
+
* Convert multiple MCP tools to ToolDefinitions
|
|
747
|
+
*/
|
|
748
|
+
toToolDefinitions(mcpTools: MCPToolDefinition[], options: MCPToolAdapterOptions): ToolDefinition[];
|
|
749
|
+
/**
|
|
750
|
+
* Convert MCP input schema to SDK ToolInputSchema
|
|
751
|
+
*/
|
|
752
|
+
private convertInputSchema;
|
|
753
|
+
/**
|
|
754
|
+
* Convert MCP schema properties to SDK JSONSchemaProperty format
|
|
755
|
+
*/
|
|
756
|
+
private convertProperties;
|
|
757
|
+
/**
|
|
758
|
+
* Convert a single MCP property to SDK format
|
|
759
|
+
*/
|
|
760
|
+
private convertProperty;
|
|
761
|
+
/**
|
|
762
|
+
* Convert MCP tool result to SDK ToolResponse
|
|
763
|
+
*/
|
|
764
|
+
private convertResult;
|
|
765
|
+
/**
|
|
766
|
+
* Format tool name as a readable title
|
|
767
|
+
*/
|
|
768
|
+
private formatToolTitle;
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Convert an MCP tool to a ToolDefinition (standalone function)
|
|
772
|
+
*/
|
|
773
|
+
declare function mcpToolToDefinition(clientName: string, mcpTool: MCPToolDefinition, options: MCPToolAdapterOptions): ToolDefinition;
|
|
774
|
+
/**
|
|
775
|
+
* Convert multiple MCP tools to ToolDefinitions (standalone function)
|
|
776
|
+
*/
|
|
777
|
+
declare function mcpToolsToDefinitions(clientName: string, mcpTools: MCPToolDefinition[], options: MCPToolAdapterOptions): ToolDefinition[];
|
|
778
|
+
|
|
779
|
+
export { BaseTransport, DEFAULT_CLIENT_CAPABILITIES, DEFAULT_CLIENT_INFO, HttpTransport, type HttpTransportOptions, JsonRpcHandler, JsonRpcMessage, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, MCPClient, MCPClientCapabilities, MCPClientConfig, MCPClientEvents, MCPClientInfo, MCPClientManager, type MCPClientManagerEvents, type MCPClientManagerState, MCPClientState, MCPConnectionState, type MCPManagedClientConfig, MCPServerCapabilities, MCPServerInfo, MCPToolAdapter, type MCPToolAdapterOptions, MCPToolCallParams, MCPToolCallResult, MCPToolDefinition, type MCPTransport, MCP_METHODS, SSETransport, type SSETransportOptions, StdioTransport, type StdioTransportOptions, createInitializeParams, createMCPClient, createMCPClientManager, createToolCallParams, createToolsListParams, mcpToolToDefinition, mcpToolsToDefinitions };
|