@mcp-use/client 2.2.3 → 2.2.4
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 +2 -2
- package/package.json +1 -1
- package/dist/.tsbuildinfo +0 -1
- package/dist/auth/browser.d.ts +0 -218
- package/dist/auth/browser.d.ts.map +0 -1
- package/dist/auth/callback.d.ts +0 -9
- package/dist/auth/callback.d.ts.map +0 -1
- package/dist/auth/flow.d.ts +0 -32
- package/dist/auth/flow.d.ts.map +0 -1
- package/dist/auth/node.d.ts +0 -212
- package/dist/auth/node.d.ts.map +0 -1
- package/dist/auth/popup.d.ts +0 -67
- package/dist/auth/popup.d.ts.map +0 -1
- package/dist/auth/session-store.d.ts +0 -125
- package/dist/auth/session-store.d.ts.map +0 -1
- package/dist/auth/storage-file.d.ts +0 -18
- package/dist/auth/storage-file.d.ts.map +0 -1
- package/dist/auth/storage.d.ts +0 -34
- package/dist/auth/storage.d.ts.map +0 -1
- package/dist/auth/url.d.ts +0 -17
- package/dist/auth/url.d.ts.map +0 -1
- package/dist/code-mode/connector.d.ts +0 -27
- package/dist/code-mode/connector.d.ts.map +0 -1
- package/dist/code-mode/executor-e2b.d.ts +0 -46
- package/dist/code-mode/executor-e2b.d.ts.map +0 -1
- package/dist/code-mode/executor-vm.d.ts +0 -39
- package/dist/code-mode/executor-vm.d.ts.map +0 -1
- package/dist/code-mode/executor.d.ts +0 -81
- package/dist/code-mode/executor.d.ts.map +0 -1
- package/dist/core/base.d.ts +0 -423
- package/dist/core/base.d.ts.map +0 -1
- package/dist/core/browser.d.ts +0 -32
- package/dist/core/browser.d.ts.map +0 -1
- package/dist/core/config.d.ts +0 -225
- package/dist/core/config.d.ts.map +0 -1
- package/dist/core/node.d.ts +0 -437
- package/dist/core/node.d.ts.map +0 -1
- package/dist/core/session.d.ts +0 -792
- package/dist/core/session.d.ts.map +0 -1
- package/dist/core/skills.d.ts +0 -47
- package/dist/core/skills.d.ts.map +0 -1
- package/dist/index-browser.d.ts +0 -26
- package/dist/index-browser.d.ts.map +0 -1
- package/dist/index-browser.js +0 -4767
- package/dist/index-browser.js.map +0 -1
- package/dist/index.d.ts +0 -23
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -6105
- package/dist/index.js.map +0 -1
- package/dist/react/McpClientProvider.d.ts +0 -254
- package/dist/react/McpClientProvider.d.ts.map +0 -1
- package/dist/react/index.d.ts +0 -39
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/index.js +0 -9444
- package/dist/react/index.js.map +0 -1
- package/dist/react/rpc-logger.d.ts +0 -47
- package/dist/react/rpc-logger.d.ts.map +0 -1
- package/dist/react/storage.d.ts +0 -98
- package/dist/react/storage.d.ts.map +0 -1
- package/dist/react/token-expiry.d.ts +0 -9
- package/dist/react/token-expiry.d.ts.map +0 -1
- package/dist/react/types.d.ts +0 -727
- package/dist/react/types.d.ts.map +0 -1
- package/dist/react/useMcp-helpers.d.ts +0 -99
- package/dist/react/useMcp-helpers.d.ts.map +0 -1
- package/dist/react/useMcp-operations.d.ts +0 -180
- package/dist/react/useMcp-operations.d.ts.map +0 -1
- package/dist/react/useMcp.d.ts +0 -48
- package/dist/react/useMcp.d.ts.map +0 -1
- package/dist/react/useMcpServerQueues.d.ts +0 -403
- package/dist/react/useMcpServerQueues.d.ts.map +0 -1
- package/dist/react/view/ViewRenderer.d.ts +0 -20
- package/dist/react/view/ViewRenderer.d.ts.map +0 -1
- package/dist/react/view/ext-apps-bridge.d.ts +0 -3
- package/dist/react/view/ext-apps-bridge.d.ts.map +0 -1
- package/dist/react/view/initialized-sync.d.ts +0 -13
- package/dist/react/view/initialized-sync.d.ts.map +0 -1
- package/dist/react/view/inject-openai-file-apis.d.ts +0 -9
- package/dist/react/view/inject-openai-file-apis.d.ts.map +0 -1
- package/dist/react/view/parse-custom-props.d.ts +0 -10
- package/dist/react/view/parse-custom-props.d.ts.map +0 -1
- package/dist/react/view/resolve-view-resource.d.ts +0 -22
- package/dist/react/view/resolve-view-resource.d.ts.map +0 -1
- package/dist/react/view/sandbox-blob-url.d.ts +0 -27
- package/dist/react/view/sandbox-blob-url.d.ts.map +0 -1
- package/dist/react/view/types.d.ts +0 -220
- package/dist/react/view/types.d.ts.map +0 -1
- package/dist/react/view/use-display-mode.d.ts +0 -19
- package/dist/react/view/use-display-mode.d.ts.map +0 -1
- package/dist/react/view/view-detection.d.ts +0 -22
- package/dist/react/view/view-detection.d.ts.map +0 -1
- package/dist/react/view/view-host-policy.d.ts +0 -61
- package/dist/react/view/view-host-policy.d.ts.map +0 -1
- package/dist/sandbox.d.ts +0 -2
- package/dist/sandbox.d.ts.map +0 -1
- package/dist/sandbox.js +0 -288
- package/dist/sandbox.js.map +0 -1
- package/dist/telemetry/client-telemetry.d.ts +0 -13
- package/dist/telemetry/client-telemetry.d.ts.map +0 -1
- package/dist/telemetry/configure-browser.d.ts +0 -2
- package/dist/telemetry/configure-browser.d.ts.map +0 -1
- package/dist/telemetry/configure-node.d.ts +0 -2
- package/dist/telemetry/configure-node.d.ts.map +0 -1
- package/dist/telemetry/connector-telemetry.d.ts +0 -8
- package/dist/telemetry/connector-telemetry.d.ts.map +0 -1
- package/dist/telemetry/events.d.ts +0 -91
- package/dist/telemetry/events.d.ts.map +0 -1
- package/dist/telemetry/index.d.ts +0 -3
- package/dist/telemetry/index.d.ts.map +0 -1
- package/dist/telemetry/tel-fetch.d.ts +0 -19
- package/dist/telemetry/tel-fetch.d.ts.map +0 -1
- package/dist/telemetry/telemetry-browser.d.ts +0 -6
- package/dist/telemetry/telemetry-browser.d.ts.map +0 -1
- package/dist/telemetry/telemetry-node.d.ts +0 -8
- package/dist/telemetry/telemetry-node.d.ts.map +0 -1
- package/dist/telemetry/telemetry.d.ts +0 -75
- package/dist/telemetry/telemetry.d.ts.map +0 -1
- package/dist/transport/base.d.ts +0 -656
- package/dist/transport/base.d.ts.map +0 -1
- package/dist/transport/connection-manager.d.ts +0 -59
- package/dist/transport/connection-manager.d.ts.map +0 -1
- package/dist/transport/http.d.ts +0 -137
- package/dist/transport/http.d.ts.map +0 -1
- package/dist/transport/stdio.d.ts +0 -97
- package/dist/transport/stdio.d.ts.map +0 -1
- package/dist/utils/elicitation.d.ts +0 -54
- package/dist/utils/elicitation.d.ts.map +0 -1
- package/dist/utils/favicon.d.ts +0 -6
- package/dist/utils/favicon.d.ts.map +0 -1
- package/dist/utils/json-schema-validator.d.ts +0 -13
- package/dist/utils/json-schema-validator.d.ts.map +0 -1
- package/dist/utils/logging.d.ts +0 -33
- package/dist/utils/logging.d.ts.map +0 -1
- package/dist/utils/version.d.ts +0 -9
- package/dist/utils/version.d.ts.map +0 -1
package/dist/core/config.d.ts
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import type { ElicitRequestFormParams, ElicitRequestURLParams, ElicitResult, Notification, AuthProvider, OAuthClientInformation, OAuthClientProvider, Root, RequestTypeMap, RequestOptions, ResultTypeMap, ClientOptions, VersionNegotiationMode } from "@modelcontextprotocol/client";
|
|
2
|
-
import type { BaseConnector, ConnectorInitOptions } from "../transport/base.js";
|
|
3
|
-
import type { ClientInfo } from "../transport/http.js";
|
|
4
|
-
import type { StdioStderrMode } from "../transport/stdio.js";
|
|
5
|
-
/** Parameters accepted by the MCP `sampling/createMessage` request. */
|
|
6
|
-
export type SamplingCreateMessageParams = RequestTypeMap["sampling/createMessage"]["params"];
|
|
7
|
-
/** Result returned for the MCP `sampling/createMessage` request. */
|
|
8
|
-
export type SamplingCreateMessageResult = ResultTypeMap["sampling/createMessage"];
|
|
9
|
-
/**
|
|
10
|
-
* Handles a sampling request initiated by an MCP server.
|
|
11
|
-
*
|
|
12
|
-
* @param params - Sampling request parameters supplied by the server.
|
|
13
|
-
* @returns The model-generated sampling result.
|
|
14
|
-
*/
|
|
15
|
-
export type OnSamplingCallback = (params: SamplingCreateMessageParams) => Promise<SamplingCreateMessageResult>;
|
|
16
|
-
/**
|
|
17
|
-
* Handles a form or URL elicitation request initiated by an MCP server.
|
|
18
|
-
*
|
|
19
|
-
* @param params - Elicitation request parameters supplied by the server.
|
|
20
|
-
* @returns The user's elicitation decision and optional content.
|
|
21
|
-
*/
|
|
22
|
-
export type OnElicitationCallback = (params: ElicitRequestFormParams | ElicitRequestURLParams) => Promise<ElicitResult>;
|
|
23
|
-
/**
|
|
24
|
-
* Handles a notification sent by an MCP server.
|
|
25
|
-
*
|
|
26
|
-
* @param notification - The notification envelope supplied by the server.
|
|
27
|
-
*/
|
|
28
|
-
export type OnNotificationCallback = (notification: Notification) => void | Promise<void>;
|
|
29
|
-
/**
|
|
30
|
-
* Callback options shared by per-server config and global defaults.
|
|
31
|
-
*/
|
|
32
|
-
export interface CallbackConfig {
|
|
33
|
-
/**
|
|
34
|
-
* Callback for sampling input.
|
|
35
|
-
*
|
|
36
|
-
* @deprecated Sampling is deprecated by the 2026 protocol. Retained for v1
|
|
37
|
-
* push requests and the v2 `input_required` compatibility window.
|
|
38
|
-
*/
|
|
39
|
-
onSampling?: OnSamplingCallback;
|
|
40
|
-
/** Callback for elicitation requests from servers. */
|
|
41
|
-
onElicitation?: OnElicitationCallback;
|
|
42
|
-
/** Callback for notifications from servers. */
|
|
43
|
-
onNotification?: OnNotificationCallback;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Resolves callback handlers, preferring per-server values over global values.
|
|
47
|
-
*
|
|
48
|
-
* @param perServer - Callback overrides for one server.
|
|
49
|
-
* @param globalDefaults - Fallback callbacks shared by all servers.
|
|
50
|
-
* @returns The effective callbacks for the server.
|
|
51
|
-
*/
|
|
52
|
-
export declare function resolveCallbacks(perServer: CallbackConfig | undefined, globalDefaults: CallbackConfig | undefined): {
|
|
53
|
-
/** Effective sampling callback. */
|
|
54
|
-
onSampling?: OnSamplingCallback;
|
|
55
|
-
/** Effective elicitation callback. */
|
|
56
|
-
onElicitation?: OnElicitationCallback;
|
|
57
|
-
/** Effective notification callback. */
|
|
58
|
-
onNotification?: OnNotificationCallback;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Base server configuration with common optional fields
|
|
62
|
-
*/
|
|
63
|
-
/** Options shared by HTTP and stdio server configurations. */
|
|
64
|
-
interface BaseServerConfig extends CallbackConfig {
|
|
65
|
-
/** Client identity advertised to the server. */
|
|
66
|
-
clientInfo?: ClientInfo;
|
|
67
|
-
/** Initial roots advertised to the server. */
|
|
68
|
-
roots?: Root[];
|
|
69
|
-
/** Options forwarded to the official MCP SDK Client. */
|
|
70
|
-
clientOptions?: ClientOptions;
|
|
71
|
-
/** Default timeout/cancellation options for requests. */
|
|
72
|
-
defaultRequestOptions?: RequestOptions;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Configures a local MCP server launched over standard input and output.
|
|
76
|
-
*/
|
|
77
|
-
export interface StdioServerConfig extends BaseServerConfig {
|
|
78
|
-
/** Executable used to start the server. */
|
|
79
|
-
command: string;
|
|
80
|
-
/** Arguments passed to {@link StdioServerConfig.command}. */
|
|
81
|
-
args: string[];
|
|
82
|
-
/** Environment variables merged with the current process environment. */
|
|
83
|
-
env?: Record<string, string>;
|
|
84
|
-
/** Working directory used to launch the server process. */
|
|
85
|
-
cwd?: string;
|
|
86
|
-
/**
|
|
87
|
-
* How the server process's standard error is handled. Defaults to `"pipe"`,
|
|
88
|
-
* which forwards it to the connector's `errlog`. Use `"inherit"` to give the
|
|
89
|
-
* child the parent's stderr file descriptor instead, preserving TTY
|
|
90
|
-
* detection and colorization, or `"ignore"` to discard it.
|
|
91
|
-
*/
|
|
92
|
-
stderr?: StdioStderrMode;
|
|
93
|
-
/**
|
|
94
|
-
* Protocol version negotiation mode. Defaults to `"legacy"` for stdio (the
|
|
95
|
-
* SDK advises against probing for spawn-per-invocation tools). See
|
|
96
|
-
* {@link StdioConnector}.
|
|
97
|
-
*/
|
|
98
|
-
protocolNegotiation?: VersionNegotiationMode;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Options forwarded to the platform `createOAuthProvider` when the client
|
|
102
|
-
* auto-provisions OAuth for an HTTP server. Platform-specific fields
|
|
103
|
-
* (e.g. Node `openBrowser`, browser `oauthProxyUrl`) are accepted and ignored
|
|
104
|
-
* by the other runtime.
|
|
105
|
-
*/
|
|
106
|
-
export interface AutoOAuthOptions {
|
|
107
|
-
/** Prefix used for persisted OAuth session keys. */
|
|
108
|
-
storageKeyPrefix?: string;
|
|
109
|
-
/** OAuth client display name. */
|
|
110
|
-
clientName?: string;
|
|
111
|
-
/** Public URL describing the OAuth client. */
|
|
112
|
-
clientUri?: string;
|
|
113
|
-
/** Public URL for the OAuth client logo. */
|
|
114
|
-
logoUri?: string;
|
|
115
|
-
/** OAuth redirect URI. The platform provider supplies a default when omitted. */
|
|
116
|
-
callbackUrl?: string;
|
|
117
|
-
/** URL of an OAuth Client ID Metadata Document. */
|
|
118
|
-
clientMetadataUrl?: string;
|
|
119
|
-
/** Space-delimited OAuth scopes to request. */
|
|
120
|
-
scope?: string;
|
|
121
|
-
/** Pre-registered public client id (skips DCR). */
|
|
122
|
-
staticClientInfo?: OAuthClientInformation;
|
|
123
|
-
/** Preferred Node loopback port. Defaults to `33418`. */
|
|
124
|
-
preferredPort?: number;
|
|
125
|
-
/** Number of Node loopback ports to try. Defaults to `10`. */
|
|
126
|
-
portRange?: number;
|
|
127
|
-
/** Node loopback callback timeout in milliseconds. Defaults to five minutes. */
|
|
128
|
-
authTimeoutMs?: number;
|
|
129
|
-
/** Node: override browser launch (CLI prints the URL instead). */
|
|
130
|
-
openBrowser?: (url: string) => void | Promise<void>;
|
|
131
|
-
/** Browser: wait for explicit authenticate() instead of auto popup. */
|
|
132
|
-
preventAutoAuth?: boolean;
|
|
133
|
-
/** Browser: full-page redirect instead of popup. */
|
|
134
|
-
useRedirectFlow?: boolean;
|
|
135
|
-
/** Browser: same-origin OAuth BFF base URL. */
|
|
136
|
-
oauthProxyUrl?: string;
|
|
137
|
-
/** Whether browser OAuth HTTP uses `oauthProxyUrl`. Defaults to `true` when the URL is set. */
|
|
138
|
-
proxyOAuthRequests?: boolean;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Configures a remote MCP server accessed with streamable HTTP.
|
|
142
|
-
*/
|
|
143
|
-
export interface HttpServerConfig extends BaseServerConfig {
|
|
144
|
-
/** MCP endpoint URL. */
|
|
145
|
-
url: string;
|
|
146
|
-
/** Headers included with MCP transport requests. */
|
|
147
|
-
headers?: Record<string, string>;
|
|
148
|
-
/** Fetch implementation used by the HTTP transport. */
|
|
149
|
-
fetch?: typeof fetch;
|
|
150
|
-
/** Bearer token added as the `Authorization` header. */
|
|
151
|
-
authToken?: string;
|
|
152
|
-
/** Connection timeout in milliseconds. */
|
|
153
|
-
timeout?: number;
|
|
154
|
-
/** OAuth provider used when the server requires authorization. */
|
|
155
|
-
authProvider?: AuthProvider | OAuthClientProvider;
|
|
156
|
-
/**
|
|
157
|
-
* Auto-OAuth options for HTTP servers.
|
|
158
|
-
* - omit / `{}`: client creates the platform provider on connect
|
|
159
|
-
* - `false`: disable auto-OAuth (e.g. CLI `--no-oauth`)
|
|
160
|
-
* - object: forwarded to `createOAuthProvider`
|
|
161
|
-
*
|
|
162
|
-
* Ignored when `authProvider` or `authToken` is set, or when `headers`
|
|
163
|
-
* already includes `Authorization`.
|
|
164
|
-
*/
|
|
165
|
-
oauth?: AutoOAuthOptions | false;
|
|
166
|
-
/**
|
|
167
|
-
* Detect mixed-auth servers after an anonymous connection by using the
|
|
168
|
-
* official SDK's RFC 9728 protected-resource metadata discovery.
|
|
169
|
-
* @defaultValue true
|
|
170
|
-
*/
|
|
171
|
-
detectMixedAuth?: boolean;
|
|
172
|
-
/**
|
|
173
|
-
* Protocol version negotiation mode. Defaults to `"auto"` to negotiate both
|
|
174
|
-
* v1 and v2 MCP servers. See {@link HttpConnector}.
|
|
175
|
-
*/
|
|
176
|
-
protocolNegotiation?: VersionNegotiationMode;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Tests whether the client should create an OAuth provider for an HTTP server.
|
|
180
|
-
*
|
|
181
|
-
* @param serverConfig - Server configuration to inspect.
|
|
182
|
-
* @returns `true` for an HTTP configuration without explicit authorization.
|
|
183
|
-
*/
|
|
184
|
-
export declare function shouldAutoProvisionOAuth(serverConfig: ServerConfig): serverConfig is HttpServerConfig;
|
|
185
|
-
/**
|
|
186
|
-
* Configuration for either a local stdio server or a remote HTTP server.
|
|
187
|
-
*/
|
|
188
|
-
export type ServerConfig = StdioServerConfig | HttpServerConfig;
|
|
189
|
-
/**
|
|
190
|
-
* Top-level MCP client configuration.
|
|
191
|
-
*
|
|
192
|
-
* Callback and client identity values act as defaults for individual servers.
|
|
193
|
-
*/
|
|
194
|
-
export interface MCPClientConfigShape extends CallbackConfig {
|
|
195
|
-
/** Default client identity for all servers; overridable per server. */
|
|
196
|
-
clientInfo?: ClientInfo;
|
|
197
|
-
/** Server configurations keyed by the name used in client methods. */
|
|
198
|
-
mcpServers?: Record<string, ServerConfig>;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Normalizes a client identity and fills optional metadata with package defaults.
|
|
202
|
-
*
|
|
203
|
-
* @param input - Candidate client identity.
|
|
204
|
-
* @returns The supplied identity merged with defaults, or the complete default
|
|
205
|
-
* identity when `input` does not contain both `name` and `version`.
|
|
206
|
-
*/
|
|
207
|
-
export declare function normalizeClientInfo(input: unknown): ClientInfo;
|
|
208
|
-
/**
|
|
209
|
-
* Expands the `capabilities.views` shorthand into the MCP Apps extension.
|
|
210
|
-
*
|
|
211
|
-
* @param clientOptions - SDK client options to normalize.
|
|
212
|
-
* @returns Normalized options, or `undefined` when no options were supplied.
|
|
213
|
-
*/
|
|
214
|
-
export declare function resolveClientOptions(clientOptions: ClientOptions | undefined): ClientOptions | undefined;
|
|
215
|
-
/**
|
|
216
|
-
* Creates an HTTP connector from a runtime-neutral server configuration.
|
|
217
|
-
*
|
|
218
|
-
* @param serverConfig - Server configuration to convert.
|
|
219
|
-
* @param connectorOptions - Connector options that override derived values.
|
|
220
|
-
* @returns An HTTP connector for the configured endpoint.
|
|
221
|
-
* @throws When `serverConfig` is a stdio configuration or has no recognized transport.
|
|
222
|
-
*/
|
|
223
|
-
export declare function createConnectorFromConfig(serverConfig: ServerConfig, connectorOptions?: Partial<ConnectorInitOptions>): BaseConnector;
|
|
224
|
-
export {};
|
|
225
|
-
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EACtB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,sBAAsB,EACtB,mBAAmB,EACnB,IAAI,EACJ,cAAc,EACd,cAAc,EACd,aAAa,EACb,aAAa,EACb,sBAAsB,EACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D,uEAAuE;AACvE,MAAM,MAAM,2BAA2B,GACrC,cAAc,CAAC,wBAAwB,CAAC,CAAC,QAAQ,CAAC,CAAC;AAErD,oEAAoE;AACpE,MAAM,MAAM,2BAA2B,GACrC,aAAa,CAAC,wBAAwB,CAAC,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAC/B,MAAM,EAAE,2BAA2B,KAChC,OAAO,CAAC,2BAA2B,CAAC,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAClC,MAAM,EAAE,uBAAuB,GAAG,sBAAsB,KACrD,OAAO,CAAC,YAAY,CAAC,CAAC;AAE3B;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,CACnC,YAAY,EAAE,YAAY,KACvB,IAAI,GAAG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E,MAAM,CAAC;IACjB,kEAAkE;IAClE,YAAY,CAAC,EAAE,YAAY,GAAG,mBAAmB,CAAC;IAClD;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,gBAAgB,GAAG,KAAK,CAAC;IACjC;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,sBAAsB,CAAC;CAC9C;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,YAAY,GACzB,YAAY,IAAI,gBAAgB,CAclC;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AAEhE;;;;GAIG;AACH,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,uEAAuE;IACvE,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CAC3C;AAqBD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAO9D;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,aAAa,GAAG,SAAS,CA0B3B;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,YAAY,EAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAC/C,aAAa,CA6Bf"}
|
package/dist/core/node.d.ts
DELETED
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
import type { ElicitRequestFormParams, ElicitRequestURLParams, ElicitResult, OAuthClientProvider } from "@modelcontextprotocol/client";
|
|
2
|
-
import { BaseMCPClient } from "./base.js";
|
|
3
|
-
import type { ExecutionResult, ToolSearchResponse } from "../code-mode/executor.js";
|
|
4
|
-
import { BaseCodeExecutor } from "../code-mode/executor.js";
|
|
5
|
-
import { type AutoOAuthOptions, type SamplingCreateMessageParams, type SamplingCreateMessageResult } from "./config.js";
|
|
6
|
-
import type { BaseConnector } from "../transport/base.js";
|
|
7
|
-
/** Read and parse a JSON MCP client config file. Node-only. */
|
|
8
|
-
export declare function loadConfigFile(filepath: string): Record<string, any>;
|
|
9
|
-
/**
|
|
10
|
-
* Custom function type for code execution in code mode.
|
|
11
|
-
* Allows providing a custom executor implementation.
|
|
12
|
-
*/
|
|
13
|
-
export type CodeExecutorFunction = (code: string, timeout?: number) => Promise<ExecutionResult>;
|
|
14
|
-
/**
|
|
15
|
-
* Built-in code executor types.
|
|
16
|
-
* - `"vm"`: Node.js VM-based executor (default, local execution)
|
|
17
|
-
* - `"e2b"`: E2B cloud sandbox executor (secure remote execution)
|
|
18
|
-
*/
|
|
19
|
-
export type CodeExecutorType = "vm" | "e2b";
|
|
20
|
-
/**
|
|
21
|
-
* Configuration options for the VM-based code executor.
|
|
22
|
-
*/
|
|
23
|
-
export interface VMExecutorOptions {
|
|
24
|
-
/** Maximum execution time in milliseconds. Default: 30000 (30 seconds) */
|
|
25
|
-
timeoutMs?: number;
|
|
26
|
-
/** Memory limit in megabytes. Default: undefined (no limit) */
|
|
27
|
-
memoryLimitMb?: number;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Configuration options for the E2B cloud sandbox executor.
|
|
31
|
-
*/
|
|
32
|
-
export interface E2BExecutorOptions {
|
|
33
|
-
/** E2B API key (required). Get one at https://e2b.dev */
|
|
34
|
-
apiKey: string;
|
|
35
|
-
/** Maximum execution time in milliseconds. Default: 300000 (5 minutes) */
|
|
36
|
-
timeoutMs?: number;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Union type for executor configuration options.
|
|
40
|
-
*/
|
|
41
|
-
export type ExecutorOptions = VMExecutorOptions | E2BExecutorOptions;
|
|
42
|
-
/**
|
|
43
|
-
* Advanced configuration for code execution mode.
|
|
44
|
-
*/
|
|
45
|
-
export interface CodeModeConfig {
|
|
46
|
-
/** Whether to enable code execution mode */
|
|
47
|
-
enabled: boolean;
|
|
48
|
-
/** Executor type or custom implementation. Defaults to "vm" */
|
|
49
|
-
executor?: CodeExecutorType | CodeExecutorFunction | BaseCodeExecutor;
|
|
50
|
-
/** Type-safe configuration options for the executor */
|
|
51
|
-
executorOptions?: ExecutorOptions;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Options for configuring MCPClient behavior.
|
|
55
|
-
*/
|
|
56
|
-
export interface MCPClientOptions {
|
|
57
|
-
/** Enable code execution mode (simple boolean or advanced configuration) */
|
|
58
|
-
codeMode?: boolean | CodeModeConfig;
|
|
59
|
-
/**
|
|
60
|
-
* Optional callback function to handle sampling requests from servers.
|
|
61
|
-
* When provided, the client will declare sampling capability and handle
|
|
62
|
-
* `sampling/createMessage` requests by calling this callback.
|
|
63
|
-
*
|
|
64
|
-
* @deprecated Sampling is deprecated by the 2026 protocol. Retained for v1
|
|
65
|
-
* push requests and v2 multi-round-trip compatibility.
|
|
66
|
-
*/
|
|
67
|
-
onSampling?: (params: SamplingCreateMessageParams) => Promise<SamplingCreateMessageResult>;
|
|
68
|
-
/**
|
|
69
|
-
* Optional callback function to handle elicitation requests from servers.
|
|
70
|
-
* When provided, the client will declare elicitation capability and handle
|
|
71
|
-
* `elicitation/create` requests by calling this callback.
|
|
72
|
-
*
|
|
73
|
-
* Elicitation allows servers to request additional information from users:
|
|
74
|
-
* - Form mode: Collect structured data with JSON schema validation
|
|
75
|
-
* - URL mode: Direct users to external URLs for sensitive interactions
|
|
76
|
-
*/
|
|
77
|
-
onElicitation?: (params: ElicitRequestFormParams | ElicitRequestURLParams) => Promise<ElicitResult>;
|
|
78
|
-
/**
|
|
79
|
-
* Optional callback function for server notifications.
|
|
80
|
-
* Applied as default when per-server config does not specify one.
|
|
81
|
-
*/
|
|
82
|
-
onNotification?: (notification: import("@modelcontextprotocol/client").Notification) => void | Promise<void>;
|
|
83
|
-
}
|
|
84
|
-
export { BaseCodeExecutor } from "../code-mode/executor.js";
|
|
85
|
-
export { E2BCodeExecutor } from "../code-mode/executor-e2b.js";
|
|
86
|
-
export { isVMAvailable, VMCodeExecutor } from "../code-mode/executor-vm.js";
|
|
87
|
-
export { accept, acceptWithDefaults, applyDefaults, cancel, decline, getDefaults, validate, } from "../utils/elicitation.js";
|
|
88
|
-
export type { ElicitContent, ElicitValidationResult, } from "../utils/elicitation.js";
|
|
89
|
-
export { MCPSession } from "./session.js";
|
|
90
|
-
export type { CallToolResult, MetaObject, Notification, Root, Tool, } from "./session.js";
|
|
91
|
-
/**
|
|
92
|
-
* Node.js-specific MCP client implementation with advanced features.
|
|
93
|
-
*
|
|
94
|
-
* The MCPClient class provides a complete MCP client implementation for Node.js
|
|
95
|
-
* environments, extending the runtime-neutral `BaseMCPClient` with platform-specific capabilities:
|
|
96
|
-
*
|
|
97
|
-
* - **All Connector Types**: Supports Stdio, HTTP, and WebSocket connectors
|
|
98
|
-
* - **Code Execution Mode**: Execute code dynamically using VM or E2B sandboxes
|
|
99
|
-
* - **File System Operations**: Load and save configurations from/to files
|
|
100
|
-
* - **Sampling & Elicitation**: Handle advanced MCP protocol features
|
|
101
|
-
* - **Session Management**: Create and manage multiple server connections
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* ```typescript
|
|
105
|
-
* // Basic usage with config file
|
|
106
|
-
* const client = new MCPClient('./mcp-config.json');
|
|
107
|
-
* const session = await client.createSession('my-server');
|
|
108
|
-
* const tools = await session.listTools();
|
|
109
|
-
* ```
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ```typescript
|
|
113
|
-
* // With inline configuration
|
|
114
|
-
* const client = new MCPClient({
|
|
115
|
-
* mcpServers: {
|
|
116
|
-
* 'filesystem': {
|
|
117
|
-
* command: 'npx',
|
|
118
|
-
* args: ['-y', '@modelcontextprotocol/server-filesystem', '/tmp']
|
|
119
|
-
* }
|
|
120
|
-
* }
|
|
121
|
-
* });
|
|
122
|
-
* ```
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```typescript
|
|
126
|
-
* // With code execution mode
|
|
127
|
-
* const client = new MCPClient('./config.json', {
|
|
128
|
-
* codeMode: {
|
|
129
|
-
* enabled: true,
|
|
130
|
-
* executor: 'e2b',
|
|
131
|
-
* executorOptions: { apiKey: process.env.E2B_API_KEY }
|
|
132
|
-
* }
|
|
133
|
-
* });
|
|
134
|
-
*
|
|
135
|
-
* const result = await client.executeCode('console.log("Hello!")');
|
|
136
|
-
* ```
|
|
137
|
-
*
|
|
138
|
-
* @see {@link MCPSession} for session management
|
|
139
|
-
*/
|
|
140
|
-
export declare class MCPClient extends BaseMCPClient {
|
|
141
|
-
/**
|
|
142
|
-
* Gets the mcp-use package version.
|
|
143
|
-
*
|
|
144
|
-
* This static method returns the version string of the installed mcp-use package,
|
|
145
|
-
* which is useful for debugging and compatibility checks.
|
|
146
|
-
*
|
|
147
|
-
* @returns The package version string (e.g., "1.13.2")
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
* ```typescript
|
|
151
|
-
* console.log(`mcp-use version: ${MCPClient.getPackageVersion()}`);
|
|
152
|
-
* ```
|
|
153
|
-
*/
|
|
154
|
-
static getPackageVersion(): string;
|
|
155
|
-
/**
|
|
156
|
-
* Indicates whether code execution mode is enabled.
|
|
157
|
-
*
|
|
158
|
-
* When true, the client provides special tools for executing code dynamically
|
|
159
|
-
* through the {@link executeCode} and {@link searchTools} methods.
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* ```typescript
|
|
163
|
-
* if (client.codeMode) {
|
|
164
|
-
* const result = await client.executeCode('return 2 + 2');
|
|
165
|
-
* console.log(result.output); // "4"
|
|
166
|
-
* }
|
|
167
|
-
* ```
|
|
168
|
-
*/
|
|
169
|
-
codeMode: boolean;
|
|
170
|
-
private _codeExecutor;
|
|
171
|
-
private _codeExecutorConfig;
|
|
172
|
-
private _executorOptions?;
|
|
173
|
-
private _globalCallbacks;
|
|
174
|
-
/**
|
|
175
|
-
* Creates a new MCPClient instance.
|
|
176
|
-
*
|
|
177
|
-
* The client can be initialized with either a configuration object, a path to
|
|
178
|
-
* a configuration file, or no configuration at all (servers can be added later
|
|
179
|
-
* using {@link addServer}).
|
|
180
|
-
*
|
|
181
|
-
* @param config - Configuration object or path to JSON config file. If omitted,
|
|
182
|
-
* starts with empty configuration
|
|
183
|
-
* @param options - Optional client behavior configuration
|
|
184
|
-
* Options can enable code mode or provide sampling and elicitation callbacks.
|
|
185
|
-
*
|
|
186
|
-
* @example
|
|
187
|
-
* ```typescript
|
|
188
|
-
* // From config file
|
|
189
|
-
* const client = new MCPClient('./mcp-config.json');
|
|
190
|
-
* ```
|
|
191
|
-
*
|
|
192
|
-
* @example
|
|
193
|
-
* ```typescript
|
|
194
|
-
* // From inline config
|
|
195
|
-
* const client = new MCPClient({
|
|
196
|
-
* mcpServers: {
|
|
197
|
-
* 'my-server': {
|
|
198
|
-
* command: 'node',
|
|
199
|
-
* args: ['server.js']
|
|
200
|
-
* }
|
|
201
|
-
* }
|
|
202
|
-
* });
|
|
203
|
-
* ```
|
|
204
|
-
*
|
|
205
|
-
* @example
|
|
206
|
-
* ```typescript
|
|
207
|
-
* // With code mode enabled
|
|
208
|
-
* const client = new MCPClient('./config.json', {
|
|
209
|
-
* codeMode: true
|
|
210
|
-
* });
|
|
211
|
-
* ```
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* ```typescript
|
|
215
|
-
* // With sampling callback
|
|
216
|
-
* const client = new MCPClient('./config.json', {
|
|
217
|
-
* onSampling: async (params) => {
|
|
218
|
-
* // Call your LLM here
|
|
219
|
-
* return anthropic.messages.create(params);
|
|
220
|
-
* }
|
|
221
|
-
* });
|
|
222
|
-
* ```
|
|
223
|
-
*
|
|
224
|
-
* @see {@link fromDict} for creating from config object (alternative syntax)
|
|
225
|
-
* @see {@link fromConfigFile} for creating from file (alternative syntax)
|
|
226
|
-
*/
|
|
227
|
-
constructor(config?: string | Record<string, any>, options?: MCPClientOptions);
|
|
228
|
-
/**
|
|
229
|
-
* Creates a client instance from a configuration dictionary.
|
|
230
|
-
*
|
|
231
|
-
* This static factory method provides an alternative syntax for creating
|
|
232
|
-
* a client from an inline configuration object.
|
|
233
|
-
*
|
|
234
|
-
* @param cfg - Configuration dictionary with server definitions
|
|
235
|
-
* @param options - Optional client behavior configuration
|
|
236
|
-
* @returns New MCPClient instance
|
|
237
|
-
*
|
|
238
|
-
* @example
|
|
239
|
-
* ```typescript
|
|
240
|
-
* const client = MCPClient.fromDict({
|
|
241
|
-
* mcpServers: {
|
|
242
|
-
* 'filesystem': {
|
|
243
|
-
* command: 'npx',
|
|
244
|
-
* args: ['-y', '@modelcontextprotocol/server-filesystem', '/tmp']
|
|
245
|
-
* }
|
|
246
|
-
* }
|
|
247
|
-
* });
|
|
248
|
-
* ```
|
|
249
|
-
*
|
|
250
|
-
* @see {@link MCPClient} for direct instantiation
|
|
251
|
-
* @see {@link fromConfigFile} for loading from file
|
|
252
|
-
*/
|
|
253
|
-
static fromDict(cfg: Record<string, any>, options?: MCPClientOptions): MCPClient;
|
|
254
|
-
/**
|
|
255
|
-
* Creates a client instance from a configuration file.
|
|
256
|
-
*
|
|
257
|
-
* This static factory method loads MCP server configurations from a JSON
|
|
258
|
-
* file and creates a new client instance.
|
|
259
|
-
*
|
|
260
|
-
* @param path - Path to the JSON configuration file
|
|
261
|
-
* @param options - Optional client behavior configuration
|
|
262
|
-
* @returns New MCPClient instance
|
|
263
|
-
* @throws If the file cannot be read or parsed
|
|
264
|
-
*
|
|
265
|
-
* @example
|
|
266
|
-
* ```typescript
|
|
267
|
-
* const client = MCPClient.fromConfigFile('./mcp-config.json');
|
|
268
|
-
* await client.createAllSessions();
|
|
269
|
-
* ```
|
|
270
|
-
*
|
|
271
|
-
* @example
|
|
272
|
-
* ```typescript
|
|
273
|
-
* // With code mode
|
|
274
|
-
* const client = MCPClient.fromConfigFile('./config.json', {
|
|
275
|
-
* codeMode: true
|
|
276
|
-
* });
|
|
277
|
-
* ```
|
|
278
|
-
*
|
|
279
|
-
* @see {@link MCPClient} for direct instantiation
|
|
280
|
-
* @see {@link fromDict} for inline configuration
|
|
281
|
-
*/
|
|
282
|
-
static fromConfigFile(path: string, options?: MCPClientOptions): MCPClient;
|
|
283
|
-
/**
|
|
284
|
-
* Saves the current configuration to a file.
|
|
285
|
-
*
|
|
286
|
-
* This Node.js-specific method writes the client's current configuration
|
|
287
|
-
* (including all server definitions) to a JSON file. The directory will be
|
|
288
|
-
* created if it doesn't exist.
|
|
289
|
-
*
|
|
290
|
-
* @param filepath - Path where the configuration file should be saved
|
|
291
|
-
*
|
|
292
|
-
* @example
|
|
293
|
-
* ```typescript
|
|
294
|
-
* const client = new MCPClient();
|
|
295
|
-
* client.addServer('my-server', {
|
|
296
|
-
* command: 'node',
|
|
297
|
-
* args: ['server.js']
|
|
298
|
-
* });
|
|
299
|
-
*
|
|
300
|
-
* // Save configuration for later use
|
|
301
|
-
* client.saveConfig('./mcp-config.json');
|
|
302
|
-
* ```
|
|
303
|
-
*
|
|
304
|
-
* @see {@link fromConfigFile} for loading configurations
|
|
305
|
-
*/
|
|
306
|
-
saveConfig(filepath: string): void;
|
|
307
|
-
protected createDefaultOAuthProvider(serverUrl: string, options?: AutoOAuthOptions): Promise<OAuthClientProvider>;
|
|
308
|
-
/**
|
|
309
|
-
* Create a connector from server configuration (Node.js version)
|
|
310
|
-
* Supports all connector types including StdioConnector (lazy-loaded to avoid pulling Node-only code into browser bundles).
|
|
311
|
-
*/
|
|
312
|
-
protected createConnectorFromConfig(serverConfig: Record<string, any>): Promise<BaseConnector>;
|
|
313
|
-
private _setupCodeModeConnector;
|
|
314
|
-
private _ensureCodeExecutor;
|
|
315
|
-
/**
|
|
316
|
-
* Executes JavaScript/TypeScript code in a sandboxed environment.
|
|
317
|
-
*
|
|
318
|
-
* This method is only available when code mode is enabled. It executes the
|
|
319
|
-
* provided code in an isolated environment (VM or E2B sandbox) and returns
|
|
320
|
-
* the results including stdout, stderr, and return value.
|
|
321
|
-
*
|
|
322
|
-
* @param code - JavaScript/TypeScript code to execute
|
|
323
|
-
* @param timeout - Optional execution timeout in milliseconds
|
|
324
|
-
* @returns Execution result with output, errors, and return value
|
|
325
|
-
* @throws If code mode is not enabled
|
|
326
|
-
*
|
|
327
|
-
* @example
|
|
328
|
-
* ```typescript
|
|
329
|
-
* const client = new MCPClient('./config.json', { codeMode: true });
|
|
330
|
-
*
|
|
331
|
-
* const result = await client.executeCode(`
|
|
332
|
-
* console.log('Hello, world!');
|
|
333
|
-
* return 2 + 2;
|
|
334
|
-
* `);
|
|
335
|
-
*
|
|
336
|
-
* console.log(result.stdout); // "Hello, world!\n"
|
|
337
|
-
* console.log(result.returnValue); // 4
|
|
338
|
-
* ```
|
|
339
|
-
*
|
|
340
|
-
* @example
|
|
341
|
-
* ```typescript
|
|
342
|
-
* // With timeout
|
|
343
|
-
* try {
|
|
344
|
-
* const result = await client.executeCode('while(true) {}', 1000);
|
|
345
|
-
* } catch (error) {
|
|
346
|
-
* console.log('Execution timed out');
|
|
347
|
-
* }
|
|
348
|
-
* ```
|
|
349
|
-
*
|
|
350
|
-
* @see {@link searchTools} for discovering available tools in code mode
|
|
351
|
-
*/
|
|
352
|
-
executeCode(code: string, timeout?: number): Promise<ExecutionResult>;
|
|
353
|
-
/**
|
|
354
|
-
* Searches for available tools across all MCP servers.
|
|
355
|
-
*
|
|
356
|
-
* This method is only available when code mode is enabled. It searches
|
|
357
|
-
* through tools from all active servers and returns matching tools based
|
|
358
|
-
* on the query and detail level.
|
|
359
|
-
*
|
|
360
|
-
* @param query - Optional search query to filter tools (defaults to empty string for all tools)
|
|
361
|
-
* @param detailLevel - Level of detail to return: "names", "descriptions", or "full"
|
|
362
|
-
* @returns Tool search results with matching tools
|
|
363
|
-
* @throws If code mode is not enabled
|
|
364
|
-
*
|
|
365
|
-
* @example
|
|
366
|
-
* ```typescript
|
|
367
|
-
* const client = new MCPClient('./config.json', { codeMode: true });
|
|
368
|
-
* await client.createAllSessions();
|
|
369
|
-
*
|
|
370
|
-
* // Search for all tools
|
|
371
|
-
* const allTools = await client.searchTools();
|
|
372
|
-
* console.log(`Found ${allTools.tools.length} tools`);
|
|
373
|
-
*
|
|
374
|
-
* // Search for specific tools
|
|
375
|
-
* const fileTools = await client.searchTools('file', 'descriptions');
|
|
376
|
-
* ```
|
|
377
|
-
*
|
|
378
|
-
* @see {@link executeCode} for executing code in code mode
|
|
379
|
-
*/
|
|
380
|
-
searchTools(query?: string, detailLevel?: "names" | "descriptions" | "full"): Promise<ToolSearchResponse>;
|
|
381
|
-
/**
|
|
382
|
-
* Gets the names of all configured MCP servers (excluding internal servers).
|
|
383
|
-
*
|
|
384
|
-
* This method overrides the base implementation to filter out internal
|
|
385
|
-
* meta-servers like the code mode server, which is an implementation detail
|
|
386
|
-
* not intended for direct user interaction.
|
|
387
|
-
*
|
|
388
|
-
* @returns Array of user-configured server names
|
|
389
|
-
*
|
|
390
|
-
* @example
|
|
391
|
-
* ```typescript
|
|
392
|
-
* const names = client.getServerNames();
|
|
393
|
-
* console.log(`User servers: ${names.join(', ')}`);
|
|
394
|
-
* // Note: 'code_mode' is excluded even if code mode is enabled
|
|
395
|
-
* ```
|
|
396
|
-
*
|
|
397
|
-
* @see {@link activeSessions} for servers with active sessions
|
|
398
|
-
*/
|
|
399
|
-
getServerNames(): string[];
|
|
400
|
-
/**
|
|
401
|
-
* Closes the client and cleans up all resources.
|
|
402
|
-
*
|
|
403
|
-
* This method performs a complete cleanup by:
|
|
404
|
-
* 1. Shutting down code executors (VM or E2B sandboxes)
|
|
405
|
-
* 2. Closing all active MCP sessions
|
|
406
|
-
* 3. Releasing any other held resources
|
|
407
|
-
*
|
|
408
|
-
* Always call this method when you're done with the client to ensure
|
|
409
|
-
* proper resource cleanup, especially when using E2B sandboxes which
|
|
410
|
-
* have associated costs.
|
|
411
|
-
*
|
|
412
|
-
* @example
|
|
413
|
-
* ```typescript
|
|
414
|
-
* const client = new MCPClient('./config.json', { codeMode: true });
|
|
415
|
-
* await client.createAllSessions();
|
|
416
|
-
*
|
|
417
|
-
* // Do work...
|
|
418
|
-
*
|
|
419
|
-
* // Clean up
|
|
420
|
-
* await client.close();
|
|
421
|
-
* ```
|
|
422
|
-
*
|
|
423
|
-
* @example
|
|
424
|
-
* ```typescript
|
|
425
|
-
* // Use in shutdown handler
|
|
426
|
-
* process.on('SIGINT', async () => {
|
|
427
|
-
* console.log('Shutting down...');
|
|
428
|
-
* await client.close();
|
|
429
|
-
* process.exit(0);
|
|
430
|
-
* });
|
|
431
|
-
* ```
|
|
432
|
-
*
|
|
433
|
-
* @see {@link closeAllSessions} for closing just the sessions
|
|
434
|
-
*/
|
|
435
|
-
close(): Promise<void>;
|
|
436
|
-
}
|
|
437
|
-
//# sourceMappingURL=node.d.ts.map
|
package/dist/core/node.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/core/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EACtB,YAAY,EACZ,mBAAmB,EACpB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,gBAAgB,EAEjB,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EAKL,KAAK,gBAAgB,EAGrB,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAEjC,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAM1D,+DAA+D;AAC/D,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAEpE;AAuBD;;;GAGG;AACH,MAAM,MAAM,oBAAo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