@mcp-use/client 2.2.4 → 2.2.5
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/dist/.tsbuildinfo +1 -0
- package/dist/auth/browser.d.ts +218 -0
- package/dist/auth/browser.d.ts.map +1 -0
- package/dist/auth/callback.d.ts +9 -0
- package/dist/auth/callback.d.ts.map +1 -0
- package/dist/auth/flow.d.ts +32 -0
- package/dist/auth/flow.d.ts.map +1 -0
- package/dist/auth/node.d.ts +212 -0
- package/dist/auth/node.d.ts.map +1 -0
- package/dist/auth/popup.d.ts +67 -0
- package/dist/auth/popup.d.ts.map +1 -0
- package/dist/auth/session-store.d.ts +125 -0
- package/dist/auth/session-store.d.ts.map +1 -0
- package/dist/auth/storage-file.d.ts +18 -0
- package/dist/auth/storage-file.d.ts.map +1 -0
- package/dist/auth/storage.d.ts +34 -0
- package/dist/auth/storage.d.ts.map +1 -0
- package/dist/auth/url.d.ts +17 -0
- package/dist/auth/url.d.ts.map +1 -0
- package/dist/code-mode/connector.d.ts +27 -0
- package/dist/code-mode/connector.d.ts.map +1 -0
- package/dist/code-mode/executor-e2b.d.ts +46 -0
- package/dist/code-mode/executor-e2b.d.ts.map +1 -0
- package/dist/code-mode/executor-vm.d.ts +39 -0
- package/dist/code-mode/executor-vm.d.ts.map +1 -0
- package/dist/code-mode/executor.d.ts +81 -0
- package/dist/code-mode/executor.d.ts.map +1 -0
- package/dist/core/base.d.ts +423 -0
- package/dist/core/base.d.ts.map +1 -0
- package/dist/core/browser.d.ts +32 -0
- package/dist/core/browser.d.ts.map +1 -0
- package/dist/core/config.d.ts +225 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/node.d.ts +437 -0
- package/dist/core/node.d.ts.map +1 -0
- package/dist/core/session.d.ts +792 -0
- package/dist/core/session.d.ts.map +1 -0
- package/dist/core/skills.d.ts +47 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/index-browser.d.ts +26 -0
- package/dist/index-browser.d.ts.map +1 -0
- package/dist/index-browser.js +4767 -0
- package/dist/index-browser.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6113 -0
- package/dist/index.js.map +1 -0
- package/dist/react/McpClientProvider.d.ts +254 -0
- package/dist/react/McpClientProvider.d.ts.map +1 -0
- package/dist/react/index.d.ts +39 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +9444 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/rpc-logger.d.ts +47 -0
- package/dist/react/rpc-logger.d.ts.map +1 -0
- package/dist/react/storage.d.ts +98 -0
- package/dist/react/storage.d.ts.map +1 -0
- package/dist/react/token-expiry.d.ts +9 -0
- package/dist/react/token-expiry.d.ts.map +1 -0
- package/dist/react/types.d.ts +727 -0
- package/dist/react/types.d.ts.map +1 -0
- package/dist/react/useMcp-helpers.d.ts +99 -0
- package/dist/react/useMcp-helpers.d.ts.map +1 -0
- package/dist/react/useMcp-operations.d.ts +180 -0
- package/dist/react/useMcp-operations.d.ts.map +1 -0
- package/dist/react/useMcp.d.ts +48 -0
- package/dist/react/useMcp.d.ts.map +1 -0
- package/dist/react/useMcpServerQueues.d.ts +403 -0
- package/dist/react/useMcpServerQueues.d.ts.map +1 -0
- package/dist/react/view/ViewRenderer.d.ts +20 -0
- package/dist/react/view/ViewRenderer.d.ts.map +1 -0
- package/dist/react/view/ext-apps-bridge.d.ts +3 -0
- package/dist/react/view/ext-apps-bridge.d.ts.map +1 -0
- package/dist/react/view/initialized-sync.d.ts +13 -0
- package/dist/react/view/initialized-sync.d.ts.map +1 -0
- package/dist/react/view/inject-openai-file-apis.d.ts +9 -0
- package/dist/react/view/inject-openai-file-apis.d.ts.map +1 -0
- package/dist/react/view/parse-custom-props.d.ts +10 -0
- package/dist/react/view/parse-custom-props.d.ts.map +1 -0
- package/dist/react/view/resolve-view-resource.d.ts +22 -0
- package/dist/react/view/resolve-view-resource.d.ts.map +1 -0
- package/dist/react/view/sandbox-blob-url.d.ts +27 -0
- package/dist/react/view/sandbox-blob-url.d.ts.map +1 -0
- package/dist/react/view/types.d.ts +220 -0
- package/dist/react/view/types.d.ts.map +1 -0
- package/dist/react/view/use-display-mode.d.ts +19 -0
- package/dist/react/view/use-display-mode.d.ts.map +1 -0
- package/dist/react/view/view-detection.d.ts +22 -0
- package/dist/react/view/view-detection.d.ts.map +1 -0
- package/dist/react/view/view-host-policy.d.ts +61 -0
- package/dist/react/view/view-host-policy.d.ts.map +1 -0
- package/dist/sandbox.d.ts +2 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/dist/sandbox.js +288 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/telemetry/client-telemetry.d.ts +13 -0
- package/dist/telemetry/client-telemetry.d.ts.map +1 -0
- package/dist/telemetry/configure-browser.d.ts +2 -0
- package/dist/telemetry/configure-browser.d.ts.map +1 -0
- package/dist/telemetry/configure-node.d.ts +2 -0
- package/dist/telemetry/configure-node.d.ts.map +1 -0
- package/dist/telemetry/connector-telemetry.d.ts +8 -0
- package/dist/telemetry/connector-telemetry.d.ts.map +1 -0
- package/dist/telemetry/events.d.ts +91 -0
- package/dist/telemetry/events.d.ts.map +1 -0
- package/dist/telemetry/index.d.ts +3 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/tel-fetch.d.ts +19 -0
- package/dist/telemetry/tel-fetch.d.ts.map +1 -0
- package/dist/telemetry/telemetry-browser.d.ts +6 -0
- package/dist/telemetry/telemetry-browser.d.ts.map +1 -0
- package/dist/telemetry/telemetry-node.d.ts +8 -0
- package/dist/telemetry/telemetry-node.d.ts.map +1 -0
- package/dist/telemetry/telemetry.d.ts +75 -0
- package/dist/telemetry/telemetry.d.ts.map +1 -0
- package/dist/transport/base.d.ts +656 -0
- package/dist/transport/base.d.ts.map +1 -0
- package/dist/transport/connection-manager.d.ts +59 -0
- package/dist/transport/connection-manager.d.ts.map +1 -0
- package/dist/transport/http.d.ts +137 -0
- package/dist/transport/http.d.ts.map +1 -0
- package/dist/transport/stdio.d.ts +97 -0
- package/dist/transport/stdio.d.ts.map +1 -0
- package/dist/utils/elicitation.d.ts +54 -0
- package/dist/utils/elicitation.d.ts.map +1 -0
- package/dist/utils/favicon.d.ts +6 -0
- package/dist/utils/favicon.d.ts.map +1 -0
- package/dist/utils/json-schema-validator.d.ts +13 -0
- package/dist/utils/json-schema-validator.d.ts.map +1 -0
- package/dist/utils/logging.d.ts +33 -0
- package/dist/utils/logging.d.ts.map +1 -0
- package/dist/utils/version.d.ts +9 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,727 @@
|
|
|
1
|
+
import type { ClientOptions, CompleteRequestParams, CompleteResult, ElicitRequestFormParams, ElicitRequestURLParams, ElicitResult, Notification, OAuthClientProvider, ProtocolEra, Transport, Prompt, Resource, ResourceTemplateType as ResourceTemplate, Tool, VersionNegotiationMode } from "@modelcontextprotocol/client";
|
|
2
|
+
import type { BaseMCPClient } from "../core/base.js";
|
|
3
|
+
import type { MCPAuthorizationInfo } from "../core/session.js";
|
|
4
|
+
import type { SamplingCreateMessageParams, SamplingCreateMessageResult } from "../core/config.js";
|
|
5
|
+
/** Proxy configuration for routing MCP traffic through a proxy server. */
|
|
6
|
+
export interface ProxyConfig {
|
|
7
|
+
/** Proxy server address (e.g. "http://localhost:3001/inspector/api/proxy"). */
|
|
8
|
+
proxyAddress?: string;
|
|
9
|
+
/** Additional headers to include in proxied requests. */
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use `headers` instead.
|
|
13
|
+
*/
|
|
14
|
+
customHeaders?: Record<string, string>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* SDK-level reconnection options for streamable HTTP transports.
|
|
18
|
+
* Controls the retry behavior of the underlying `StreamableHTTPClientTransport`.
|
|
19
|
+
*/
|
|
20
|
+
export type ReconnectionOptions = {
|
|
21
|
+
/** Maximum delay between reconnection attempts in ms (default: 30000) */
|
|
22
|
+
maxReconnectionDelay?: number;
|
|
23
|
+
/** Initial delay before first reconnection attempt in ms (default: 1000) */
|
|
24
|
+
initialReconnectionDelay?: number;
|
|
25
|
+
/** Multiplier applied to delay after each failed attempt (default: 1.5) */
|
|
26
|
+
reconnectionDelayGrowFactor?: number;
|
|
27
|
+
/** Maximum number of reconnection retries (default: 2) */
|
|
28
|
+
maxRetries?: number;
|
|
29
|
+
};
|
|
30
|
+
/** Configures the {@link useMcp} hook and its browser connection lifecycle. */
|
|
31
|
+
export type UseMcpOptions = {
|
|
32
|
+
/** The /sse URL of your remote MCP server */
|
|
33
|
+
url?: string;
|
|
34
|
+
/** Enable/disable the connection (similar to TanStack Query). When false, no connection will be attempted (default: true) */
|
|
35
|
+
enabled?: boolean;
|
|
36
|
+
/** Proxy configuration for routing through a proxy server */
|
|
37
|
+
proxyConfig?: ProxyConfig;
|
|
38
|
+
/**
|
|
39
|
+
* OAuth proxy base URL (e.g. `https://inspector.example.com/inspector/api/oauth`)
|
|
40
|
+
* used to route OAuth requests (`.well-known` discovery, DCR, token exchange)
|
|
41
|
+
* through a transparent server-side proxy — bypassing browser CORS against
|
|
42
|
+
* third-party identity providers — WITHOUT proxying MCP traffic itself.
|
|
43
|
+
*
|
|
44
|
+
* The proxy is transparent: it forwards requests and responses unmodified, so
|
|
45
|
+
* the SDK's authorization-server issuer validation (RFC 8414 §3.3) still
|
|
46
|
+
* passes. When omitted, the OAuth proxy URL is derived from
|
|
47
|
+
* `proxyConfig.proxyAddress` (replacing a trailing `/proxy` with `/oauth`),
|
|
48
|
+
* preserving the existing behavior for fully-proxied connections.
|
|
49
|
+
*/
|
|
50
|
+
oauthProxyUrl?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Connection policy for proxy routing.
|
|
53
|
+
* - `auto`: start direct and use `autoProxyFallback` after a qualifying failure
|
|
54
|
+
* - `direct`: never use `proxyConfig` and never fall back
|
|
55
|
+
* - `proxy`: use `proxyConfig` immediately and never fall back
|
|
56
|
+
*
|
|
57
|
+
* When omitted, `proxyConfig` retains its legacy immediate-proxy behavior,
|
|
58
|
+
* except when `autoProxyFallback` explicitly requests a direct-first attempt.
|
|
59
|
+
*/
|
|
60
|
+
connectionMode?: "auto" | "direct" | "proxy";
|
|
61
|
+
/**
|
|
62
|
+
* Enable automatic proxy fallback when direct connection fails
|
|
63
|
+
* When enabled, if a direct connection fails with FastMCP or CORS errors,
|
|
64
|
+
* automatically retries using the proxy configuration
|
|
65
|
+
*
|
|
66
|
+
* Can be:
|
|
67
|
+
* - `true`: Enable with `proxyConfig.proxyAddress`
|
|
68
|
+
* - `false`: Disable automatic fallback (default)
|
|
69
|
+
* - `{ enabled: boolean, proxyAddress?: string }`: Custom configuration
|
|
70
|
+
*
|
|
71
|
+
* @defaultValue false
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* // Use default proxy
|
|
76
|
+
* useMcp({ url: '...', autoProxyFallback: true })
|
|
77
|
+
*
|
|
78
|
+
* // Use custom proxy
|
|
79
|
+
* useMcp({
|
|
80
|
+
* url: '...',
|
|
81
|
+
* autoProxyFallback: {
|
|
82
|
+
* enabled: true,
|
|
83
|
+
* proxyAddress: 'https://my-proxy.com/api/proxy'
|
|
84
|
+
* }
|
|
85
|
+
* })
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
autoProxyFallback?: boolean | {
|
|
89
|
+
/** Whether fallback is enabled. */
|
|
90
|
+
enabled?: boolean;
|
|
91
|
+
/** Proxy endpoint used after a qualifying direct failure. */
|
|
92
|
+
proxyAddress?: string;
|
|
93
|
+
};
|
|
94
|
+
/** Custom callback URL for OAuth redirect (defaults to /oauth/callback on the current origin) */
|
|
95
|
+
callbackUrl?: string;
|
|
96
|
+
/** Storage key prefix for OAuth data in localStorage (defaults to "mcp:auth") */
|
|
97
|
+
storageKeyPrefix?: string;
|
|
98
|
+
/** Headers that can be used to bypass auth */
|
|
99
|
+
headers?: Record<string, string>;
|
|
100
|
+
/**
|
|
101
|
+
* Log level for console output.
|
|
102
|
+
* Set to 'silent' to suppress ALL console logging (the `mcp.log` state array is still populated).
|
|
103
|
+
* @defaultValue `"silent"`
|
|
104
|
+
*/
|
|
105
|
+
logLevel?: "silent" | "error" | "warn" | "info" | "http" | "verbose" | "debug" | "silly";
|
|
106
|
+
/** Auto retry connection if initial connection fails, with delay in ms (default: false) */
|
|
107
|
+
autoRetry?: boolean | number;
|
|
108
|
+
/**
|
|
109
|
+
* Auto reconnect if an established connection is lost.
|
|
110
|
+
*
|
|
111
|
+
* Can be:
|
|
112
|
+
* - `boolean`: Enable/disable with default 3000ms delay and 10s health check
|
|
113
|
+
* - `number`: Reconnect delay in ms (enables health checks with defaults)
|
|
114
|
+
* - `object`: Full configuration for reconnection and health checks
|
|
115
|
+
*
|
|
116
|
+
* @defaultValue `true` with a 3000 ms initial delay
|
|
117
|
+
*/
|
|
118
|
+
autoReconnect?: boolean | number | {
|
|
119
|
+
/** Whether to enable automatic reconnection (default: true) */
|
|
120
|
+
enabled?: boolean;
|
|
121
|
+
/** Delay in ms before reconnection attempt (default: 3000) */
|
|
122
|
+
initialDelay?: number;
|
|
123
|
+
/**
|
|
124
|
+
* Interval in ms for health check polling via HEAD requests.
|
|
125
|
+
* Set to `false` to disable health checks entirely.
|
|
126
|
+
* @defaultValue `10000`
|
|
127
|
+
*/
|
|
128
|
+
healthCheckInterval?: number | false;
|
|
129
|
+
/**
|
|
130
|
+
* Time in ms without a successful health check before triggering reconnect.
|
|
131
|
+
* @defaultValue `30000`
|
|
132
|
+
*/
|
|
133
|
+
healthCheckTimeout?: number;
|
|
134
|
+
};
|
|
135
|
+
/** SDK-level reconnection options for the streamable HTTP transport */
|
|
136
|
+
reconnectionOptions?: ReconnectionOptions;
|
|
137
|
+
/** Popup window features string (dimensions and behavior) for OAuth */
|
|
138
|
+
popupFeatures?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Prevent automatic authentication popup/redirect on initial connection (default: true)
|
|
141
|
+
* When true, the connection will enter 'pending_auth' state and wait for user to call authenticate()
|
|
142
|
+
* Set to true to show a modal/button before triggering OAuth instead of auto-redirecting
|
|
143
|
+
*/
|
|
144
|
+
preventAutoAuth?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Detect OAuth protected-resource metadata after an anonymous connection so
|
|
147
|
+
* mixed-auth servers can offer optional authentication without blocking use.
|
|
148
|
+
* @defaultValue true
|
|
149
|
+
*/
|
|
150
|
+
detectMixedAuth?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Use full-page redirect for OAuth instead of popup window (default: false)
|
|
153
|
+
* Redirect flow avoids popup blockers and provides better UX on mobile.
|
|
154
|
+
* Set to true to use redirect flow instead of popup.
|
|
155
|
+
*/
|
|
156
|
+
useRedirectFlow?: boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Callback function that is invoked just before the authentication popup window is opened.
|
|
159
|
+
* Only used when useRedirectFlow is false (popup mode).
|
|
160
|
+
* @param url - The URL that will be opened in the popup.
|
|
161
|
+
* @param features - The features string for the popup window.
|
|
162
|
+
*/
|
|
163
|
+
onPopupWindow?: (url: string, features: string, window: globalThis.Window | null) => void;
|
|
164
|
+
/**
|
|
165
|
+
* Additional client options passed to the underlying MCP SDK Client.
|
|
166
|
+
* Use `capabilities.views: true` as shorthand for the MCP Apps UI extension,
|
|
167
|
+
* or set `capabilities.extensions` directly.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* useMcp({
|
|
172
|
+
* url: '...',
|
|
173
|
+
* clientOptions: {
|
|
174
|
+
* capabilities: {
|
|
175
|
+
* views: true,
|
|
176
|
+
* },
|
|
177
|
+
* },
|
|
178
|
+
* })
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
clientOptions?: Omit<ClientOptions, "capabilities"> & {
|
|
182
|
+
/** MCP capabilities advertised by the underlying SDK client. */
|
|
183
|
+
capabilities?: NonNullable<ClientOptions["capabilities"]> & {
|
|
184
|
+
/** Whether to advertise the MCP Apps UI extension shorthand. */
|
|
185
|
+
views?: boolean;
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Protocol version negotiation mode passed to the underlying SDK `Client`.
|
|
190
|
+
* - `"auto"` (default): probe with `server/discover` to detect modern (2026-07-28)
|
|
191
|
+
* servers, falling back to the 2025 handshake against legacy servers.
|
|
192
|
+
* - `"legacy"`: classic 2025 `initialize` handshake, no probe.
|
|
193
|
+
* - `{ pin: "2026-07-28" }`: modern era only, no fallback.
|
|
194
|
+
*/
|
|
195
|
+
protocolNegotiation?: VersionNegotiationMode;
|
|
196
|
+
/** Connection timeout in milliseconds for establishing initial connection (default: 30000 / 30 seconds) */
|
|
197
|
+
timeout?: number;
|
|
198
|
+
/** Optional callback to wrap the transport before passing it to the Client. Useful for logging, monitoring, or other transport-level interceptors. */
|
|
199
|
+
wrapTransport?: (transport: Transport, serverId: string) => Transport;
|
|
200
|
+
/** Stable identifier supplied to `wrapTransport`; defaults to `url`. */
|
|
201
|
+
serverId?: string;
|
|
202
|
+
/** Callback function that is invoked when a notification is received from the MCP server */
|
|
203
|
+
onNotification?: (notification: Notification) => void;
|
|
204
|
+
/**
|
|
205
|
+
* Optional callback function to handle sampling requests from servers.
|
|
206
|
+
* When provided, the client will declare sampling capability and handle
|
|
207
|
+
* `sampling/createMessage` requests by calling this callback.
|
|
208
|
+
*
|
|
209
|
+
* @deprecated Sampling is deprecated by the 2026 protocol. Retained for v1
|
|
210
|
+
* push requests and v2 multi-round-trip compatibility.
|
|
211
|
+
*/
|
|
212
|
+
onSampling?: (params: SamplingCreateMessageParams) => Promise<SamplingCreateMessageResult>;
|
|
213
|
+
/**
|
|
214
|
+
* Optional callback function to handle elicitation requests from servers.
|
|
215
|
+
* When provided, the client will declare elicitation capability and handle
|
|
216
|
+
* `elicitation/create` requests by calling this callback.
|
|
217
|
+
*
|
|
218
|
+
* Elicitation allows servers to request additional information from users:
|
|
219
|
+
* - Form mode: Collect structured data with JSON schema validation
|
|
220
|
+
* - URL mode: Direct users to external URLs for sensitive interactions
|
|
221
|
+
*/
|
|
222
|
+
onElicitation?: (params: ElicitRequestFormParams | ElicitRequestURLParams) => Promise<ElicitResult>;
|
|
223
|
+
/** Client information advertised while establishing the MCP connection. */
|
|
224
|
+
clientInfo?: {
|
|
225
|
+
/** Stable programmatic client name. */
|
|
226
|
+
name: string;
|
|
227
|
+
/** Optional human-readable client title. */
|
|
228
|
+
title?: string;
|
|
229
|
+
/** Client version. */
|
|
230
|
+
version: string;
|
|
231
|
+
/** Optional human-readable client description. */
|
|
232
|
+
description?: string;
|
|
233
|
+
/** Icons representing the client. */
|
|
234
|
+
icons?: Array<{
|
|
235
|
+
/** Icon URL. */
|
|
236
|
+
src: string;
|
|
237
|
+
/** Icon media type. */
|
|
238
|
+
mimeType?: string;
|
|
239
|
+
/** Supported icon sizes, such as `"48x48"`. */
|
|
240
|
+
sizes?: string[];
|
|
241
|
+
}>;
|
|
242
|
+
/** Public website describing the client. */
|
|
243
|
+
websiteUrl?: string;
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Optional custom fetch function to use for all MCP HTTP requests.
|
|
247
|
+
*
|
|
248
|
+
* When provided, this replaces the default global `fetch` for transport-level
|
|
249
|
+
* requests. Useful for adding custom auth retry logic, logging, or proxying.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* useMcp({
|
|
254
|
+
* url: 'http://localhost:3000/mcp',
|
|
255
|
+
* fetch: myCustomFetch,
|
|
256
|
+
* })
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
fetch?: typeof globalThis.fetch;
|
|
260
|
+
/**
|
|
261
|
+
* Optional external OAuth client provider.
|
|
262
|
+
*
|
|
263
|
+
* When provided, useMcp will use this provider directly instead of creating
|
|
264
|
+
* BrowserOAuthClientProvider internally. This is useful for headless/testing
|
|
265
|
+
* runtimes where popup/redirect flows are not available.
|
|
266
|
+
*/
|
|
267
|
+
authProvider?: OAuthClientProvider;
|
|
268
|
+
/**
|
|
269
|
+
* OAuth client registration settings.
|
|
270
|
+
*
|
|
271
|
+
* Use this when the upstream auth server does **not** support Dynamic Client
|
|
272
|
+
* Registration — for example, MCP servers running in proxy mode against
|
|
273
|
+
* Slack, WorkOS, or similar providers. Prefer `clientMetadataUrl` when the
|
|
274
|
+
* authorization server advertises CIMD support; the SDK falls back to DCR
|
|
275
|
+
* when appropriate.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```typescript
|
|
279
|
+
* useMcp({
|
|
280
|
+
* url: 'https://mcp.example.com',
|
|
281
|
+
* oauth: {
|
|
282
|
+
* clientId: 'my-preregistered-client-id',
|
|
283
|
+
* clientMetadataUrl: 'https://app.example.com/oauth/client-metadata.json',
|
|
284
|
+
* scope: 'openid profile email',
|
|
285
|
+
* },
|
|
286
|
+
* })
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
oauth?: {
|
|
290
|
+
/** Pre-registered OAuth client_id. */
|
|
291
|
+
clientId?: string;
|
|
292
|
+
/**
|
|
293
|
+
* Public HTTPS OAuth Client ID Metadata Document URL (CIMD).
|
|
294
|
+
* The document must contain a matching client_id and redirect_uris.
|
|
295
|
+
*/
|
|
296
|
+
clientMetadataUrl?: string;
|
|
297
|
+
/** OAuth scope string included in the authorize request. */
|
|
298
|
+
scope?: string;
|
|
299
|
+
};
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* Serializable configuration for one server managed by `McpClientProvider`.
|
|
303
|
+
* Pass this to `addServer` / `updateServer`.
|
|
304
|
+
*/
|
|
305
|
+
export interface McpServerConfig extends Omit<UseMcpOptions, "onSampling" | "onElicitation" | "onNotification"> {
|
|
306
|
+
/** Optional user-facing alias. `server.name` always comes from MCP server metadata. */
|
|
307
|
+
displayName?: string;
|
|
308
|
+
/** Optional callback invoked when the provider queues sampling. */
|
|
309
|
+
onSamplingRequest?: (request: PendingSamplingRequest) => void;
|
|
310
|
+
/** Optional callback invoked when the provider queues elicitation. */
|
|
311
|
+
onElicitationRequest?: (request: PendingElicitationRequest) => void;
|
|
312
|
+
/** Optional callback invoked when the provider receives a notification. */
|
|
313
|
+
onNotificationReceived?: (notification: McpNotification) => void;
|
|
314
|
+
}
|
|
315
|
+
/** @deprecated Use {@link McpServerConfig} */
|
|
316
|
+
export type McpServerOptions = McpServerConfig;
|
|
317
|
+
/** Non-secret connection settings that built-in providers may persist. */
|
|
318
|
+
export type PersistedMcpServerConfig = Pick<McpServerConfig, "url" | "displayName" | "enabled" | "oauthProxyUrl" | "connectionMode" | "autoProxyFallback" | "callbackUrl" | "storageKeyPrefix" | "logLevel" | "autoRetry" | "autoReconnect" | "reconnectionOptions" | "popupFeatures" | "preventAutoAuth" | "detectMixedAuth" | "useRedirectFlow" | "protocolNegotiation" | "timeout" | "clientInfo"> & {
|
|
319
|
+
/** Proxy endpoint only. Proxy authorization headers are runtime-only. */
|
|
320
|
+
proxyConfig?: Pick<ProxyConfig, "proxyAddress">;
|
|
321
|
+
/** Public OAuth registration settings only. */
|
|
322
|
+
oauth?: {
|
|
323
|
+
/** Pre-registered public OAuth client identifier. */
|
|
324
|
+
clientId?: string;
|
|
325
|
+
/** Public OAuth Client ID Metadata Document URL. */
|
|
326
|
+
clientMetadataUrl?: string;
|
|
327
|
+
/** Space-delimited OAuth scopes. */
|
|
328
|
+
scope?: string;
|
|
329
|
+
};
|
|
330
|
+
};
|
|
331
|
+
/** Notification received from one managed MCP server. */
|
|
332
|
+
export interface McpNotification {
|
|
333
|
+
/** Unique notification identifier generated by the provider. */
|
|
334
|
+
id: string;
|
|
335
|
+
/** MCP notification method name. */
|
|
336
|
+
method: string;
|
|
337
|
+
/** Optional notification parameters. */
|
|
338
|
+
params?: Record<string, unknown>;
|
|
339
|
+
/** Unix timestamp in milliseconds when the notification was received. */
|
|
340
|
+
timestamp: number;
|
|
341
|
+
/** Whether the consumer has marked the notification as read. */
|
|
342
|
+
read: boolean;
|
|
343
|
+
}
|
|
344
|
+
/** A server sampling request awaiting UI or application approval. */
|
|
345
|
+
export interface PendingSamplingRequest {
|
|
346
|
+
/** Unique request identifier generated by the provider. */
|
|
347
|
+
id: string;
|
|
348
|
+
/** Sampling request received from the server. */
|
|
349
|
+
request: {
|
|
350
|
+
/** Sampling JSON-RPC method name. */
|
|
351
|
+
method: "sampling/createMessage";
|
|
352
|
+
/** Sampling request parameters. */
|
|
353
|
+
params: SamplingCreateMessageParams;
|
|
354
|
+
};
|
|
355
|
+
/** Unix timestamp in milliseconds when the request was received. */
|
|
356
|
+
timestamp: number;
|
|
357
|
+
/** Name of the server that issued the request. */
|
|
358
|
+
serverName: string;
|
|
359
|
+
}
|
|
360
|
+
/** A server elicitation request awaiting UI or application approval. */
|
|
361
|
+
export interface PendingElicitationRequest {
|
|
362
|
+
/** Unique request identifier generated by the provider. */
|
|
363
|
+
id: string;
|
|
364
|
+
/** Form or URL elicitation request received from the server. */
|
|
365
|
+
request: ElicitRequestFormParams | ElicitRequestURLParams;
|
|
366
|
+
/** Unix timestamp in milliseconds when the request was received. */
|
|
367
|
+
timestamp: number;
|
|
368
|
+
/** Name of the server that issued the request. */
|
|
369
|
+
serverName: string;
|
|
370
|
+
}
|
|
371
|
+
/** Reactive state and operations returned by {@link useMcp}. */
|
|
372
|
+
export type UseMcpResult = {
|
|
373
|
+
/** Name advertised by the connected MCP server. */
|
|
374
|
+
name: string;
|
|
375
|
+
/** List of tools available from the connected MCP server */
|
|
376
|
+
tools: Tool[];
|
|
377
|
+
/** List of resources available from the connected MCP server */
|
|
378
|
+
resources: Resource[];
|
|
379
|
+
/** List of resource templates available from the connected MCP server */
|
|
380
|
+
resourceTemplates: ResourceTemplate[];
|
|
381
|
+
/** List of prompts available from the connected MCP server */
|
|
382
|
+
prompts: Prompt[];
|
|
383
|
+
/** Skills advertised through the experimental Skills over MCP extension. */
|
|
384
|
+
skills: import("../core/skills.js").Skill[];
|
|
385
|
+
/** Server information normalized for the active connection. */
|
|
386
|
+
serverInfo?: {
|
|
387
|
+
/** Optional human-readable server title. */
|
|
388
|
+
title?: string;
|
|
389
|
+
/** Stable server name. */
|
|
390
|
+
name: string;
|
|
391
|
+
/** Server version. */
|
|
392
|
+
version?: string;
|
|
393
|
+
/** Optional human-readable server description. */
|
|
394
|
+
description?: string;
|
|
395
|
+
/** Public website describing the server. */
|
|
396
|
+
websiteUrl?: string;
|
|
397
|
+
/** Icons advertised by the server. */
|
|
398
|
+
icons?: Array<{
|
|
399
|
+
/** Icon URL. */
|
|
400
|
+
src: string;
|
|
401
|
+
/** Icon media type. */
|
|
402
|
+
mimeType?: string;
|
|
403
|
+
/** Supported icon sizes, such as `"48x48"`. */
|
|
404
|
+
sizes?: string[];
|
|
405
|
+
}>;
|
|
406
|
+
/** Base64-encoded favicon auto-detected from server domain */
|
|
407
|
+
icon?: string;
|
|
408
|
+
};
|
|
409
|
+
/** Server capabilities normalized for the active connection. */
|
|
410
|
+
capabilities?: Record<string, unknown>;
|
|
411
|
+
/** Optional server instructions advertised for the active connection. */
|
|
412
|
+
instructions?: string;
|
|
413
|
+
/** Protocol extension metadata normalized from the server capabilities. */
|
|
414
|
+
extensions: Record<string, unknown>;
|
|
415
|
+
/**
|
|
416
|
+
* Negotiated MCP protocol era for the active connection:
|
|
417
|
+
* - 'legacy': 2025-era server; lifecycle is managed internally.
|
|
418
|
+
* - 'modern': 2026-07-28-era server, stateless per-request.
|
|
419
|
+
* `undefined` until a connection has negotiated.
|
|
420
|
+
*/
|
|
421
|
+
protocolEra?: ProtocolEra;
|
|
422
|
+
/** Negotiated MCP protocol version string (e.g. '2025-06-18', '2026-07-28'). */
|
|
423
|
+
protocolVersion?: string;
|
|
424
|
+
/**
|
|
425
|
+
* The current state of the MCP connection:
|
|
426
|
+
* - 'discovering': Checking server existence and capabilities (including auth requirements).
|
|
427
|
+
* - 'pending_auth': Authentication is required but auto-popup was prevented. User action needed.
|
|
428
|
+
* - 'authenticating': Authentication is required and the process (e.g., popup) has been initiated.
|
|
429
|
+
* - 'ready': Connected and ready for tool calls.
|
|
430
|
+
* - 'failed': Connection or authentication failed. Check the `error` property.
|
|
431
|
+
*/
|
|
432
|
+
state: "discovering" | "pending_auth" | "authenticating" | "ready" | "failed";
|
|
433
|
+
/** If the state is 'failed', this provides the error message */
|
|
434
|
+
error?: string;
|
|
435
|
+
/**
|
|
436
|
+
* If authentication requires user interaction (e.g., popup was blocked),
|
|
437
|
+
* this URL can be presented to the user to complete authentication manually in a new tab.
|
|
438
|
+
*/
|
|
439
|
+
authUrl?: string;
|
|
440
|
+
/**
|
|
441
|
+
* OAuth tokens if authentication was completed
|
|
442
|
+
* Available when state is 'ready' and OAuth was used
|
|
443
|
+
*/
|
|
444
|
+
authTokens?: {
|
|
445
|
+
/** OAuth access token. */
|
|
446
|
+
access_token: string;
|
|
447
|
+
/** OAuth token type, commonly `"Bearer"`. */
|
|
448
|
+
token_type: string;
|
|
449
|
+
/** Unix timestamp in seconds when the access token expires. */
|
|
450
|
+
expires_at?: number;
|
|
451
|
+
/** OAuth refresh token, when issued. */
|
|
452
|
+
refresh_token?: string;
|
|
453
|
+
/** Space-delimited OAuth scopes granted to the token. */
|
|
454
|
+
scope?: string;
|
|
455
|
+
/** Canonical protected-resource URL required by some token refresh flows. */
|
|
456
|
+
resource?: string;
|
|
457
|
+
/**
|
|
458
|
+
* OAuth token endpoint resolved during discovery (when available). Lets
|
|
459
|
+
* consumers persist it so a backend can proactively refresh the token.
|
|
460
|
+
*/
|
|
461
|
+
token_endpoint?: string;
|
|
462
|
+
/**
|
|
463
|
+
* OAuth client id (from Dynamic Client Registration or a static client).
|
|
464
|
+
* Most token endpoints require it on refresh, so consumers can persist it
|
|
465
|
+
* for server-side proactive refresh.
|
|
466
|
+
*/
|
|
467
|
+
client_id?: string;
|
|
468
|
+
/** OAuth client secret, when the provider issued a confidential client. */
|
|
469
|
+
client_secret?: string;
|
|
470
|
+
};
|
|
471
|
+
/** OAuth availability discovered for an anonymously connected server. */
|
|
472
|
+
authorization?: MCPAuthorizationInfo;
|
|
473
|
+
/** Array of internal log messages (useful for debugging) */
|
|
474
|
+
log: {
|
|
475
|
+
/** Log severity. */
|
|
476
|
+
level: "debug" | "info" | "warn" | "error";
|
|
477
|
+
/** Human-readable log message. */
|
|
478
|
+
message: string;
|
|
479
|
+
/** Unix timestamp in milliseconds when the entry was created. */
|
|
480
|
+
timestamp: number;
|
|
481
|
+
}[];
|
|
482
|
+
/**
|
|
483
|
+
* Function to call a tool on the MCP server.
|
|
484
|
+
* @param name - The name of the tool to call.
|
|
485
|
+
* @param args - Optional arguments for the tool.
|
|
486
|
+
* @param options - Optional request options including timeout configuration.
|
|
487
|
+
* @returns A promise that resolves with the tool's result.
|
|
488
|
+
* @throws If the client is not in the 'ready' state or the call fails.
|
|
489
|
+
*
|
|
490
|
+
* @example
|
|
491
|
+
* ```typescript
|
|
492
|
+
* // Simple tool call
|
|
493
|
+
* const result = await mcp.callTool('my-tool', { arg: 'value' })
|
|
494
|
+
*
|
|
495
|
+
* // Tool call with extended timeout (e.g., for tools that trigger sampling)
|
|
496
|
+
* const result = await mcp.callTool('analyze-sentiment', { text: 'Hello' }, {
|
|
497
|
+
* timeout: 300000, // 5 minutes
|
|
498
|
+
* resetTimeoutOnProgress: true // Reset timeout when progress notifications are received
|
|
499
|
+
* })
|
|
500
|
+
* ```
|
|
501
|
+
*/
|
|
502
|
+
callTool: (name: string, args?: Record<string, unknown>, options?: {
|
|
503
|
+
/** Timeout in milliseconds for this tool call (default: 60000 / 60 seconds) */
|
|
504
|
+
timeout?: number;
|
|
505
|
+
/** Maximum total timeout in milliseconds, even with progress resets */
|
|
506
|
+
maxTotalTimeout?: number;
|
|
507
|
+
/** Reset the timeout when progress notifications are received (default: false) */
|
|
508
|
+
resetTimeoutOnProgress?: boolean;
|
|
509
|
+
/** AbortSignal to cancel the request */
|
|
510
|
+
signal?: AbortSignal;
|
|
511
|
+
}) => Promise<any>;
|
|
512
|
+
/**
|
|
513
|
+
* Function to list resources from the MCP server.
|
|
514
|
+
* @returns A promise that resolves when resources are refreshed.
|
|
515
|
+
* @throws If the client is not in the 'ready' state.
|
|
516
|
+
*/
|
|
517
|
+
listResources: () => Promise<void>;
|
|
518
|
+
/**
|
|
519
|
+
* Function to read a resource from the MCP server.
|
|
520
|
+
* @param uri - The URI of the resource to read.
|
|
521
|
+
* @returns A promise that resolves with the resource contents.
|
|
522
|
+
* @throws If the client is not in the 'ready' state or the read fails.
|
|
523
|
+
*/
|
|
524
|
+
readResource: (uri: string) => Promise<{
|
|
525
|
+
/** Content blocks returned for the resource. */
|
|
526
|
+
contents: Array<{
|
|
527
|
+
/** URI of the returned resource content. */
|
|
528
|
+
uri: string;
|
|
529
|
+
/** Content media type. */
|
|
530
|
+
mimeType?: string;
|
|
531
|
+
/** UTF-8 text content. */
|
|
532
|
+
text?: string;
|
|
533
|
+
/** Base64-encoded binary content. */
|
|
534
|
+
blob?: string;
|
|
535
|
+
}>;
|
|
536
|
+
}>;
|
|
537
|
+
/** Refresh the complete paginated skill catalog. */
|
|
538
|
+
listSkills: () => Promise<void>;
|
|
539
|
+
/** Resolve one skill by its canonical URI. */
|
|
540
|
+
getSkill: (uri: string) => Promise<import("../core/skills.js").SkillGetResult>;
|
|
541
|
+
/** Read one non-recursive directory in a remote skill. */
|
|
542
|
+
readResourceDirectory: (uri: string, cursor?: string) => Promise<import("../core/skills.js").SkillDirectoryReadResult>;
|
|
543
|
+
/**
|
|
544
|
+
* Function to list prompts from the MCP server.
|
|
545
|
+
* @returns A promise that resolves when prompts are refreshed.
|
|
546
|
+
* @throws If the client is not in the 'ready' state.
|
|
547
|
+
*/
|
|
548
|
+
listPrompts: () => Promise<void>;
|
|
549
|
+
/**
|
|
550
|
+
* Function to get a specific prompt from the MCP server.
|
|
551
|
+
* @param name - The name of the prompt to get.
|
|
552
|
+
* @param args - Optional arguments for the prompt.
|
|
553
|
+
* @returns A promise that resolves with the prompt messages.
|
|
554
|
+
* @throws If the client is not in the 'ready' state or the get fails.
|
|
555
|
+
*/
|
|
556
|
+
getPrompt: (name: string, args?: Record<string, string>) => Promise<{
|
|
557
|
+
/** Messages produced from the prompt template. */
|
|
558
|
+
messages: Array<{
|
|
559
|
+
/** Conversation role for the prompt message. */
|
|
560
|
+
role: "user" | "assistant";
|
|
561
|
+
/** Prompt message content. */
|
|
562
|
+
content: {
|
|
563
|
+
/** MCP content block type. */
|
|
564
|
+
type: string;
|
|
565
|
+
/** Text value for text content blocks. */
|
|
566
|
+
text?: string;
|
|
567
|
+
[key: string]: any;
|
|
568
|
+
};
|
|
569
|
+
}>;
|
|
570
|
+
}>;
|
|
571
|
+
/**
|
|
572
|
+
* Request completion suggestions for a prompt or resource template argument.
|
|
573
|
+
* @param params - Completion request parameters specifying the ref and argument to complete.
|
|
574
|
+
* @returns A promise that resolves with completion suggestions from the server.
|
|
575
|
+
* @throws If the client is not in the 'ready' state or the completion request fails.
|
|
576
|
+
*/
|
|
577
|
+
complete: (params: CompleteRequestParams) => Promise<CompleteResult>;
|
|
578
|
+
/**
|
|
579
|
+
* Refresh the tools list from the server.
|
|
580
|
+
* Called automatically when notifications/tools/list_changed is received.
|
|
581
|
+
* Can also be called manually for explicit refresh.
|
|
582
|
+
*/
|
|
583
|
+
refreshTools: () => Promise<void>;
|
|
584
|
+
/**
|
|
585
|
+
* Refresh the resources list from the server.
|
|
586
|
+
* Called automatically when notifications/resources/list_changed is received.
|
|
587
|
+
* Can also be called manually for explicit refresh.
|
|
588
|
+
*/
|
|
589
|
+
refreshResources: () => Promise<void>;
|
|
590
|
+
/**
|
|
591
|
+
* Refresh the resource templates list from the server.
|
|
592
|
+
* Can be called manually for explicit refresh.
|
|
593
|
+
*/
|
|
594
|
+
refreshResourceTemplates: () => Promise<void>;
|
|
595
|
+
/**
|
|
596
|
+
* Refresh the prompts list from the server.
|
|
597
|
+
* Called automatically when notifications/prompts/list_changed is received.
|
|
598
|
+
* Can also be called manually for explicit refresh.
|
|
599
|
+
*/
|
|
600
|
+
refreshPrompts: () => Promise<void>;
|
|
601
|
+
/**
|
|
602
|
+
* Refresh all lists (tools, resources, resource templates, prompts) from the server.
|
|
603
|
+
* Useful after reconnection or for manual refresh.
|
|
604
|
+
*/
|
|
605
|
+
refreshAll: () => Promise<void>;
|
|
606
|
+
/** Manually attempts to reconnect if the state is 'failed'. */
|
|
607
|
+
retry: () => void;
|
|
608
|
+
/** Disconnects the client from the MCP server. */
|
|
609
|
+
disconnect: () => Promise<void>;
|
|
610
|
+
/**
|
|
611
|
+
* Manually triggers the authentication process. Useful if the initial attempt failed
|
|
612
|
+
* due to a blocked popup, allowing the user to initiate it via a button click.
|
|
613
|
+
* @returns A promise that resolves with the authorization URL opened (or intended to be opened),
|
|
614
|
+
* or undefined if auth cannot be started.
|
|
615
|
+
*/
|
|
616
|
+
authenticate: () => Promise<void>;
|
|
617
|
+
/** Clears all stored authentication data (tokens, client info, etc.) for this server URL from localStorage. */
|
|
618
|
+
clearStorage: () => void;
|
|
619
|
+
/**
|
|
620
|
+
* Ensure the server icon is loaded and available in serverInfo
|
|
621
|
+
* Returns a promise that resolves when the icon is ready
|
|
622
|
+
* Use this before server creation to guarantee the icon is available
|
|
623
|
+
*
|
|
624
|
+
* @returns Promise that resolves with the base64 icon or null if not available
|
|
625
|
+
*
|
|
626
|
+
* @example
|
|
627
|
+
* ```typescript
|
|
628
|
+
* // Wait for icon before creating server
|
|
629
|
+
* const icon = await mcp.ensureIconLoaded();
|
|
630
|
+
* // Now mcp.serverInfo.icon is guaranteed to be set (if icon exists)
|
|
631
|
+
* ```
|
|
632
|
+
*/
|
|
633
|
+
ensureIconLoaded: () => Promise<string | null>;
|
|
634
|
+
/**
|
|
635
|
+
* The underlying runtime-neutral MCP client instance.
|
|
636
|
+
* Use this to create an MCPAgent for AI chat functionality.
|
|
637
|
+
*
|
|
638
|
+
* @example
|
|
639
|
+
* ```typescript
|
|
640
|
+
* import { MCPAgent } from "@mcp-use/agent"
|
|
641
|
+
* import { ChatOpenAI } from '@langchain/openai'
|
|
642
|
+
*
|
|
643
|
+
* const mcp = useMcp({ url: 'http://localhost:3000/mcp' })
|
|
644
|
+
* const llm = new ChatOpenAI({ model: 'gpt-4' })
|
|
645
|
+
*
|
|
646
|
+
* const agent = new MCPAgent({ llm, client: mcp.client })
|
|
647
|
+
* await agent.initialize()
|
|
648
|
+
*
|
|
649
|
+
* for await (const event of agent.streamEvents('Hello')) {
|
|
650
|
+
* console.log(event)
|
|
651
|
+
* }
|
|
652
|
+
* ```
|
|
653
|
+
*/
|
|
654
|
+
client: BaseMCPClient | null;
|
|
655
|
+
};
|
|
656
|
+
/**
|
|
657
|
+
* Connected MCP server: non-secret settings, live runtime headers, and state.
|
|
658
|
+
* Returned from `useMcpClient().servers`.
|
|
659
|
+
*/
|
|
660
|
+
type LiveMcpServerConfig = Omit<PersistedMcpServerConfig, "proxyConfig"> & {
|
|
661
|
+
/** Runtime HTTP headers. These values are never persisted. */
|
|
662
|
+
headers?: Record<string, string>;
|
|
663
|
+
/** Live proxy configuration, including runtime-only headers. */
|
|
664
|
+
proxyConfig?: ProxyConfig;
|
|
665
|
+
/** SDK client options used by the active connection. */
|
|
666
|
+
clientOptions?: McpServerConfig["clientOptions"];
|
|
667
|
+
};
|
|
668
|
+
export interface McpServer extends LiveMcpServerConfig, UseMcpResult {
|
|
669
|
+
/** Stable provider-managed server identifier. */
|
|
670
|
+
id: string;
|
|
671
|
+
/** Notifications received from this server. */
|
|
672
|
+
notifications: McpNotification[];
|
|
673
|
+
/** Number of notifications not yet marked as read. */
|
|
674
|
+
unreadNotificationCount: number;
|
|
675
|
+
/** Marks one notification as read. */
|
|
676
|
+
markNotificationRead: (id: string) => void;
|
|
677
|
+
/** Marks every notification as read. */
|
|
678
|
+
markAllNotificationsRead: () => void;
|
|
679
|
+
/** Removes every notification from local state. */
|
|
680
|
+
clearNotifications: () => void;
|
|
681
|
+
/** Sampling requests awaiting an application decision. */
|
|
682
|
+
pendingSamplingRequests: PendingSamplingRequest[];
|
|
683
|
+
/** Approves a pending sampling request with a result. */
|
|
684
|
+
approveSampling: (requestId: string, result: SamplingCreateMessageResult) => void;
|
|
685
|
+
/** Rejects a pending sampling request. */
|
|
686
|
+
rejectSampling: (requestId: string, error?: string) => void;
|
|
687
|
+
/** Elicitation requests awaiting an application decision. */
|
|
688
|
+
pendingElicitationRequests: PendingElicitationRequest[];
|
|
689
|
+
/** Approves a pending elicitation request with a result. */
|
|
690
|
+
approveElicitation: (requestId: string, result: ElicitResult) => void;
|
|
691
|
+
/** Rejects a pending elicitation request. */
|
|
692
|
+
rejectElicitation: (requestId: string, error?: string) => void;
|
|
693
|
+
/**
|
|
694
|
+
* Merge connection-affecting config and reconnect when it changed.
|
|
695
|
+
* Prefer this over context `updateServer(id, …)` when you already hold the server.
|
|
696
|
+
*/
|
|
697
|
+
updateConfig: (config: Partial<McpServerConfig>) => Promise<void>;
|
|
698
|
+
/** Set HTTP headers on the connection config and reconnect. */
|
|
699
|
+
setHeaders: (headers: Record<string, string> | undefined) => Promise<void>;
|
|
700
|
+
/** Rename the server without disconnecting. */
|
|
701
|
+
setDisplayName: (displayName: string) => Promise<void>;
|
|
702
|
+
/** Disconnect and reconnect with the current config. */
|
|
703
|
+
reconnect: () => Promise<void>;
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Extracts the non-secret subset safe for provider storage.
|
|
707
|
+
*
|
|
708
|
+
* @param source - Server configuration or live managed server.
|
|
709
|
+
* @returns A new persistable configuration object.
|
|
710
|
+
*/
|
|
711
|
+
export declare function pickPersistedServerConfig(source: McpServerConfig | McpServer): PersistedMcpServerConfig;
|
|
712
|
+
/**
|
|
713
|
+
* Extracts connection settings, including runtime-only values, from a server.
|
|
714
|
+
*
|
|
715
|
+
* @param source - Server configuration or live managed server.
|
|
716
|
+
* @returns A new live configuration object.
|
|
717
|
+
*/
|
|
718
|
+
export declare function pickLiveServerConfig(source: McpServerConfig | McpServer): LiveMcpServerConfig;
|
|
719
|
+
/**
|
|
720
|
+
* Removes credentials, callbacks, and runtime-only values before storage.
|
|
721
|
+
*
|
|
722
|
+
* @param config - Configuration to sanitize.
|
|
723
|
+
* @returns A new persistable configuration object.
|
|
724
|
+
*/
|
|
725
|
+
export declare function toPersistedServerConfig(config: McpServerConfig): PersistedMcpServerConfig;
|
|
726
|
+
export {};
|
|
727
|
+
//# sourceMappingURL=types.d.ts.map
|