@tambo-ai/react 0.54.1 → 0.55.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.
Files changed (50) hide show
  1. package/README.md +49 -14
  2. package/dist/hooks/__tests__/use-tambo-threads.test.js +1 -9
  3. package/dist/hooks/__tests__/use-tambo-threads.test.js.map +1 -1
  4. package/dist/mcp/__tests__/mcp-client.test.js +21 -21
  5. package/dist/mcp/__tests__/mcp-client.test.js.map +1 -1
  6. package/dist/mcp/mcp-client.d.ts +61 -210
  7. package/dist/mcp/mcp-client.d.ts.map +1 -1
  8. package/dist/mcp/mcp-client.js +43 -17
  9. package/dist/mcp/mcp-client.js.map +1 -1
  10. package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
  11. package/dist/mcp/tambo-mcp-provider.js +2 -1
  12. package/dist/mcp/tambo-mcp-provider.js.map +1 -1
  13. package/dist/providers/hooks/use-tambo-session-token.d.ts +2 -2
  14. package/dist/providers/hooks/use-tambo-session-token.js +2 -2
  15. package/dist/providers/hooks/use-tambo-session-token.js.map +1 -1
  16. package/dist/providers/tambo-context-helpers-provider.d.ts +7 -2
  17. package/dist/providers/tambo-context-helpers-provider.d.ts.map +1 -1
  18. package/dist/providers/tambo-context-helpers-provider.js +12 -7
  19. package/dist/providers/tambo-context-helpers-provider.js.map +1 -1
  20. package/dist/providers/tambo-prop-stream-provider/index.d.ts +1 -1
  21. package/dist/providers/tambo-prop-stream-provider/index.js +1 -1
  22. package/dist/providers/tambo-prop-stream-provider/index.js.map +1 -1
  23. package/dist/providers/tambo-provider.d.ts +1 -1
  24. package/dist/providers/tambo-provider.js +1 -1
  25. package/dist/providers/tambo-provider.js.map +1 -1
  26. package/esm/hooks/__tests__/use-tambo-threads.test.js +1 -9
  27. package/esm/hooks/__tests__/use-tambo-threads.test.js.map +1 -1
  28. package/esm/mcp/__tests__/mcp-client.test.js +21 -21
  29. package/esm/mcp/__tests__/mcp-client.test.js.map +1 -1
  30. package/esm/mcp/mcp-client.d.ts +61 -210
  31. package/esm/mcp/mcp-client.d.ts.map +1 -1
  32. package/esm/mcp/mcp-client.js +43 -17
  33. package/esm/mcp/mcp-client.js.map +1 -1
  34. package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
  35. package/esm/mcp/tambo-mcp-provider.js +2 -1
  36. package/esm/mcp/tambo-mcp-provider.js.map +1 -1
  37. package/esm/providers/hooks/use-tambo-session-token.d.ts +2 -2
  38. package/esm/providers/hooks/use-tambo-session-token.js +2 -2
  39. package/esm/providers/hooks/use-tambo-session-token.js.map +1 -1
  40. package/esm/providers/tambo-context-helpers-provider.d.ts +7 -2
  41. package/esm/providers/tambo-context-helpers-provider.d.ts.map +1 -1
  42. package/esm/providers/tambo-context-helpers-provider.js +12 -7
  43. package/esm/providers/tambo-context-helpers-provider.js.map +1 -1
  44. package/esm/providers/tambo-prop-stream-provider/index.d.ts +1 -1
  45. package/esm/providers/tambo-prop-stream-provider/index.js +1 -1
  46. package/esm/providers/tambo-prop-stream-provider/index.js.map +1 -1
  47. package/esm/providers/tambo-provider.d.ts +1 -1
  48. package/esm/providers/tambo-provider.js +1 -1
  49. package/esm/providers/tambo-provider.js.map +1 -1
  50. package/package.json +11 -11
