@mcp-use/client 0.0.0-bootstrap.0 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +127 -4
- package/dist/.tsbuildinfo +1 -0
- package/dist/auth/browser.d.ts +149 -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 +23 -0
- package/dist/auth/flow.d.ts.map +1 -0
- package/dist/auth/node.d.ts +100 -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 +114 -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 +25 -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 +66 -0
- package/dist/code-mode/executor.d.ts.map +1 -0
- package/dist/core/base.d.ts +418 -0
- package/dist/core/base.d.ts.map +1 -0
- package/dist/core/browser.d.ts +20 -0
- package/dist/core/browser.d.ts.map +1 -0
- package/dist/core/config.d.ts +149 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/node.d.ts +441 -0
- package/dist/core/node.d.ts.map +1 -0
- package/dist/core/session.d.ts +683 -0
- package/dist/core/session.d.ts.map +1 -0
- package/dist/index-browser.d.ts +25 -0
- package/dist/index-browser.d.ts.map +1 -0
- package/dist/index-browser.js +4150 -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 +5598 -0
- package/dist/index.js.map +1 -0
- package/dist/react/McpClientProvider.d.ts +242 -0
- package/dist/react/McpClientProvider.d.ts.map +1 -0
- package/dist/react/index.d.ts +33 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +7922 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/rpc-logger.d.ts +42 -0
- package/dist/react/rpc-logger.d.ts.map +1 -0
- package/dist/react/storage.d.ts +51 -0
- package/dist/react/storage.d.ts.map +1 -0
- package/dist/react/types.d.ts +596 -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 +156 -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 +376 -0
- package/dist/react/useMcpServerQueues.d.ts.map +1 -0
- package/dist/react/view/ViewRenderer.d.ts +12 -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/parse-custom-props.d.ts +2 -0
- package/dist/react/view/parse-custom-props.d.ts.map +1 -0
- package/dist/react/view/resolve-view-resource.d.ts +12 -0
- package/dist/react/view/resolve-view-resource.d.ts.map +1 -0
- package/dist/react/view/sandbox-blob-url.d.ts +25 -0
- package/dist/react/view/sandbox-blob-url.d.ts.map +1 -0
- package/dist/react/view/types.d.ts +97 -0
- package/dist/react/view/types.d.ts.map +1 -0
- package/dist/react/view/use-display-mode.d.ts +18 -0
- package/dist/react/view/use-display-mode.d.ts.map +1 -0
- package/dist/react/view/view-detection.d.ts +4 -0
- package/dist/react/view/view-detection.d.ts.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 +25 -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 +79 -0
- package/dist/telemetry/telemetry.d.ts.map +1 -0
- package/dist/transport/base.d.ts +505 -0
- package/dist/transport/base.d.ts.map +1 -0
- package/dist/transport/connection-manager.d.ts +55 -0
- package/dist/transport/connection-manager.d.ts.map +1 -0
- package/dist/transport/http.d.ts +74 -0
- package/dist/transport/http.d.ts.map +1 -0
- package/dist/transport/stdio.d.ts +48 -0
- package/dist/transport/stdio.d.ts.map +1 -0
- package/dist/utils/elicitation.d.ts +52 -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 +32 -0
- package/dist/utils/logging.d.ts.map +1 -0
- package/dist/utils/version.d.ts +3 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/package.json +77 -8
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
import type { CallToolResult, Client, ClientOptions, CompleteRequestParams, CompleteResult, ElicitRequestFormParams, ElicitRequestURLParams, ElicitResult, AuthProvider, Notification, OAuthClientProvider, ProtocolEra, RequestOptions, Root, Tool } from "@modelcontextprotocol/client";
|
|
2
|
+
import type { SamplingCreateMessageParams, SamplingCreateMessageResult } from "../core/config.js";
|
|
3
|
+
import type { ConnectionManager } from "./connection-manager.js";
|
|
4
|
+
import type { ConnectorInitEventData } from "../telemetry/events.js";
|
|
5
|
+
import type { MCPServerInfo } from "../core/session.js";
|
|
6
|
+
/**
|
|
7
|
+
* Handler function for server notifications
|
|
8
|
+
*/
|
|
9
|
+
export type NotificationHandler = (notification: Notification) => void | Promise<void>;
|
|
10
|
+
export interface ConnectorInitOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Options forwarded to the underlying MCP `Client` instance.
|
|
13
|
+
*
|
|
14
|
+
* By default, all connectors (HTTP and stdio) use `DialectJsonSchemaValidator`
|
|
15
|
+
* to support common `$schema` dialects (draft-04, draft-07, 2019-09, 2020-12)
|
|
16
|
+
* for cross-version compatibility with v1-era servers. Override with
|
|
17
|
+
* `clientOptions.jsonSchemaValidator` if stricter validation is needed.
|
|
18
|
+
*/
|
|
19
|
+
clientOptions?: ClientOptions;
|
|
20
|
+
/**
|
|
21
|
+
* Arbitrary request options (timeouts, cancellation, etc.) used by helper
|
|
22
|
+
* methods when they issue SDK requests. Can be overridden per‑call.
|
|
23
|
+
*/
|
|
24
|
+
defaultRequestOptions?: RequestOptions;
|
|
25
|
+
/**
|
|
26
|
+
* OAuth client provider for automatic authentication
|
|
27
|
+
*/
|
|
28
|
+
authProvider?: AuthProvider | OAuthClientProvider;
|
|
29
|
+
/**
|
|
30
|
+
* Optional callback to wrap the transport before passing it to the Client.
|
|
31
|
+
* Useful for logging, monitoring, or other transport-level interceptors.
|
|
32
|
+
*/
|
|
33
|
+
wrapTransport?: (transport: any, serverId: string) => any;
|
|
34
|
+
/**
|
|
35
|
+
* Initial roots to provide to the server.
|
|
36
|
+
* Roots allow the server to know which directories/files the client has access to.
|
|
37
|
+
*/
|
|
38
|
+
roots?: Root[];
|
|
39
|
+
/**
|
|
40
|
+
* Optional callback function to handle sampling requests from servers.
|
|
41
|
+
* When provided, the client will declare sampling capability and handle
|
|
42
|
+
* `sampling/createMessage` requests by calling this callback.
|
|
43
|
+
*
|
|
44
|
+
* @deprecated Sampling is deprecated by the 2026 protocol. Retained for v1
|
|
45
|
+
* push requests and v2 multi-round-trip compatibility.
|
|
46
|
+
*/
|
|
47
|
+
onSampling?: (params: SamplingCreateMessageParams) => Promise<SamplingCreateMessageResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Optional callback function to handle elicitation requests from servers.
|
|
50
|
+
* When provided, the client will declare elicitation capability and handle
|
|
51
|
+
* `elicitation/create` requests by calling this callback.
|
|
52
|
+
*
|
|
53
|
+
* Elicitation allows servers to request additional information from users:
|
|
54
|
+
* - Form mode: Collect structured data with JSON schema validation
|
|
55
|
+
* - URL mode: Direct users to external URLs for sensitive interactions
|
|
56
|
+
*/
|
|
57
|
+
onElicitation?: (params: ElicitRequestFormParams | ElicitRequestURLParams) => Promise<ElicitResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Optional callback for server notifications.
|
|
60
|
+
* When provided, registered as initial notification handler.
|
|
61
|
+
*/
|
|
62
|
+
onNotification?: NotificationHandler;
|
|
63
|
+
/**
|
|
64
|
+
* Reconnection options for streamable HTTP transport.
|
|
65
|
+
* Controls retry behavior of the underlying `StreamableHTTPClientTransport`.
|
|
66
|
+
*/
|
|
67
|
+
reconnectionOptions?: {
|
|
68
|
+
maxReconnectionDelay?: number;
|
|
69
|
+
initialReconnectionDelay?: number;
|
|
70
|
+
reconnectionDelayGrowFactor?: number;
|
|
71
|
+
maxRetries?: number;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Base class for MCP connectors.
|
|
76
|
+
*/
|
|
77
|
+
export declare abstract class BaseConnector {
|
|
78
|
+
protected client: Client | null;
|
|
79
|
+
protected connectionManager: ConnectionManager<any> | null;
|
|
80
|
+
protected toolsCache: Tool[] | null;
|
|
81
|
+
protected capabilitiesCache: Record<string, unknown> | null;
|
|
82
|
+
protected serverInfoCache: MCPServerInfo | null;
|
|
83
|
+
protected connected: boolean;
|
|
84
|
+
protected readonly opts: ConnectorInitOptions;
|
|
85
|
+
protected notificationHandlers: NotificationHandler[];
|
|
86
|
+
protected rootsCache: Root[];
|
|
87
|
+
private activeProgressHandlers;
|
|
88
|
+
constructor(opts?: ConnectorInitOptions);
|
|
89
|
+
/**
|
|
90
|
+
* Track connector initialization event
|
|
91
|
+
* Should be called by subclasses after successful connection
|
|
92
|
+
*/
|
|
93
|
+
protected trackConnectorInit(data: Omit<ConnectorInitEventData, "connectorType">): void;
|
|
94
|
+
/**
|
|
95
|
+
* Register a handler for server notifications
|
|
96
|
+
*
|
|
97
|
+
* @param handler - Function to call when a notification is received
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* connector.onNotification((notification) => {
|
|
102
|
+
* console.log(`Received: ${notification.method}`, notification.params);
|
|
103
|
+
* });
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
onNotification(handler: NotificationHandler): void;
|
|
107
|
+
/** Forward a normalized notification to every registered consumer. */
|
|
108
|
+
protected forwardNotification(notification: Notification): Promise<void>;
|
|
109
|
+
/** Handle SDK list-change callbacks identically on v1 and v2 connections. */
|
|
110
|
+
protected handleListChanged(method: "notifications/tools/list_changed" | "notifications/resources/list_changed" | "notifications/prompts/list_changed", error: Error | null, tools?: Tool[] | null): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Internal: wire notification handlers to the SDK client
|
|
113
|
+
* Includes automatic handling for list_changed notifications per MCP spec
|
|
114
|
+
*/
|
|
115
|
+
protected setupNotificationHandler(): void;
|
|
116
|
+
/**
|
|
117
|
+
* Forward v2 MRTR progress whose retry request IDs are not associated with
|
|
118
|
+
* the original call callback by the current SDK beta.
|
|
119
|
+
*
|
|
120
|
+
* ponytail: fallback is enabled only when exactly one progress-aware call is
|
|
121
|
+
* active; remove it when the upstream SDK propagates handlers to MRTR rounds.
|
|
122
|
+
*/
|
|
123
|
+
protected setupRoundProgressForwarding(): void;
|
|
124
|
+
/** Forward progress parsed from a transport stream to the active call. */
|
|
125
|
+
protected forwardRoundProgress(params: unknown): void;
|
|
126
|
+
/**
|
|
127
|
+
* Auto-refresh tools cache when server sends tools/list_changed notification
|
|
128
|
+
*/
|
|
129
|
+
protected refreshToolsCache(): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Called when server sends resources/list_changed notification
|
|
132
|
+
* Resources aren't cached by default, but we log for user awareness
|
|
133
|
+
*/
|
|
134
|
+
protected onResourcesListChanged(): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Called when server sends prompts/list_changed notification
|
|
137
|
+
* Prompts aren't cached by default, but we log for user awareness
|
|
138
|
+
*/
|
|
139
|
+
protected onPromptsListChanged(): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Set roots and notify the server.
|
|
142
|
+
* Roots represent directories or files that the client has access to.
|
|
143
|
+
*
|
|
144
|
+
* @param roots - Array of Root objects with `uri` (must start with "file://") and optional `name`
|
|
145
|
+
*
|
|
146
|
+
* @deprecated Roots are retained only for v1 compatibility.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* await connector.setRoots([
|
|
151
|
+
* { uri: "file:///home/user/project", name: "My Project" },
|
|
152
|
+
* { uri: "file:///home/user/data" }
|
|
153
|
+
* ]);
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
setRoots(roots: Root[]): Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* Get the current roots.
|
|
159
|
+
*/
|
|
160
|
+
getRoots(): Root[];
|
|
161
|
+
/**
|
|
162
|
+
* Internal: set up roots/list request handler.
|
|
163
|
+
* Must be registered after Client construction and before connect() so the
|
|
164
|
+
* handler is available during initialize / reverse RPC for the full session.
|
|
165
|
+
*/
|
|
166
|
+
protected setupRootsHandler(): void;
|
|
167
|
+
/**
|
|
168
|
+
* Internal: set up sampling/createMessage request handler.
|
|
169
|
+
* Must be registered after Client construction and before connect().
|
|
170
|
+
*/
|
|
171
|
+
protected setupSamplingHandler(): void;
|
|
172
|
+
/**
|
|
173
|
+
* Internal: set up elicitation/create request handler.
|
|
174
|
+
* Must be registered after Client construction and before connect().
|
|
175
|
+
*/
|
|
176
|
+
protected setupElicitationHandler(): void;
|
|
177
|
+
/** Establish the connection and create the SDK client. */
|
|
178
|
+
abstract connect(): Promise<void>;
|
|
179
|
+
/** Get the identifier for the connector. */
|
|
180
|
+
abstract get publicIdentifier(): Record<string, string>;
|
|
181
|
+
/** Disconnect and release resources. */
|
|
182
|
+
disconnect(): Promise<void>;
|
|
183
|
+
/** Check if the client is connected */
|
|
184
|
+
get isClientConnected(): boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Initialise the MCP session **after** `connect()` has succeeded.
|
|
187
|
+
*
|
|
188
|
+
* In the SDK, `Client.connect(transport)` automatically performs the
|
|
189
|
+
* protocol‑level `initialize` handshake, so we only need to cache the list of
|
|
190
|
+
* tools and expose some server info.
|
|
191
|
+
*/
|
|
192
|
+
initialize(defaultRequestOptions?: RequestOptions): Promise<ReturnType<Client["getServerCapabilities"]>>;
|
|
193
|
+
/** Lazily expose the cached tools list. */
|
|
194
|
+
get tools(): Tool[];
|
|
195
|
+
/** Expose cached server capabilities. */
|
|
196
|
+
get serverCapabilities(): Record<string, unknown>;
|
|
197
|
+
/** Expose cached server info. */
|
|
198
|
+
get serverInfo(): MCPServerInfo | null;
|
|
199
|
+
/** Instructions supplied by the connected server, if any. */
|
|
200
|
+
get instructions(): string | undefined;
|
|
201
|
+
/**
|
|
202
|
+
* The negotiated protocol era for the active connection.
|
|
203
|
+
* - `"legacy"` — 2025-era server, sessionful `initialize` handshake.
|
|
204
|
+
* - `"modern"` — 2026-era server, stateless per-request.
|
|
205
|
+
* `undefined` before the connection has negotiated.
|
|
206
|
+
*/
|
|
207
|
+
get protocolEra(): ProtocolEra | undefined;
|
|
208
|
+
/** The protocol version string negotiated for the active connection. */
|
|
209
|
+
get negotiatedProtocolVersion(): string | undefined;
|
|
210
|
+
/** Call a tool on the server. */
|
|
211
|
+
callTool(name: string, args: Record<string, any>, options?: RequestOptions): Promise<CallToolResult>;
|
|
212
|
+
/**
|
|
213
|
+
* List all available tools from the MCP server.
|
|
214
|
+
* This method fetches fresh tools from the server, unlike the `tools` getter which returns cached tools.
|
|
215
|
+
*
|
|
216
|
+
* @param options - Optional request options
|
|
217
|
+
* @returns Array of available tools
|
|
218
|
+
*/
|
|
219
|
+
listTools(options?: RequestOptions): Promise<Tool[]>;
|
|
220
|
+
/**
|
|
221
|
+
* List resources from the server with optional pagination
|
|
222
|
+
*
|
|
223
|
+
* @param cursor - Optional cursor for pagination
|
|
224
|
+
* @param options - Request options
|
|
225
|
+
* @returns Resource list with optional nextCursor for pagination
|
|
226
|
+
*/
|
|
227
|
+
listResources(cursor?: string, options?: RequestOptions): Promise<{
|
|
228
|
+
[x: string]: unknown;
|
|
229
|
+
resources: {
|
|
230
|
+
uri: string;
|
|
231
|
+
name: string;
|
|
232
|
+
description?: string | undefined;
|
|
233
|
+
mimeType?: string | undefined;
|
|
234
|
+
size?: number | undefined;
|
|
235
|
+
annotations?: {
|
|
236
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
237
|
+
priority?: number | undefined;
|
|
238
|
+
lastModified?: string | undefined;
|
|
239
|
+
} | undefined;
|
|
240
|
+
_meta?: {
|
|
241
|
+
[x: string]: unknown;
|
|
242
|
+
} | undefined;
|
|
243
|
+
icons?: {
|
|
244
|
+
src: string;
|
|
245
|
+
mimeType?: string | undefined;
|
|
246
|
+
sizes?: string[] | undefined;
|
|
247
|
+
theme?: "light" | "dark" | undefined;
|
|
248
|
+
}[] | undefined;
|
|
249
|
+
title?: string | undefined;
|
|
250
|
+
}[];
|
|
251
|
+
_meta?: {
|
|
252
|
+
[x: string]: unknown;
|
|
253
|
+
progressToken?: string | number | undefined;
|
|
254
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
255
|
+
taskId: string;
|
|
256
|
+
} | undefined;
|
|
257
|
+
} | undefined;
|
|
258
|
+
nextCursor?: string | undefined;
|
|
259
|
+
}>;
|
|
260
|
+
/**
|
|
261
|
+
* List all resources from the server, automatically handling pagination
|
|
262
|
+
*
|
|
263
|
+
* @param options - Request options
|
|
264
|
+
* @returns Complete list of all resources
|
|
265
|
+
*/
|
|
266
|
+
listAllResources(options?: RequestOptions): Promise<{
|
|
267
|
+
resources: any[];
|
|
268
|
+
}>;
|
|
269
|
+
/**
|
|
270
|
+
* List resource templates from the server
|
|
271
|
+
*
|
|
272
|
+
* @param options - Request options
|
|
273
|
+
* @returns List of available resource templates
|
|
274
|
+
*/
|
|
275
|
+
listResourceTemplates(options?: RequestOptions): Promise<{
|
|
276
|
+
[x: string]: unknown;
|
|
277
|
+
resourceTemplates: {
|
|
278
|
+
uriTemplate: string;
|
|
279
|
+
name: string;
|
|
280
|
+
description?: string | undefined;
|
|
281
|
+
mimeType?: string | undefined;
|
|
282
|
+
annotations?: {
|
|
283
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
284
|
+
priority?: number | undefined;
|
|
285
|
+
lastModified?: string | undefined;
|
|
286
|
+
} | undefined;
|
|
287
|
+
_meta?: {
|
|
288
|
+
[x: string]: unknown;
|
|
289
|
+
} | undefined;
|
|
290
|
+
icons?: {
|
|
291
|
+
src: string;
|
|
292
|
+
mimeType?: string | undefined;
|
|
293
|
+
sizes?: string[] | undefined;
|
|
294
|
+
theme?: "light" | "dark" | undefined;
|
|
295
|
+
}[] | undefined;
|
|
296
|
+
title?: string | undefined;
|
|
297
|
+
}[];
|
|
298
|
+
_meta?: {
|
|
299
|
+
[x: string]: unknown;
|
|
300
|
+
progressToken?: string | number | undefined;
|
|
301
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
302
|
+
taskId: string;
|
|
303
|
+
} | undefined;
|
|
304
|
+
} | undefined;
|
|
305
|
+
nextCursor?: string | undefined;
|
|
306
|
+
}>;
|
|
307
|
+
/**
|
|
308
|
+
* Request completion suggestions for a prompt or resource template argument
|
|
309
|
+
*
|
|
310
|
+
* @param params - Completion request parameters
|
|
311
|
+
* @param options - Request options
|
|
312
|
+
* @returns Completion suggestions from the server
|
|
313
|
+
*/
|
|
314
|
+
complete(params: CompleteRequestParams, options?: RequestOptions): Promise<CompleteResult>;
|
|
315
|
+
/** Read a resource by URI. */
|
|
316
|
+
readResource(uri: string, options?: RequestOptions): Promise<{
|
|
317
|
+
[x: string]: unknown;
|
|
318
|
+
contents: ({
|
|
319
|
+
uri: string;
|
|
320
|
+
text: string;
|
|
321
|
+
mimeType?: string | undefined;
|
|
322
|
+
_meta?: {
|
|
323
|
+
[x: string]: unknown;
|
|
324
|
+
} | undefined;
|
|
325
|
+
} | {
|
|
326
|
+
uri: string;
|
|
327
|
+
blob: string;
|
|
328
|
+
mimeType?: string | undefined;
|
|
329
|
+
_meta?: {
|
|
330
|
+
[x: string]: unknown;
|
|
331
|
+
} | undefined;
|
|
332
|
+
})[];
|
|
333
|
+
_meta?: {
|
|
334
|
+
[x: string]: unknown;
|
|
335
|
+
progressToken?: string | number | undefined;
|
|
336
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
337
|
+
taskId: string;
|
|
338
|
+
} | undefined;
|
|
339
|
+
} | undefined;
|
|
340
|
+
}>;
|
|
341
|
+
/**
|
|
342
|
+
* Subscribe to resource updates
|
|
343
|
+
*
|
|
344
|
+
* @param uri - URI of the resource to subscribe to
|
|
345
|
+
* @param options - Request options
|
|
346
|
+
*/
|
|
347
|
+
subscribeToResource(uri: string, options?: RequestOptions): Promise<{
|
|
348
|
+
_meta?: {
|
|
349
|
+
[x: string]: unknown;
|
|
350
|
+
progressToken?: string | number | undefined;
|
|
351
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
352
|
+
taskId: string;
|
|
353
|
+
} | undefined;
|
|
354
|
+
} | undefined;
|
|
355
|
+
}>;
|
|
356
|
+
/**
|
|
357
|
+
* Unsubscribe from resource updates
|
|
358
|
+
*
|
|
359
|
+
* @param uri - URI of the resource to unsubscribe from
|
|
360
|
+
* @param options - Request options
|
|
361
|
+
*/
|
|
362
|
+
unsubscribeFromResource(uri: string, options?: RequestOptions): Promise<{
|
|
363
|
+
_meta?: {
|
|
364
|
+
[x: string]: unknown;
|
|
365
|
+
progressToken?: string | number | undefined;
|
|
366
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
367
|
+
taskId: string;
|
|
368
|
+
} | undefined;
|
|
369
|
+
} | undefined;
|
|
370
|
+
}>;
|
|
371
|
+
listPrompts(): Promise<{
|
|
372
|
+
[x: string]: unknown;
|
|
373
|
+
prompts: {
|
|
374
|
+
name: string;
|
|
375
|
+
description?: string | undefined;
|
|
376
|
+
arguments?: {
|
|
377
|
+
name: string;
|
|
378
|
+
description?: string | undefined;
|
|
379
|
+
required?: boolean | undefined;
|
|
380
|
+
}[] | undefined;
|
|
381
|
+
_meta?: {
|
|
382
|
+
[x: string]: unknown;
|
|
383
|
+
} | undefined;
|
|
384
|
+
icons?: {
|
|
385
|
+
src: string;
|
|
386
|
+
mimeType?: string | undefined;
|
|
387
|
+
sizes?: string[] | undefined;
|
|
388
|
+
theme?: "light" | "dark" | undefined;
|
|
389
|
+
}[] | undefined;
|
|
390
|
+
title?: string | undefined;
|
|
391
|
+
}[];
|
|
392
|
+
_meta?: {
|
|
393
|
+
[x: string]: unknown;
|
|
394
|
+
progressToken?: string | number | undefined;
|
|
395
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
396
|
+
taskId: string;
|
|
397
|
+
} | undefined;
|
|
398
|
+
} | undefined;
|
|
399
|
+
nextCursor?: string | undefined;
|
|
400
|
+
}>;
|
|
401
|
+
getPrompt(name: string, args: Record<string, any>): Promise<{
|
|
402
|
+
[x: string]: unknown;
|
|
403
|
+
messages: {
|
|
404
|
+
role: "user" | "assistant";
|
|
405
|
+
content: {
|
|
406
|
+
type: "text";
|
|
407
|
+
text: string;
|
|
408
|
+
annotations?: {
|
|
409
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
410
|
+
priority?: number | undefined;
|
|
411
|
+
lastModified?: string | undefined;
|
|
412
|
+
} | undefined;
|
|
413
|
+
_meta?: {
|
|
414
|
+
[x: string]: unknown;
|
|
415
|
+
} | undefined;
|
|
416
|
+
} | {
|
|
417
|
+
type: "image";
|
|
418
|
+
data: string;
|
|
419
|
+
mimeType: string;
|
|
420
|
+
annotations?: {
|
|
421
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
422
|
+
priority?: number | undefined;
|
|
423
|
+
lastModified?: string | undefined;
|
|
424
|
+
} | undefined;
|
|
425
|
+
_meta?: {
|
|
426
|
+
[x: string]: unknown;
|
|
427
|
+
} | undefined;
|
|
428
|
+
} | {
|
|
429
|
+
type: "audio";
|
|
430
|
+
data: string;
|
|
431
|
+
mimeType: string;
|
|
432
|
+
annotations?: {
|
|
433
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
434
|
+
priority?: number | undefined;
|
|
435
|
+
lastModified?: string | undefined;
|
|
436
|
+
} | undefined;
|
|
437
|
+
_meta?: {
|
|
438
|
+
[x: string]: unknown;
|
|
439
|
+
} | undefined;
|
|
440
|
+
} | {
|
|
441
|
+
uri: string;
|
|
442
|
+
name: string;
|
|
443
|
+
type: "resource_link";
|
|
444
|
+
description?: string | undefined;
|
|
445
|
+
mimeType?: string | undefined;
|
|
446
|
+
size?: number | undefined;
|
|
447
|
+
annotations?: {
|
|
448
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
449
|
+
priority?: number | undefined;
|
|
450
|
+
lastModified?: string | undefined;
|
|
451
|
+
} | undefined;
|
|
452
|
+
_meta?: {
|
|
453
|
+
[x: string]: unknown;
|
|
454
|
+
} | undefined;
|
|
455
|
+
icons?: {
|
|
456
|
+
src: string;
|
|
457
|
+
mimeType?: string | undefined;
|
|
458
|
+
sizes?: string[] | undefined;
|
|
459
|
+
theme?: "light" | "dark" | undefined;
|
|
460
|
+
}[] | undefined;
|
|
461
|
+
title?: string | undefined;
|
|
462
|
+
} | {
|
|
463
|
+
type: "resource";
|
|
464
|
+
resource: {
|
|
465
|
+
uri: string;
|
|
466
|
+
text: string;
|
|
467
|
+
mimeType?: string | undefined;
|
|
468
|
+
_meta?: {
|
|
469
|
+
[x: string]: unknown;
|
|
470
|
+
} | undefined;
|
|
471
|
+
} | {
|
|
472
|
+
uri: string;
|
|
473
|
+
blob: string;
|
|
474
|
+
mimeType?: string | undefined;
|
|
475
|
+
_meta?: {
|
|
476
|
+
[x: string]: unknown;
|
|
477
|
+
} | undefined;
|
|
478
|
+
};
|
|
479
|
+
annotations?: {
|
|
480
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
481
|
+
priority?: number | undefined;
|
|
482
|
+
lastModified?: string | undefined;
|
|
483
|
+
} | undefined;
|
|
484
|
+
_meta?: {
|
|
485
|
+
[x: string]: unknown;
|
|
486
|
+
} | undefined;
|
|
487
|
+
};
|
|
488
|
+
}[];
|
|
489
|
+
_meta?: {
|
|
490
|
+
[x: string]: unknown;
|
|
491
|
+
progressToken?: string | number | undefined;
|
|
492
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
493
|
+
taskId: string;
|
|
494
|
+
} | undefined;
|
|
495
|
+
} | undefined;
|
|
496
|
+
description?: string | undefined;
|
|
497
|
+
}>;
|
|
498
|
+
/** Send a raw request through the client. */
|
|
499
|
+
request(method: string, params?: Record<string, any> | null, options?: RequestOptions): Promise<unknown>;
|
|
500
|
+
/**
|
|
501
|
+
* Helper to tear down the client & connection manager safely.
|
|
502
|
+
*/
|
|
503
|
+
protected cleanupResources(): Promise<void>;
|
|
504
|
+
}
|
|
505
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@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AAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc;;;;;;;;;IAS/D;;;;;OAKG;IACG,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc;;;;;;;;;IAS7D,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAyBX,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IASvD,6CAA6C;IACvC,OAAO,CACX,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAW,EACzC,OAAO,CAAC,EAAE,cAAc;IAiB1B;;OAEG;cACa,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;CAkClD"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export declare abstract class ConnectionManager<T = any> {
|
|
2
|
+
private _readyPromise;
|
|
3
|
+
private _readyResolver;
|
|
4
|
+
private _donePromise;
|
|
5
|
+
private _doneResolver;
|
|
6
|
+
private _exception;
|
|
7
|
+
private _connection;
|
|
8
|
+
private _task;
|
|
9
|
+
private _abortController;
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Establish the connection.
|
|
13
|
+
*
|
|
14
|
+
* This method should be implemented by subclasses to establish the specific
|
|
15
|
+
* type of connection needed.
|
|
16
|
+
*
|
|
17
|
+
* @returns The established connection.
|
|
18
|
+
* @throws If the connection cannot be established.
|
|
19
|
+
*/
|
|
20
|
+
protected abstract establishConnection(): Promise<T>;
|
|
21
|
+
/**
|
|
22
|
+
* Close the connection.
|
|
23
|
+
*
|
|
24
|
+
* This method should be implemented by subclasses to close the specific type
|
|
25
|
+
* of connection.
|
|
26
|
+
*
|
|
27
|
+
* @param connection The connection to close.
|
|
28
|
+
*/
|
|
29
|
+
protected abstract closeConnection(connection: T): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Start the connection manager and establish a connection.
|
|
32
|
+
*
|
|
33
|
+
* @returns The established connection.
|
|
34
|
+
* @throws If the connection cannot be established.
|
|
35
|
+
*/
|
|
36
|
+
start(): Promise<T>;
|
|
37
|
+
/**
|
|
38
|
+
* Stop the connection manager and close the connection.
|
|
39
|
+
*/
|
|
40
|
+
stop(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Reset all internal state.
|
|
43
|
+
*/
|
|
44
|
+
private reset;
|
|
45
|
+
/**
|
|
46
|
+
* The background task responsible for establishing and maintaining the
|
|
47
|
+
* connection until it is cancelled.
|
|
48
|
+
*/
|
|
49
|
+
private connectionTask;
|
|
50
|
+
/**
|
|
51
|
+
* Helper that returns a promise which resolves when the abort signal fires.
|
|
52
|
+
*/
|
|
53
|
+
private waitForAbort;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=connection-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-manager.d.ts","sourceRoot":"","sources":["../../src/transport/connection-manager.ts"],"names":[],"mappings":"AAEA,8BAAsB,iBAAiB,CAAC,CAAC,GAAG,GAAG;IAC7C,OAAO,CAAC,aAAa,CAAiB;IACtC,OAAO,CAAC,cAAc,CAAc;IAEpC,OAAO,CAAC,YAAY,CAAiB;IACrC,OAAO,CAAC,aAAa,CAAc;IAEnC,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,KAAK,CAA8B;IAC3C,OAAO,CAAC,gBAAgB,CAAgC;;IAMxD;;;;;;;;OAQG;IACH,SAAS,CAAC,QAAQ,CAAC,mBAAmB,IAAI,OAAO,CAAC,CAAC,CAAC;IAEpD;;;;;;;OAOG;IACH,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAEhE;;;;;OAKG;IACG,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC;IAwBzB;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAsB3B;;OAEG;IACH,OAAO,CAAC,KAAK;IASb;;;OAGG;YACW,cAAc;IAqC5B;;OAEG;YACW,YAAY;CAqB3B"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type VersionNegotiationMode } from "@modelcontextprotocol/client";
|
|
2
|
+
import type { ConnectorInitOptions } from "./base.js";
|
|
3
|
+
import { BaseConnector } from "./base.js";
|
|
4
|
+
export type ClientInfo = {
|
|
5
|
+
name: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
version: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
icons?: Array<{
|
|
10
|
+
src: string;
|
|
11
|
+
mimeType?: string;
|
|
12
|
+
sizes?: string[];
|
|
13
|
+
}>;
|
|
14
|
+
websiteUrl?: string;
|
|
15
|
+
};
|
|
16
|
+
interface HttpConnectorOptions extends ConnectorInitOptions {
|
|
17
|
+
authToken?: string;
|
|
18
|
+
fetch?: typeof fetch;
|
|
19
|
+
headers?: Record<string, string>;
|
|
20
|
+
timeout?: number;
|
|
21
|
+
clientInfo?: ClientInfo;
|
|
22
|
+
/**
|
|
23
|
+
* Protocol version negotiation mode passed to the SDK `Client`.
|
|
24
|
+
* - `"legacy"` (default): classic 2025 `initialize` handshake, no probe —
|
|
25
|
+
* matches the SDK's own default. Still connects to both v1 and v2 servers
|
|
26
|
+
* (v2 servers serve 2025-era traffic).
|
|
27
|
+
* - `"auto"`: probe with `server/discover`, falling back to the 2025
|
|
28
|
+
* handshake against legacy servers. Opt-in: the probe performs OAuth
|
|
29
|
+
* discovery on auth-required servers and can fail on servers whose
|
|
30
|
+
* authorization-server issuer differs from the server URL (RFC 8414 §3.3),
|
|
31
|
+
* which would otherwise mask the normal 401 → auth flow.
|
|
32
|
+
* - `{ pin: "2026-07-28" }`: modern era only, no fallback.
|
|
33
|
+
*/
|
|
34
|
+
protocolNegotiation?: VersionNegotiationMode;
|
|
35
|
+
gatewayUrl?: string;
|
|
36
|
+
serverId?: string;
|
|
37
|
+
reconnectionOptions?: {
|
|
38
|
+
maxReconnectionDelay?: number;
|
|
39
|
+
initialReconnectionDelay?: number;
|
|
40
|
+
reconnectionDelayGrowFactor?: number;
|
|
41
|
+
maxRetries?: number;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export declare class HttpConnector extends BaseConnector {
|
|
45
|
+
private readonly baseUrl;
|
|
46
|
+
private readonly headers;
|
|
47
|
+
private readonly timeout;
|
|
48
|
+
private readonly customFetch?;
|
|
49
|
+
private readonly clientInfo;
|
|
50
|
+
private readonly protocolNegotiation;
|
|
51
|
+
private readonly gatewayUrl?;
|
|
52
|
+
private readonly serverId?;
|
|
53
|
+
private readonly reconnectionOptions?;
|
|
54
|
+
private transportType;
|
|
55
|
+
private streamableTransport;
|
|
56
|
+
constructor(baseUrl: string, opts?: HttpConnectorOptions);
|
|
57
|
+
private buildClientOptions;
|
|
58
|
+
private unwrapStreamableError;
|
|
59
|
+
private classifyStreamableHttpFailure;
|
|
60
|
+
/** Establish connection to the MCP implementation via streamable HTTP. */
|
|
61
|
+
connect(): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Tee an SSE response so v2 MRTR progress can be correlated even when the
|
|
64
|
+
* upstream SDK does not carry the original callback to retry request IDs.
|
|
65
|
+
*/
|
|
66
|
+
private observeSseProgress;
|
|
67
|
+
private connectWithStreamableHttp;
|
|
68
|
+
get publicIdentifier(): Record<string, string>;
|
|
69
|
+
/** Get the active transport type (`streamable-http` once connected). */
|
|
70
|
+
getTransportType(): "streamable-http" | null;
|
|
71
|
+
protected cleanupResources(): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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