@@ -1,3 +1,5 @@
1
+ import { type OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
2
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
1
3
  import { JSONSchema7 } from "json-schema";
2
4
  export declare enum MCPTransport {
3
5
  SSE = "sse",
@@ -17,8 +19,10 @@ export declare class MCPClient {
17
19
  private client;
18
20
  private transport;
19
21
  private transportType;
22
+ sessionId?: string;
20
23
  private endpoint;
21
24
  private headers;
25
+ private authProvider?;
22
26
  /**
23
27
  * Tracks an in-flight reconnect so concurrent triggers coalesce
24
28
  * (single-flight). When set, additional calls to `reconnect()` or
@@ -62,16 +66,19 @@ export declare class MCPClient {
62
66
  */
63
67
  private constructor();
64
68
  /**
65
- * Creates and initializes a new MCPClient instance.
66
- * This is the recommended way to create an MCPClient as it handles both
67
- * instantiation and connection setup.
69
+ * Creates and initializes a new MCPClient instance. This is the recommended
70
+ * way to create an MCPClient as it handles both instantiation and connection
71
+ * setup.
68
72
  * @param endpoint - The URL of the MCP server to connect to
69
73
  * @param transportType - The transport type to use for the MCP client. Defaults to HTTP.
70
74
  * @param headers - Optional custom headers to include in requests
75
+ * @param authProvider - Optional auth provider to use for authentication
76
+ * @param sessionId - Optional session id to use for the MCP client - if not
77
+ * provided, a new session will be created
71
78
  * @returns A connected MCPClient instance ready for use
72
- * @throws Will throw an error if connection fails
79
+ * @throws {Error} Will throw an error if connection fails
73
80
  */
74
- static create(endpoint: string, transportType?: MCPTransport, headers?: Record<string, string>): Promise<MCPClient>;
81
+ static create(endpoint: string, transportType: MCPTransport | undefined, headers: Record<string, string> | undefined, authProvider: OAuthClientProvider | undefined, sessionId: string | undefined): Promise<MCPClient>;
75
82
  /**
76
83
  * Reconnects to the MCP server, optionally retaining the same session ID.
77
84
  *
@@ -89,6 +96,7 @@ export declare class MCPClient {
89
96
  * @param newSession - Whether to create a new session (true) or reuse existing session ID (false)
90
97
  * @param reportErrorOnClose - Whether to report errors when closing the client
91
98
  * Note that only StreamableHTTPClientTransport supports session IDs.
99
+ * @returns A promise that resolves when the reconnect is complete
92
100
  */
93
101
  reconnect(newSession?: boolean, reportErrorOnClose?: boolean): Promise<void>;
94
102
  /**
@@ -99,6 +107,7 @@ export declare class MCPClient {
99
107
  private onclose;
100
108
  /**
101
109
  * Compute the next backoff delay with symmetric jitter.
110
+ * @returns The next backoff delay in milliseconds
102
111
  */
103
112
  private computeBackoffDelayMs;
104
113
  /**
@@ -112,220 +121,62 @@ export declare class MCPClient {
112
121
  * Retrieves a complete list of all available tools from the MCP server.
113
122
  * Handles pagination automatically by following cursors until all tools are fetched.
114
123
  * @returns A complete list of all available tools and their descriptions
115
- * @throws Will throw an error if any server request fails during pagination
124
+ * @throws {Error} Will throw an error if any server request fails during pagination
116
125
  */
117
126
  listTools(): Promise<MCPToolSpec[]>;
127
+ getServerCapabilities(): {
128
+ [x: string]: unknown;
129
+ tools?: {
130
+ [x: string]: unknown;
131
+ listChanged?: boolean | undefined;
132
+ } | undefined;
133
+ experimental?: {
134
+ [x: string]: unknown;
135
+ } | undefined;
136
+ logging?: {
137
+ [x: string]: unknown;
138
+ } | undefined;
139
+ completions?: {
140
+ [x: string]: unknown;
141
+ } | undefined;
142
+ prompts?: {
143
+ [x: string]: unknown;
144
+ listChanged?: boolean | undefined;
145
+ } | undefined;
146
+ resources?: {
147
+ [x: string]: unknown;
148
+ listChanged?: boolean | undefined;
149
+ subscribe?: boolean | undefined;
150
+ } | undefined;
151
+ } | undefined;
152
+ getServerVersion(): {
153
+ [x: string]: unknown;
154
+ name: string;
155
+ version: string;
156
+ title?: string | undefined;
157
+ websiteUrl?: string | undefined;
158
+ icons?: {
159
+ [x: string]: unknown;
160
+ src: string;
161
+ mimeType?: string | undefined;
162
+ sizes?: string | undefined;
163
+ }[] | undefined;
164
+ } | undefined;
165
+ getInstructions(): string | undefined;
118
166
  /**
119
167
  * Calls a specific tool on the MCP server with the provided arguments.
120
168
  * @param name - The name of the tool to call
121
169
  * @param args - Arguments to pass to the tool, must match the tool's expected schema
122
170
  * @returns The result from the tool execution
123
- * @throws Will throw an error if the tool call fails or if arguments are invalid
171
+ * @throws {Error} Will throw an error if the tool call fails or if arguments are invalid
124
172
  */
125
- callTool(name: string, args: Record<string, unknown>): Promise<import("zod").objectOutputType<{
126
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
127
- } & {
128
- content: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodObject<{
129
- type: import("zod").ZodLiteral<"text">;
130
- text: import("zod").ZodString;
131
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
132
- }, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{
133
- type: import("zod").ZodLiteral<"text">;
134
- text: import("zod").ZodString;
135
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
136
- }, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{
137
- type: import("zod").ZodLiteral<"text">;
138
- text: import("zod").ZodString;
139
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
140
- }, import("zod").ZodTypeAny, "passthrough">>, import("zod").ZodObject<{
141
- type: import("zod").ZodLiteral<"image">;
142
- data: import("zod").ZodEffects<import("zod").ZodString, string, string>;
143
- mimeType: import("zod").ZodString;
144
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
145
- }, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{
146
- type: import("zod").ZodLiteral<"image">;
147
- data: import("zod").ZodEffects<import("zod").ZodString, string, string>;
148
- mimeType: import("zod").ZodString;
149
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
150
- }, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{
151
- type: import("zod").ZodLiteral<"image">;
152
- data: import("zod").ZodEffects<import("zod").ZodString, string, string>;
153
- mimeType: import("zod").ZodString;
154
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
155
- }, import("zod").ZodTypeAny, "passthrough">>, import("zod").ZodObject<{
156
- type: import("zod").ZodLiteral<"audio">;
157
- data: import("zod").ZodEffects<import("zod").ZodString, string, string>;
158
- mimeType: import("zod").ZodString;
159
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
160
- }, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{
161
- type: import("zod").ZodLiteral<"audio">;
162
- data: import("zod").ZodEffects<import("zod").ZodString, string, string>;
163
- mimeType: import("zod").ZodString;
164
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
165
- }, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{
166
- type: import("zod").ZodLiteral<"audio">;
167
- data: import("zod").ZodEffects<import("zod").ZodString, string, string>;
168
- mimeType: import("zod").ZodString;
169
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
170
- }, import("zod").ZodTypeAny, "passthrough">>, import("zod").ZodObject<import("zod").objectUtil.extendShape<import("zod").objectUtil.extendShape<{
171
- name: import("zod").ZodString;
172
- title: import("zod").ZodOptional<import("zod").ZodString>;
173
- }, {
174
- uri: import("zod").ZodString;
175
- description: import("zod").ZodOptional<import("zod").ZodString>;
176
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
177
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
178
- }>, {
179
- type: import("zod").ZodLiteral<"resource_link">;
180
- }>, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<import("zod").objectUtil.extendShape<import("zod").objectUtil.extendShape<{
181
- name: import("zod").ZodString;
182
- title: import("zod").ZodOptional<import("zod").ZodString>;
183
- }, {
184
- uri: import("zod").ZodString;
185
- description: import("zod").ZodOptional<import("zod").ZodString>;
186
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
187
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
188
- }>, {
189
- type: import("zod").ZodLiteral<"resource_link">;
190
- }>, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<import("zod").objectUtil.extendShape<import("zod").objectUtil.extendShape<{
191
- name: import("zod").ZodString;
192
- title: import("zod").ZodOptional<import("zod").ZodString>;
193
- }, {
194
- uri: import("zod").ZodString;
195
- description: import("zod").ZodOptional<import("zod").ZodString>;
196
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
197
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
198
- }>, {
199
- type: import("zod").ZodLiteral<"resource_link">;
200
- }>, import("zod").ZodTypeAny, "passthrough">>, import("zod").ZodObject<{
201
- type: import("zod").ZodLiteral<"resource">;
202
- resource: import("zod").ZodUnion<[import("zod").ZodObject<import("zod").objectUtil.extendShape<{
203
- uri: import("zod").ZodString;
204
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
205
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
206
- }, {
207
- text: import("zod").ZodString;
208
- }>, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<import("zod").objectUtil.extendShape<{
209
- uri: import("zod").ZodString;
210
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
211
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
212
- }, {
213
- text: import("zod").ZodString;
214
- }>, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<import("zod").objectUtil.extendShape<{
215
- uri: import("zod").ZodString;
216
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
217
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
218
- }, {
219
- text: import("zod").ZodString;
220
- }>, import("zod").ZodTypeAny, "passthrough">>, import("zod").ZodObject<import("zod").objectUtil.extendShape<{
221
- uri: import("zod").ZodString;
222
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
223
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
224
- }, {
225
- blob: import("zod").ZodEffects<import("zod").ZodString, string, string>;
226
- }>, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<import("zod").objectUtil.extendShape<{
227
- uri: import("zod").ZodString;
228
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
229
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
230
- }, {
231
- blob: import("zod").ZodEffects<import("zod").ZodString, string, string>;
232
- }>, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<import("zod").objectUtil.extendShape<{
233
- uri: import("zod").ZodString;
234
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
235
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
236
- }, {
237
- blob: import("zod").ZodEffects<import("zod").ZodString, string, string>;
238
- }>, import("zod").ZodTypeAny, "passthrough">>]>;
239
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
240
- }, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{
241
- type: import("zod").ZodLiteral<"resource">;
242
- resource: import("zod").ZodUnion<[import("zod").ZodObject<import("zod").objectUtil.extendShape<{
243
- uri: import("zod").ZodString;
244
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
245
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
246
- }, {
247
- text: import("zod").ZodString;
248
- }>, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<import("zod").objectUtil.extendShape<{
249
- uri: import("zod").ZodString;
250
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
251
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
252
- }, {
253
- text: import("zod").ZodString;
254
- }>, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<import("zod").objectUtil.extendShape<{
255
- uri: import("zod").ZodString;
256
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
257
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
258
- }, {
259
- text: import("zod").ZodString;
260
- }>, import("zod").ZodTypeAny, "passthrough">>, import("zod").ZodObject<import("zod").objectUtil.extendShape<{
261
- uri: import("zod").ZodString;
262
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
263
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
264
- }, {
265
- blob: import("zod").ZodEffects<import("zod").ZodString, string, string>;
266
- }>, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<import("zod").objectUtil.extendShape<{
267
- uri: import("zod").ZodString;
268
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
269
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
270
- }, {
271
- blob: import("zod").ZodEffects<import("zod").ZodString, string, string>;
272
- }>, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<import("zod").objectUtil.extendShape<{
273
- uri: import("zod").ZodString;
274
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
275
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
276
- }, {
277
- blob: import("zod").ZodEffects<import("zod").ZodString, string, string>;
278
- }>, import("zod").ZodTypeAny, "passthrough">>]>;
279
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
280
- }, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{
281
- type: import("zod").ZodLiteral<"resource">;
282
- resource: import("zod").ZodUnion<[import("zod").ZodObject<import("zod").objectUtil.extendShape<{
283
- uri: import("zod").ZodString;
284
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
285
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
286
- }, {
287
- text: import("zod").ZodString;
288
- }>, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<import("zod").objectUtil.extendShape<{
289
- uri: import("zod").ZodString;
290
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
291
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
292
- }, {
293
- text: import("zod").ZodString;
294
- }>, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<import("zod").objectUtil.extendShape<{
295
- uri: import("zod").ZodString;
296
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
297
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
298
- }, {
299
- text: import("zod").ZodString;
300
- }>, import("zod").ZodTypeAny, "passthrough">>, import("zod").ZodObject<import("zod").objectUtil.extendShape<{
301
- uri: import("zod").ZodString;
302
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
303
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
304
- }, {
305
- blob: import("zod").ZodEffects<import("zod").ZodString, string, string>;
306
- }>, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<import("zod").objectUtil.extendShape<{
307
- uri: import("zod").ZodString;
308
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
309
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
310
- }, {
311
- blob: import("zod").ZodEffects<import("zod").ZodString, string, string>;
312
- }>, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<import("zod").objectUtil.extendShape<{
313
- uri: import("zod").ZodString;
314
- mimeType: import("zod").ZodOptional<import("zod").ZodString>;
315
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
316
- }, {
317
- blob: import("zod").ZodEffects<import("zod").ZodString, string, string>;
318
- }>, import("zod").ZodTypeAny, "passthrough">>]>;
319
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
320
- }, import("zod").ZodTypeAny, "passthrough">>]>, "many">>;
321
- structuredContent: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
322
- isError: import("zod").ZodOptional<import("zod").ZodBoolean>;
323
- }, import("zod").ZodTypeAny, "passthrough"> | import("zod").objectOutputType<{
324
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
325
- } & {
326
- toolResult: import("zod").ZodUnknown;
327
- }, import("zod").ZodTypeAny, "passthrough">>;
173
+ callTool(name: string, args: Record<string, unknown>): Promise<MCPToolCallResult>;
328
174
  }
175
+ /**
176
+ * The result of a tool call.
177
+ * This is the same as the result of a tool call in the OpenAI SDK, but is reified here
178
+ */
179
+ export type MCPToolCallResult = Awaited<ReturnType<typeof Client.prototype.callTool>>;
329
180
  export interface MCPToolSpec {
330
181
  name: string;
331
182
  description?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-client.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp-client.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,oBAAY,YAAY;IACtB,GAAG,QAAQ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;
26
+ sessionId;
26
27
  endpoint;
27
28
  headers;
29
+ authProvider;
28
30
  /**
29
31
  * Tracks an in-flight reconnect so concurrent triggers coalesce
30
32
  * (single-flight). When set, additional calls to `reconnect()` or
@@ -66,26 +68,33 @@ class MCPClient {
66
68
  * @param transportType - The transport to use for the MCP client
67
69
  * @param headers - Optional custom headers to include in requests
68
70
  */
69
- constructor(endpoint, transportType, headers = {}) {
71
+ constructor(endpoint, transportType, headers, authProvider, sessionId) {
70
72
  this.endpoint = endpoint;
71
- this.headers = headers;
73
+ this.headers = headers ?? {};
74
+ this.authProvider = authProvider;
72
75
  this.transportType = transportType;
73
- this.transport = this.initializeTransport(undefined);
76
+ this.transport = this.initializeTransport(sessionId);
74
77
  this.client = this.initializeClient();
75
78
  }
76
79
  /**
77
- * Creates and initializes a new MCPClient instance.
78
- * This is the recommended way to create an MCPClient as it handles both
79
- * instantiation and connection setup.
80
+ * Creates and initializes a new MCPClient instance. This is the recommended
81
+ * way to create an MCPClient as it handles both instantiation and connection
82
+ * setup.
80
83
  * @param endpoint - The URL of the MCP server to connect to
81
84
  * @param transportType - The transport type to use for the MCP client. Defaults to HTTP.
82
85
  * @param headers - Optional custom headers to include in requests
86
+ * @param authProvider - Optional auth provider to use for authentication
87
+ * @param sessionId - Optional session id to use for the MCP client - if not
88
+ * provided, a new session will be created
83
89
  * @returns A connected MCPClient instance ready for use
84
- * @throws Will throw an error if connection fails
90
+ * @throws {Error} Will throw an error if connection fails
85
91
  */
86
- static async create(endpoint, transportType = MCPTransport.HTTP, headers) {
87
- const mcpClient = new MCPClient(endpoint, transportType, headers);
92
+ static async create(endpoint, transportType = MCPTransport.HTTP, headers, authProvider, sessionId) {
93
+ const mcpClient = new MCPClient(endpoint, transportType, headers, authProvider, sessionId);
88
94
  await mcpClient.client.connect(mcpClient.transport);
95
+ if ("sessionId" in mcpClient.transport) {
96
+ mcpClient.sessionId = mcpClient.transport.sessionId;
97
+ }
89
98
  return mcpClient;
90
99
  }
91
100
  /**
@@ -105,6 +114,7 @@ class MCPClient {
105
114
  * @param newSession - Whether to create a new session (true) or reuse existing session ID (false)
106
115
  * @param reportErrorOnClose - Whether to report errors when closing the client
107
116
  * Note that only StreamableHTTPClientTransport supports session IDs.
117
+ * @returns A promise that resolves when the reconnect is complete
108
118
  */
109
119
  async reconnect(newSession = false, reportErrorOnClose = true) {
110
120
  // If a reconnect is already running, coalesce into it.
@@ -117,11 +127,7 @@ class MCPClient {
117
127
  this.reconnectTimer = undefined;
118
128
  }
119
129
  const doReconnect = async () => {
120
- const sessionId = newSession
121
- ? undefined
122
- : "sessionId" in this.transport
123
- ? this.transport.sessionId
124
- : undefined;
130
+ const sessionId = newSession ? undefined : this.sessionId;
125
131
  // Prevent re-entrant onclose during deliberate close by detaching
126
132
  // the handler from the previous client instance.
127
133
  const prevClient = this.client;
@@ -138,6 +144,14 @@ class MCPClient {
138
144
  this.transport = this.initializeTransport(sessionId);
139
145
  this.client = this.initializeClient();
140
146
  await this.client.connect(this.transport);
147
+ // We may have gotten a session id from the server, so we need to set it
148
+ if ("sessionId" in this.transport) {
149
+ this.sessionId = this.transport.sessionId;
150
+ if (sessionId !== this.sessionId) {
151
+ // This is a pretty unusual thing to happen, but it might be possible?
152
+ console.warn("Session id mismatch", sessionId, this.sessionId);
153
+ }
154
+ }
141
155
  };
142
156
  this.reconnecting = (async () => {
143
157
  try {
@@ -161,6 +175,7 @@ class MCPClient {
161
175
  }
162
176
  /**
163
177
  * Compute the next backoff delay with symmetric jitter.
178
+ * @returns The next backoff delay in milliseconds
164
179
  */
165
180
  computeBackoffDelayMs() {
166
181
  const base = Math.min(MCPClient.BACKOFF_MAX_MS, MCPClient.BACKOFF_INITIAL_MS *
@@ -206,13 +221,15 @@ class MCPClient {
206
221
  initializeTransport(sessionId) {
207
222
  if (this.transportType === MCPTransport.SSE) {
208
223
  return new sse_js_1.SSEClientTransport(new URL(this.endpoint), {
224
+ authProvider: this.authProvider,
209
225
  requestInit: { headers: this.headers },
210
226
  });
211
227
  }
212
228
  else {
213
229
  return new streamableHttp_js_1.StreamableHTTPClientTransport(new URL(this.endpoint), {
214
- sessionId,
230
+ authProvider: this.authProvider,
215
231
  requestInit: { headers: this.headers },
232
+ sessionId,
216
233
  });
217
234
  }
218
235
  }
@@ -228,7 +245,7 @@ class MCPClient {
228
245
  * Retrieves a complete list of all available tools from the MCP server.
229
246
  * Handles pagination automatically by following cursors until all tools are fetched.
230
247
  * @returns A complete list of all available tools and their descriptions
231
- * @throws Will throw an error if any server request fails during pagination
248
+ * @throws {Error} Will throw an error if any server request fails during pagination
232
249
  */
233
250
  async listTools() {
234
251
  const allTools = [];
@@ -255,12 +272,21 @@ class MCPClient {
255
272
  }
256
273
  return allTools;
257
274
  }
275
+ getServerCapabilities() {
276
+ return this.client.getServerCapabilities();
277
+ }
278
+ getServerVersion() {
279
+ return this.client.getServerVersion();
280
+ }
281
+ getInstructions() {
282
+ return this.client.getInstructions();
283
+ }
258
284
  /**
259
285
  * Calls a specific tool on the MCP server with the provided arguments.
260
286
  * @param name - The name of the tool to call
261
287
  * @param args - Arguments to pass to the tool, must match the tool's expected schema
262
288
  * @returns The result from the tool execution
263
- * @throws Will throw an error if the tool call fails or if arguments are invalid
289
+ * @throws {Error} Will throw an error if the tool call fails or if arguments are invalid
264
290
  */
265
291
  async callTool(name, args) {
266
292
  const result = await this.client.callTool({
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-client.js","sourceRoot":"","sources":["../../src/mcp/mcp-client.ts"],"names":[],"mappings":";;;AAAA,wEAAmE;AACnE,oEAA6E;AAC7E,0FAAmG;AAGnG,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,6BAAa,CAAA;AACf,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AACD;;;;;;;;;GASG;AACH,MAAa,SAAS;IACZ,MAAM,CAAS;IACf,SAAS,CAAqD;IAC9D,aAAa,CAAe;IAC5B,QAAQ,CAAS;IACjB,OAAO,CAAy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;QACnC,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,IAAI,MAAM,GAAuB,SAAS,CAAC;QAE3C,OAAO,OAAO,EAAE,CAAC;YACf,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;YAC7D,QAAQ,CAAC,IAAI,CACX,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAe,EAAE;gBAC1C,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBACvC,MAAM,IAAI,KAAK,CACb,yBAAyB,IAAI,CAAC,IAAI,mBAAmB,CACtD,CAAC;gBACJ,CAAC;gBAED,OAAO;oBACL,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,WAAW,EAAE,IAAI,CAAC,WAAW;oBAC7B,WAAW,EAAE,IAAI,CAAC,WAA0B;iBAC7C,CAAC;YACJ,CAAC,CAAC,CACH,CAAC;YAEF,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;gBACxB,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC;YAC/B,CAAC;iBAAM,CAAC;gBACN,OAAO,GAAG,KAAK,CAAC;YAClB,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,QAAQ,CAAC,IAAY,EAAE,IAA6B;QACxD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;YACxC,IAAI;YACJ,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;;AA/RH,8BAgSC","sourcesContent":["import { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport { SSEClientTransport } from \"@modelcontextprotocol/sdk/client/sse.js\";\nimport { StreamableHTTPClientTransport } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\nimport { JSONSchema7 } from \"json-schema\";\n\nexport enum MCPTransport {\n SSE = \"sse\",\n HTTP = \"http\",\n}\n/**\n * A client for interacting with MCP (Model Context Protocol) servers.\n * Provides a simple interface for listing and calling tools exposed by the server.\n * @example\n * ```typescript\n * const mcp = await MCPClient.create('https://api.example.com/mcp');\n * const tools = await mcp.listTools();\n * const result = await mcp.callTool('toolName', { arg1: 'value1' });\n * ```\n */\nexport class MCPClient {\n private client: Client;\n private transport: SSEClientTransport | StreamableHTTPClientTransport;\n private transportType: MCPTransport;\n private endpoint: string;\n private headers: Record<string, string>;\n /**\n * Tracks an in-flight reconnect so concurrent triggers coalesce\n * (single-flight). When set, additional calls to `reconnect()` or\n * the automatic `onclose` handler will await the same Promise instead of\n * starting another reconnect sequence.\n */\n private reconnecting?: Promise<void>;\n /**\n * Timer id for a scheduled automatic reconnect (used by `onclose`).\n * Present only while waiting for the backoff delay to elapse.\n */\n private reconnectTimer?: ReturnType<typeof setTimeout>;\n /**\n * Count of consecutive automatic reconnect failures used to compute\n * exponential backoff. Reset to 0 after a successful connection.\n */\n private backoffAttempts = 0;\n\n /**\n * Backoff policy (discoverable constants)\n * - BACKOFF_INITIAL_MS: initial delay for the first automatic retry\n * - BACKOFF_MULTIPLIER: exponential growth factor for each failed attempt\n * - BACKOFF_MAX_MS: upper bound for the delay\n * - BACKOFF_JITTER_RATIO: jitter range as a fraction of the base delay\n *\n * Jitter is applied symmetrically in [-ratio, +ratio]. For example, with a\n * 500ms base delay and 0.2 ratio, the actual delay is in [400ms, 600ms].\n *\n * The backoff applies only to automatic reconnects started from the\n * `onclose` handler. Explicit/manual calls to `reconnect()` run immediately\n * (no backoff), and will preempt any scheduled automatic attempt.\n */\n static readonly BACKOFF_INITIAL_MS = 500;\n static readonly BACKOFF_MULTIPLIER = 2;\n static readonly BACKOFF_MAX_MS = 30_000;\n static readonly BACKOFF_JITTER_RATIO = 0.2;\n\n /**\n * Private constructor to enforce using the static create method.\n * @param endpoint - The URL of the MCP server to connect to\n * @param transportType - The transport to use for the MCP client\n * @param headers - Optional custom headers to include in requests\n */\n private constructor(\n endpoint: string,\n transportType: MCPTransport,\n headers: Record<string, string> = {},\n ) {\n this.endpoint = endpoint;\n this.headers = headers;\n this.transportType = transportType;\n this.transport = this.initializeTransport(undefined);\n this.client = this.initializeClient();\n }\n\n /**\n * Creates and initializes a new MCPClient instance.\n * This is the recommended way to create an MCPClient as it handles both\n * instantiation and connection setup.\n * @param endpoint - The URL of the MCP server to connect to\n * @param transportType - The transport type to use for the MCP client. Defaults to HTTP.\n * @param headers - Optional custom headers to include in requests\n * @returns A connected MCPClient instance ready for use\n * @throws Will throw an error if connection fails\n */\n static async create(\n endpoint: string,\n transportType: MCPTransport = MCPTransport.HTTP,\n headers?: Record<string, string>,\n ): Promise<MCPClient> {\n const mcpClient = new MCPClient(endpoint, transportType, headers);\n await mcpClient.client.connect(mcpClient.transport);\n return mcpClient;\n }\n /**\n * Reconnects to the MCP server, optionally retaining the same session ID.\n *\n * Single‑flight semantics:\n * - If a reconnect is already in progress (triggered either manually or by\n * the automatic `onclose` handler), additional calls will await the\n * in-flight reconnect rather than start another one.\n * - If an automatic reconnect has been scheduled but not yet started (i.e.,\n * we are waiting in a backoff delay), calling `reconnect()` manually will\n * cancel the scheduled attempt and perform an immediate reconnect.\n *\n * Backoff policy:\n * - Backoff delays with jitter are applied only for automatic reconnects\n * (via `onclose`). Manual calls to `reconnect()` do not use backoff.\n * @param newSession - Whether to create a new session (true) or reuse existing session ID (false)\n * @param reportErrorOnClose - Whether to report errors when closing the client\n * Note that only StreamableHTTPClientTransport supports session IDs.\n */\n async reconnect(newSession = false, reportErrorOnClose = true) {\n // If a reconnect is already running, coalesce into it.\n if (this.reconnecting) {\n return await this.reconnecting;\n }\n\n // Manual reconnect preempts any scheduled automatic attempt.\n if (this.reconnectTimer) {\n clearTimeout(this.reconnectTimer);\n this.reconnectTimer = undefined;\n }\n\n const doReconnect = async () => {\n const sessionId = newSession\n ? undefined\n : \"sessionId\" in this.transport\n ? this.transport.sessionId\n : undefined;\n\n // Prevent re-entrant onclose during deliberate close by detaching\n // the handler from the previous client instance.\n const prevClient = this.client;\n // Prevent re-entrant onclose callbacks from the previous client\n prevClient.onclose = undefined;\n\n try {\n await prevClient.close();\n } catch (error) {\n if (reportErrorOnClose) {\n console.error(\"Error closing Tambo MCP Client:\", error);\n }\n }\n\n this.transport = this.initializeTransport(sessionId);\n this.client = this.initializeClient();\n await this.client.connect(this.transport);\n };\n\n this.reconnecting = (async () => {\n try {\n await doReconnect();\n // Successful manual reconnect: reset backoff.\n this.backoffAttempts = 0;\n } finally {\n this.reconnecting = undefined;\n }\n })();\n\n return await this.reconnecting;\n }\n\n /**\n * Called by the underlying MCP SDK when the connection closes.\n * Schedules an automatic reconnect with bounded exponential backoff and\n * jitter. If a reconnect is already scheduled or running, this is a no-op.\n */\n private onclose() {\n this.scheduleAutoReconnect();\n }\n\n /**\n * Compute the next backoff delay with symmetric jitter.\n */\n private computeBackoffDelayMs(): number {\n const base = Math.min(\n MCPClient.BACKOFF_MAX_MS,\n MCPClient.BACKOFF_INITIAL_MS *\n Math.pow(MCPClient.BACKOFF_MULTIPLIER, this.backoffAttempts),\n );\n const jitterRange = MCPClient.BACKOFF_JITTER_RATIO * base;\n const jitter = (Math.random() * 2 - 1) * jitterRange; // [-range, +range]\n const ms = Math.max(0, Math.round(base + jitter));\n return ms;\n }\n\n /**\n * Schedule an automatic reconnect attempt if one is not already scheduled\n * or running. Uses the backoff policy and self-reschedules on failure.\n */\n private scheduleAutoReconnect() {\n if (this.reconnecting || this.reconnectTimer) {\n return;\n }\n\n const delayMs = this.computeBackoffDelayMs();\n console.warn(\n \"Tambo MCP Client closed; attempting automatic reconnect in\",\n `${delayMs}ms`,\n );\n\n this.reconnectTimer = setTimeout(async () => {\n this.reconnectTimer = undefined;\n // Start the actual reconnect (single-flight)\n const inFlight = (this.reconnecting = this.reconnect(false, false));\n try {\n await inFlight;\n // Success: reset attempts\n this.backoffAttempts = 0;\n } catch (err) {\n // Failure: increase attempts; scheduling occurs in finally below so the\n // new timer isn't blocked by `this.reconnecting` being truthy.\n this.backoffAttempts += 1;\n console.warn(\n \"Automatic reconnect failed; will retry with backoff.\",\n err,\n );\n } finally {\n this.reconnecting = undefined;\n if (this.backoffAttempts > 0) {\n this.scheduleAutoReconnect();\n }\n }\n }, delayMs);\n }\n\n private initializeTransport(sessionId: string | undefined) {\n if (this.transportType === MCPTransport.SSE) {\n return new SSEClientTransport(new URL(this.endpoint), {\n requestInit: { headers: this.headers },\n });\n } else {\n return new StreamableHTTPClientTransport(new URL(this.endpoint), {\n sessionId,\n requestInit: { headers: this.headers },\n });\n }\n }\n\n private initializeClient() {\n const client = new Client({\n name: \"tambo-mcp-client\",\n version: \"1.0.0\",\n });\n client.onclose = this.onclose.bind(this);\n return client;\n }\n\n /**\n * Retrieves a complete list of all available tools from the MCP server.\n * Handles pagination automatically by following cursors until all tools are fetched.\n * @returns A complete list of all available tools and their descriptions\n * @throws Will throw an error if any server request fails during pagination\n */\n async listTools(): Promise<MCPToolSpec[]> {\n const allTools: MCPToolSpec[] = [];\n let hasMore = true;\n let cursor: string | undefined = undefined;\n\n while (hasMore) {\n const response = await this.client.listTools({ cursor }, {});\n allTools.push(\n ...response.tools.map((tool): MCPToolSpec => {\n if (tool.inputSchema.type !== \"object\") {\n throw new Error(\n `Input schema for tool ${tool.name} is not an object`,\n );\n }\n\n return {\n name: tool.name,\n description: tool.description,\n inputSchema: tool.inputSchema as JSONSchema7,\n };\n }),\n );\n\n if (response.nextCursor) {\n cursor = response.nextCursor;\n } else {\n hasMore = false;\n }\n }\n\n return allTools;\n }\n\n /**\n * Calls a specific tool on the MCP server with the provided arguments.\n * @param name - The name of the tool to call\n * @param args - Arguments to pass to the tool, must match the tool's expected schema\n * @returns The result from the tool execution\n * @throws Will throw an error if the tool call fails or if arguments are invalid\n */\n async callTool(name: string, args: Record<string, unknown>) {\n const result = await this.client.callTool({\n name,\n arguments: args,\n });\n return result;\n }\n}\n\n// Example usage:\n/*\nconst mcp = await MCPClient.create('https://api.example.com/mcp', MCPTransport.HTTP);\nconst tools = await mcp.listTools();\nconst result = await mcp.callTool('toolName', { arg1: 'value1' });\n*/\n\nexport interface MCPToolSpec {\n name: string;\n description?: string;\n inputSchema?: JSONSchema7;\n}\n"]}
1
+ {"version":3,"file":"mcp-client.js","sourceRoot":"","sources":["../../src/mcp/mcp-client.ts"],"names":[],"mappings":";;;AACA,wEAAmE;AACnE,oEAA6E;AAC7E,0FAAmG;AAGnG,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,6BAAa,CAAA;AACf,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AACD;;;;;;;;;GASG;AACH,MAAa,SAAS;IACZ,MAAM,CAAS;IACf,SAAS,CAAqD;IAC9D,aAAa,CAAe;IAC7B,SAAS,CAAU;IAClB,QAAQ,CAAS;IACjB,OAAO,CAAyB;IAChC,YAAY,CAAuB;IAC3C;;;;;OAKG;IACK,YAAY,CAAiB;IACrC;;;OAGG;IACK,cAAc,CAAiC;IACvD;;;OAGG;IACK,eAAe,GAAG,CAAC,CAAC;IAE5B;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAU,kBAAkB,GAAG,GAAG,CAAC;IACzC,MAAM,CAAU,kBAAkB,GAAG,CAAC,CAAC;IACvC,MAAM,CAAU,cAAc,GAAG,MAAM,CAAC;IACxC,MAAM,CAAU,oBAAoB,GAAG,GAAG,CAAC;IAE3C;;;;;OAKG;IACH,YACE,QAAgB,EAChB,aAA2B,EAC3B,OAAgC,EAChC,YAAkC,EAClC,SAAkB;QAElB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,SA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,OAAO,MAAM,CAAC;IAChB,CAAC;;AAzUH,8BA0UC","sourcesContent":["import { type OAuthClientProvider } from \"@modelcontextprotocol/sdk/client/auth.js\";\nimport { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport { SSEClientTransport } from \"@modelcontextprotocol/sdk/client/sse.js\";\nimport { StreamableHTTPClientTransport } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\nimport { JSONSchema7 } from \"json-schema\";\n\nexport enum MCPTransport {\n SSE = \"sse\",\n HTTP = \"http\",\n}\n/**\n * A client for interacting with MCP (Model Context Protocol) servers.\n * Provides a simple interface for listing and calling tools exposed by the server.\n * @example\n * ```typescript\n * const mcp = await MCPClient.create('https://api.example.com/mcp');\n * const tools = await mcp.listTools();\n * const result = await mcp.callTool('toolName', { arg1: 'value1' });\n * ```\n */\nexport class MCPClient {\n private client: Client;\n private transport: SSEClientTransport | StreamableHTTPClientTransport;\n private transportType: MCPTransport;\n public sessionId?: string;\n private endpoint: string;\n private headers: Record<string, string>;\n private authProvider?: OAuthClientProvider;\n /**\n * Tracks an in-flight reconnect so concurrent triggers coalesce\n * (single-flight). When set, additional calls to `reconnect()` or\n * the automatic `onclose` handler will await the same Promise instead of\n * starting another reconnect sequence.\n */\n private reconnecting?: Promise<void>;\n /**\n * Timer id for a scheduled automatic reconnect (used by `onclose`).\n * Present only while waiting for the backoff delay to elapse.\n */\n private reconnectTimer?: ReturnType<typeof setTimeout>;\n /**\n * Count of consecutive automatic reconnect failures used to compute\n * exponential backoff. Reset to 0 after a successful connection.\n */\n private backoffAttempts = 0;\n\n /**\n * Backoff policy (discoverable constants)\n * - BACKOFF_INITIAL_MS: initial delay for the first automatic retry\n * - BACKOFF_MULTIPLIER: exponential growth factor for each failed attempt\n * - BACKOFF_MAX_MS: upper bound for the delay\n * - BACKOFF_JITTER_RATIO: jitter range as a fraction of the base delay\n *\n * Jitter is applied symmetrically in [-ratio, +ratio]. For example, with a\n * 500ms base delay and 0.2 ratio, the actual delay is in [400ms, 600ms].\n *\n * The backoff applies only to automatic reconnects started from the\n * `onclose` handler. Explicit/manual calls to `reconnect()` run immediately\n * (no backoff), and will preempt any scheduled automatic attempt.\n */\n static readonly BACKOFF_INITIAL_MS = 500;\n static readonly BACKOFF_MULTIPLIER = 2;\n static readonly BACKOFF_MAX_MS = 30_000;\n static readonly BACKOFF_JITTER_RATIO = 0.2;\n\n /**\n * Private constructor to enforce using the static create method.\n * @param endpoint - The URL of the MCP server to connect to\n * @param transportType - The transport to use for the MCP client\n * @param headers - Optional custom headers to include in requests\n */\n private constructor(\n endpoint: string,\n transportType: MCPTransport,\n headers?: Record<string, string>,\n authProvider?: OAuthClientProvider,\n sessionId?: string,\n ) {\n this.endpoint = endpoint;\n this.headers = headers ?? {};\n this.authProvider = authProvider;\n this.transportType = transportType;\n this.transport = this.initializeTransport(sessionId);\n this.client = this.initializeClient();\n }\n\n /**\n * Creates and initializes a new MCPClient instance. This is the recommended\n * way to create an MCPClient as it handles both instantiation and connection\n * setup.\n * @param endpoint - The URL of the MCP server to connect to\n * @param transportType - The transport type to use for the MCP client. Defaults to HTTP.\n * @param headers - Optional custom headers to include in requests\n * @param authProvider - Optional auth provider to use for authentication\n * @param sessionId - Optional session id to use for the MCP client - if not\n * provided, a new session will be created\n * @returns A connected MCPClient instance ready for use\n * @throws {Error} Will throw an error if connection fails\n */\n static async create(\n endpoint: string,\n transportType: MCPTransport = MCPTransport.HTTP,\n headers: Record<string, string> | undefined,\n authProvider: OAuthClientProvider | undefined,\n sessionId: string | undefined,\n ): Promise<MCPClient> {\n const mcpClient = new MCPClient(\n endpoint,\n transportType,\n headers,\n authProvider,\n sessionId,\n );\n await mcpClient.client.connect(mcpClient.transport);\n if (\"sessionId\" in mcpClient.transport) {\n mcpClient.sessionId = mcpClient.transport.sessionId;\n }\n return mcpClient;\n }\n /**\n * Reconnects to the MCP server, optionally retaining the same session ID.\n *\n * Single‑flight semantics:\n * - If a reconnect is already in progress (triggered either manually or by\n * the automatic `onclose` handler), additional calls will await the\n * in-flight reconnect rather than start another one.\n * - If an automatic reconnect has been scheduled but not yet started (i.e.,\n * we are waiting in a backoff delay), calling `reconnect()` manually will\n * cancel the scheduled attempt and perform an immediate reconnect.\n *\n * Backoff policy:\n * - Backoff delays with jitter are applied only for automatic reconnects\n * (via `onclose`). Manual calls to `reconnect()` do not use backoff.\n * @param newSession - Whether to create a new session (true) or reuse existing session ID (false)\n * @param reportErrorOnClose - Whether to report errors when closing the client\n * Note that only StreamableHTTPClientTransport supports session IDs.\n * @returns A promise that resolves when the reconnect is complete\n */\n async reconnect(newSession = false, reportErrorOnClose = true) {\n // If a reconnect is already running, coalesce into it.\n if (this.reconnecting) {\n return await this.reconnecting;\n }\n\n // Manual reconnect preempts any scheduled automatic attempt.\n if (this.reconnectTimer) {\n clearTimeout(this.reconnectTimer);\n this.reconnectTimer = undefined;\n }\n\n const doReconnect = async () => {\n const sessionId = newSession ? undefined : this.sessionId;\n\n // Prevent re-entrant onclose during deliberate close by detaching\n // the handler from the previous client instance.\n const prevClient = this.client;\n // Prevent re-entrant onclose callbacks from the previous client\n prevClient.onclose = undefined;\n\n try {\n await prevClient.close();\n } catch (error) {\n if (reportErrorOnClose) {\n console.error(\"Error closing Tambo MCP Client:\", error);\n }\n }\n\n this.transport = this.initializeTransport(sessionId);\n this.client = this.initializeClient();\n await this.client.connect(this.transport);\n // We may have gotten a session id from the server, so we need to set it\n if (\"sessionId\" in this.transport) {\n this.sessionId = this.transport.sessionId;\n if (sessionId !== this.sessionId) {\n // This is a pretty unusual thing to happen, but it might be possible?\n console.warn(\"Session id mismatch\", sessionId, this.sessionId);\n }\n }\n };\n\n this.reconnecting = (async () => {\n try {\n await doReconnect();\n // Successful manual reconnect: reset backoff.\n this.backoffAttempts = 0;\n } finally {\n this.reconnecting = undefined;\n }\n })();\n\n return await this.reconnecting;\n }\n\n /**\n * Called by the underlying MCP SDK when the connection closes.\n * Schedules an automatic reconnect with bounded exponential backoff and\n * jitter. If a reconnect is already scheduled or running, this is a no-op.\n */\n private onclose() {\n this.scheduleAutoReconnect();\n }\n\n /**\n * Compute the next backoff delay with symmetric jitter.\n * @returns The next backoff delay in milliseconds\n */\n private computeBackoffDelayMs(): number {\n const base = Math.min(\n MCPClient.BACKOFF_MAX_MS,\n MCPClient.BACKOFF_INITIAL_MS *\n Math.pow(MCPClient.BACKOFF_MULTIPLIER, this.backoffAttempts),\n );\n const jitterRange = MCPClient.BACKOFF_JITTER_RATIO * base;\n const jitter = (Math.random() * 2 - 1) * jitterRange; // [-range, +range]\n const ms = Math.max(0, Math.round(base + jitter));\n return ms;\n }\n\n /**\n * Schedule an automatic reconnect attempt if one is not already scheduled\n * or running. Uses the backoff policy and self-reschedules on failure.\n */\n private scheduleAutoReconnect() {\n if (this.reconnecting || this.reconnectTimer) {\n return;\n }\n\n const delayMs = this.computeBackoffDelayMs();\n console.warn(\n \"Tambo MCP Client closed; attempting automatic reconnect in\",\n `${delayMs}ms`,\n );\n\n this.reconnectTimer = setTimeout(async () => {\n this.reconnectTimer = undefined;\n // Start the actual reconnect (single-flight)\n const inFlight = (this.reconnecting = this.reconnect(false, false));\n try {\n await inFlight;\n // Success: reset attempts\n this.backoffAttempts = 0;\n } catch (err) {\n // Failure: increase attempts; scheduling occurs in finally below so the\n // new timer isn't blocked by `this.reconnecting` being truthy.\n this.backoffAttempts += 1;\n console.warn(\n \"Automatic reconnect failed; will retry with backoff.\",\n err,\n );\n } finally {\n this.reconnecting = undefined;\n if (this.backoffAttempts > 0) {\n this.scheduleAutoReconnect();\n }\n }\n }, delayMs);\n }\n\n private initializeTransport(sessionId: string | undefined) {\n if (this.transportType === MCPTransport.SSE) {\n return new SSEClientTransport(new URL(this.endpoint), {\n authProvider: this.authProvider,\n requestInit: { headers: this.headers },\n });\n } else {\n return new StreamableHTTPClientTransport(new URL(this.endpoint), {\n authProvider: this.authProvider,\n requestInit: { headers: this.headers },\n sessionId,\n });\n }\n }\n\n private initializeClient() {\n const client = new Client({\n name: \"tambo-mcp-client\",\n version: \"1.0.0\",\n });\n client.onclose = this.onclose.bind(this);\n return client;\n }\n\n /**\n * Retrieves a complete list of all available tools from the MCP server.\n * Handles pagination automatically by following cursors until all tools are fetched.\n * @returns A complete list of all available tools and their descriptions\n * @throws {Error} Will throw an error if any server request fails during pagination\n */\n async listTools(): Promise<MCPToolSpec[]> {\n const allTools: MCPToolSpec[] = [];\n let hasMore = true;\n let cursor: string | undefined = undefined;\n\n while (hasMore) {\n const response = await this.client.listTools({ cursor }, {});\n allTools.push(\n ...response.tools.map((tool): MCPToolSpec => {\n if (tool.inputSchema.type !== \"object\") {\n throw new Error(\n `Input schema for tool ${tool.name} is not an object`,\n );\n }\n\n return {\n name: tool.name,\n description: tool.description,\n inputSchema: tool.inputSchema as JSONSchema7,\n };\n }),\n );\n\n if (response.nextCursor) {\n cursor = response.nextCursor;\n } else {\n hasMore = false;\n }\n }\n\n return allTools;\n }\n\n getServerCapabilities() {\n return this.client.getServerCapabilities();\n }\n\n getServerVersion() {\n return this.client.getServerVersion();\n }\n\n getInstructions() {\n return this.client.getInstructions();\n }\n\n /**\n * Calls a specific tool on the MCP server with the provided arguments.\n * @param name - The name of the tool to call\n * @param args - Arguments to pass to the tool, must match the tool's expected schema\n * @returns The result from the tool execution\n * @throws {Error} Will throw an error if the tool call fails or if arguments are invalid\n */\n async callTool(\n name: string,\n args: Record<string, unknown>,\n ): Promise<MCPToolCallResult> {\n const result = await this.client.callTool({\n name,\n arguments: args,\n });\n return result;\n }\n}\n\n/**\n * The result of a tool call.\n * This is the same as the result of a tool call in the OpenAI SDK, but is reified here\n */\nexport type MCPToolCallResult = Awaited<\n ReturnType<typeof Client.prototype.callTool>\n>;\n\n// Example usage:\n/*\nconst mcp = await MCPClient.create('https://api.example.com/mcp', MCPTransport.HTTP);\nconst tools = await mcp.listTools();\nconst result = await mcp.callTool('toolName', { arg1: 'value1' });\n*/\n\nexport interface MCPToolSpec {\n name: string;\n description?: string;\n inputSchema?: JSONSchema7;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-mcp-provider.d.ts","sourceRoot":"","sources":["../../src/mcp/tambo-mcp-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAEZ,EAAE,EAIH,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEvD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAsB5D;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACvD,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,eAAe,EAAE,KAAK,CAAC;CACxB;AAED,MAAM,MAAM,SAAS,GAAG,kBAAkB,GAAG,eAAe,CAAC;AAG7D;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC;IAChC,UAAU,EAAE,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAsIA,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,kBAAkB,mBAE9B,CAAC"}
1
+ {"version":3,"file":"tambo-mcp-provider.d.ts","sourceRoot":"","sources":["../../src/mcp/tambo-mcp-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAEZ,EAAE,EAIH,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEvD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAsB5D;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACvD,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,eAAe,EAAE,KAAK,CAAC;CACxB;AAED,MAAM,MAAM,SAAS,GAAG,kBAAkB,GAAG,eAAe,CAAC;AAG7D;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC;IAChC,UAAU,EAAE,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAwIA,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,kBAAkB,mBAE9B,CAAC"}
@@ -83,7 +83,8 @@ const TamboMcpProvider = ({ mcpServers, children }) => {
83
83
  // initialize the MCP clients, converting McpServerInfo -> McpServer
84
84
  const mcpServers = await Promise.allSettled(mcpServerInfos.map(async (mcpServerInfo) => {
85
85
  try {
86
- const client = await mcp_client_1.MCPClient.create(mcpServerInfo.url, mcpServerInfo.transport, mcpServerInfo.customHeaders);
86
+ const client = await mcp_client_1.MCPClient.create(mcpServerInfo.url, mcpServerInfo.transport, mcpServerInfo.customHeaders, undefined, // no oauth support yet
87
+ undefined);
87
88
  const connectedMcpServer = {
88
89
  ...mcpServerInfo,
89
90
  client: client,