@tambo-ai/react 0.64.1 → 0.65.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/README.md +304 -327
  2. package/dist/hooks/use-tambo-threads.d.ts +0 -12
  3. package/dist/hooks/use-tambo-threads.d.ts.map +1 -1
  4. package/dist/hooks/use-tambo-threads.js.map +1 -1
  5. package/dist/index.d.ts +3 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +6 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/mcp/__tests__/elicitation.test.js +7 -3
  10. package/dist/mcp/__tests__/elicitation.test.js.map +1 -1
  11. package/dist/mcp/__tests__/mcp-hooks.test.js +149 -123
  12. package/dist/mcp/__tests__/mcp-hooks.test.js.map +1 -1
  13. package/dist/mcp/__tests__/tambo-mcp-provider.test.js +176 -120
  14. package/dist/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -1
  15. package/dist/mcp/__tests__/use-mcp-servers.test.js +12 -9
  16. package/dist/mcp/__tests__/use-mcp-servers.test.js.map +1 -1
  17. package/dist/mcp/elicitation.d.ts +4 -40
  18. package/dist/mcp/elicitation.d.ts.map +1 -1
  19. package/dist/mcp/elicitation.js +1 -1
  20. package/dist/mcp/elicitation.js.map +1 -1
  21. package/dist/mcp/index.d.ts +2 -1
  22. package/dist/mcp/index.d.ts.map +1 -1
  23. package/dist/mcp/index.js +2 -1
  24. package/dist/mcp/index.js.map +1 -1
  25. package/dist/mcp/mcp-client.d.ts +14 -26
  26. package/dist/mcp/mcp-client.d.ts.map +1 -1
  27. package/dist/mcp/mcp-client.js +4 -7
  28. package/dist/mcp/mcp-client.js.map +1 -1
  29. package/dist/mcp/mcp-hooks.d.ts +27 -78
  30. package/dist/mcp/mcp-hooks.d.ts.map +1 -1
  31. package/dist/mcp/tambo-mcp-provider.d.ts +27 -45
  32. package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
  33. package/dist/mcp/tambo-mcp-provider.js +36 -87
  34. package/dist/mcp/tambo-mcp-provider.js.map +1 -1
  35. package/dist/model/mcp-server-info.d.ts +74 -0
  36. package/dist/model/mcp-server-info.d.ts.map +1 -0
  37. package/dist/model/mcp-server-info.js +29 -0
  38. package/dist/model/mcp-server-info.js.map +1 -0
  39. package/dist/providers/__tests__/tambo-thread-provider-initial-messages.test.js +22 -8
  40. package/dist/providers/__tests__/tambo-thread-provider-initial-messages.test.js.map +1 -1
  41. package/dist/providers/__tests__/tambo-thread-provider.test.js +318 -129
  42. package/dist/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
  43. package/dist/providers/index.d.ts +1 -1
  44. package/dist/providers/index.d.ts.map +1 -1
  45. package/dist/providers/index.js +2 -1
  46. package/dist/providers/index.js.map +1 -1
  47. package/dist/providers/tambo-client-provider.d.ts +4 -0
  48. package/dist/providers/tambo-client-provider.d.ts.map +1 -1
  49. package/dist/providers/tambo-client-provider.js +3 -0
  50. package/dist/providers/tambo-client-provider.js.map +1 -1
  51. package/dist/providers/tambo-mcp-token-provider.d.ts +3 -0
  52. package/dist/providers/tambo-mcp-token-provider.d.ts.map +1 -1
  53. package/dist/providers/tambo-mcp-token-provider.js +11 -3
  54. package/dist/providers/tambo-mcp-token-provider.js.map +1 -1
  55. package/dist/providers/tambo-provider.d.ts +1 -0
  56. package/dist/providers/tambo-provider.d.ts.map +1 -1
  57. package/dist/providers/tambo-provider.js +10 -5
  58. package/dist/providers/tambo-provider.js.map +1 -1
  59. package/dist/providers/tambo-registry-provider.d.ts +37 -0
  60. package/dist/providers/tambo-registry-provider.d.ts.map +1 -1
  61. package/dist/providers/tambo-registry-provider.js +162 -2
  62. package/dist/providers/tambo-registry-provider.js.map +1 -1
  63. package/dist/providers/tambo-stubs.d.ts.map +1 -1
  64. package/dist/providers/tambo-stubs.js +10 -1
  65. package/dist/providers/tambo-stubs.js.map +1 -1
  66. package/esm/hooks/use-tambo-threads.d.ts +0 -12
  67. package/esm/hooks/use-tambo-threads.d.ts.map +1 -1
  68. package/esm/hooks/use-tambo-threads.js.map +1 -1
  69. package/esm/index.d.ts +3 -1
  70. package/esm/index.d.ts.map +1 -1
  71. package/esm/index.js +3 -2
  72. package/esm/index.js.map +1 -1
  73. package/esm/mcp/__tests__/elicitation.test.js +8 -4
  74. package/esm/mcp/__tests__/elicitation.test.js.map +1 -1
  75. package/esm/mcp/__tests__/mcp-hooks.test.js +149 -123
  76. package/esm/mcp/__tests__/mcp-hooks.test.js.map +1 -1
  77. package/esm/mcp/__tests__/tambo-mcp-provider.test.js +178 -122
  78. package/esm/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -1
  79. package/esm/mcp/__tests__/use-mcp-servers.test.js +12 -9
  80. package/esm/mcp/__tests__/use-mcp-servers.test.js.map +1 -1
  81. package/esm/mcp/elicitation.d.ts +4 -40
  82. package/esm/mcp/elicitation.d.ts.map +1 -1
  83. package/esm/mcp/elicitation.js +2 -2
  84. package/esm/mcp/elicitation.js.map +1 -1
  85. package/esm/mcp/index.d.ts +2 -1
  86. package/esm/mcp/index.d.ts.map +1 -1
  87. package/esm/mcp/index.js +1 -1
  88. package/esm/mcp/index.js.map +1 -1
  89. package/esm/mcp/mcp-client.d.ts +14 -26
  90. package/esm/mcp/mcp-client.d.ts.map +1 -1
  91. package/esm/mcp/mcp-client.js +3 -5
  92. package/esm/mcp/mcp-client.js.map +1 -1
  93. package/esm/mcp/mcp-hooks.d.ts +27 -78
  94. package/esm/mcp/mcp-hooks.d.ts.map +1 -1
  95. package/esm/mcp/tambo-mcp-provider.d.ts +27 -45
  96. package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
  97. package/esm/mcp/tambo-mcp-provider.js +35 -86
  98. package/esm/mcp/tambo-mcp-provider.js.map +1 -1
  99. package/esm/model/mcp-server-info.d.ts +74 -0
  100. package/esm/model/mcp-server-info.d.ts.map +1 -0
  101. package/esm/model/mcp-server-info.js +25 -0
  102. package/esm/model/mcp-server-info.js.map +1 -0
  103. package/esm/providers/__tests__/tambo-thread-provider-initial-messages.test.js +23 -9
  104. package/esm/providers/__tests__/tambo-thread-provider-initial-messages.test.js.map +1 -1
  105. package/esm/providers/__tests__/tambo-thread-provider.test.js +319 -130
  106. package/esm/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
  107. package/esm/providers/index.d.ts +1 -1
  108. package/esm/providers/index.d.ts.map +1 -1
  109. package/esm/providers/index.js +1 -1
  110. package/esm/providers/index.js.map +1 -1
  111. package/esm/providers/tambo-client-provider.d.ts +4 -0
  112. package/esm/providers/tambo-client-provider.d.ts.map +1 -1
  113. package/esm/providers/tambo-client-provider.js +3 -0
  114. package/esm/providers/tambo-client-provider.js.map +1 -1
  115. package/esm/providers/tambo-mcp-token-provider.d.ts +3 -0
  116. package/esm/providers/tambo-mcp-token-provider.d.ts.map +1 -1
  117. package/esm/providers/tambo-mcp-token-provider.js +13 -5
  118. package/esm/providers/tambo-mcp-token-provider.js.map +1 -1
  119. package/esm/providers/tambo-provider.d.ts +1 -0
  120. package/esm/providers/tambo-provider.d.ts.map +1 -1
  121. package/esm/providers/tambo-provider.js +11 -6
  122. package/esm/providers/tambo-provider.js.map +1 -1
  123. package/esm/providers/tambo-registry-provider.d.ts +37 -0
  124. package/esm/providers/tambo-registry-provider.d.ts.map +1 -1
  125. package/esm/providers/tambo-registry-provider.js +161 -2
  126. package/esm/providers/tambo-registry-provider.js.map +1 -1
  127. package/esm/providers/tambo-stubs.d.ts.map +1 -1
  128. package/esm/providers/tambo-stubs.js +10 -1
  129. package/esm/providers/tambo-stubs.js.map +1 -1
  130. package/package.json +6 -6
@@ -3,10 +3,8 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
3
3
  import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
4
4
  import { ClientNotification, ClientRequest, CreateMessageRequest, CreateMessageResult, ElicitRequest, ElicitResult } from "@modelcontextprotocol/sdk/types.js";
5
5
  import { JSONSchema7 } from "json-schema";
6
- export declare enum MCPTransport {
7
- SSE = "sse",
8
- HTTP = "http"
9
- }
6
+ import { MCPTransport } from "../model/mcp-server-info";
7
+ export { MCPTransport };
10
8
  /**
11
9
  * Handler for MCP elicitation requests.
12
10
  * Receives the elicit request and a RequestHandlerExtra containing an AbortSignal that fires when the request is cancelled.
@@ -119,42 +117,32 @@ export declare class MCPClient {
119
117
  */
120
118
  listTools(): Promise<MCPToolSpec[]>;
121
119
  getServerCapabilities(): {
122
- [x: string]: unknown;
123
- tools?: {
124
- [x: string]: unknown;
125
- listChanged?: boolean | undefined;
126
- } | undefined;
127
120
  experimental?: {
128
- [x: string]: unknown;
129
- } | undefined;
130
- logging?: {
131
- [x: string]: unknown;
132
- } | undefined;
133
- completions?: {
134
- [x: string]: unknown;
121
+ [x: string]: object;
135
122
  } | undefined;
123
+ logging?: object | undefined | undefined;
124
+ completions?: object | undefined | undefined;
136
125
  prompts?: {
137
- [x: string]: unknown;
138
- listChanged?: boolean | undefined;
126
+ listChanged?: boolean | undefined | undefined;
139
127
  } | undefined;
140
128
  resources?: {
141
- [x: string]: unknown;
142
- listChanged?: boolean | undefined;
143
- subscribe?: boolean | undefined;
129
+ listChanged?: boolean | undefined | undefined;
130
+ subscribe?: boolean | undefined | undefined;
131
+ } | undefined;
132
+ tools?: {
133
+ listChanged?: boolean | undefined | undefined;
144
134
  } | undefined;
145
135
  } | undefined;
146
136
  getServerVersion(): {
147
- [x: string]: unknown;
148
137
  name: string;
149
138
  version: string;
150
- title?: string | undefined;
151
- websiteUrl?: string | undefined;
152
139
  icons?: {
153
- [x: string]: unknown;
154
140
  src: string;
155
- mimeType?: string | undefined;
141
+ mimeType?: string | undefined | undefined;
156
142
  sizes?: string[] | undefined;
157
143
  }[] | undefined;
144
+ title?: string | undefined | undefined;
145
+ websiteUrl?: string | undefined | undefined;
158
146
  } | undefined;
159
147
  getInstructions(): string | undefined;
160
148
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-client.d.ts","sourceRoot":"","sources":["../../src/m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port } from "@modelcontextprotocol/sdk/client/sse.js";
3
3
  import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
4
4
  import { CreateMessageRequestSchema, ElicitRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
5
- export var MCPTransport;
6
- (function (MCPTransport) {
7
- MCPTransport["SSE"] = "sse";
8
- MCPTransport["HTTP"] = "http";
9
- })(MCPTransport || (MCPTransport = {}));
5
+ import { MCPTransport } from "../model/mcp-server-info";
6
+ // Re-export for backwards compatibility
7
+ export { MCPTransport };
10
8
  /**
11
9
  * A client for interacting with MCP (Model Context Protocol) servers.
12
10
  * Provides a simple interface for listing and calling tools exposed by the server.
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-client.js","sourceRoot":"","sources":["../../src/mcp/mcp-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAEnG,OAAO,EAIL,0BAA0B,EAG1B,mBAAmB,GAEpB,MAAM,oCAAoC,CAAC;AAG5C,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,6BAAa,CAAA;AACf,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAgED;;;;;;;;;GASG;AACH,MAAM,OAAO,SAAS;IACpB;;;;OAIG;IACH,MAAM,CAAS;IACP,SAAS,CAAqD;IAC9D,aAAa,CAAe;IAC7B,SAAS,CAAU;IAClB,QAAQ,CAAS;IACjB,OAAO,CAAyB;IAChC,YAAY,CAAuB;IACnC,QAAQ,CAAuB;IAEvC;;;;;OAKG;IACH,YACE,QAAgB,EAChB,aAA2B,EAC3B,OAAgC,EAChC,YAAkC,EAClC,SAAkB,EAClB,WAAiC,EAAE;QAEnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CA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M,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;YACzC,OAAO;QACT,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC;IAED,KAAK,CAAC,KAAK;QACT,yEAAyE;QACzE,yEAAyE;QACzE,UAAU;QACV,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QAC7B,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","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 type { RequestHandlerExtra } from \"@modelcontextprotocol/sdk/shared/protocol.js\";\nimport {\n ClientNotification,\n ClientRequest,\n CreateMessageRequest,\n CreateMessageRequestSchema,\n CreateMessageResult,\n ElicitRequest,\n ElicitRequestSchema,\n ElicitResult,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { JSONSchema7 } from \"json-schema\";\n\nexport enum MCPTransport {\n SSE = \"sse\",\n HTTP = \"http\",\n}\n\n/**\n * Handler for MCP elicitation requests.\n * Receives the elicit request and a RequestHandlerExtra containing an AbortSignal that fires when the request is cancelled.\n * @param request - The elicitation request from the server\n * @param extra - Additional context including AbortSignal for cancellation\n * @returns Promise resolving to the elicitation result\n * @example\n * ```typescript\n * const handler: MCPElicitationHandler = async (request, extra) => {\n * // Listen for cancellation\n * extra.signal.addEventListener('abort', () => {\n * console.log('Request cancelled');\n * });\n *\n * // Return user's response\n * return {\n * action: 'accept',\n * content: { name: 'John' }\n * };\n * };\n * ```\n */\nexport type MCPElicitationHandler = (\n e: ElicitRequest,\n extra: RequestHandlerExtra<ClientRequest, ClientNotification>,\n) => Promise<ElicitResult>;\n\n/**\n * Handler for MCP sampling requests (create_message).\n * Receives the sampling request and a RequestHandlerExtra containing an AbortSignal that fires when the request is cancelled.\n * @param request - The sampling/create_message request from the server\n * @param extra - Additional context including AbortSignal for cancellation\n * @returns Promise resolving to the sampling result\n */\nexport type MCPSamplingHandler = (\n e: CreateMessageRequest,\n extra: RequestHandlerExtra<ClientRequest, ClientNotification>,\n) => Promise<CreateMessageResult>;\n\n/**\n * Handlers for MCP requests - these are only used if the server supports the corresponding capabilities\n * @param elicitation - Handler for elicitation requests (receives request and RequestHandlerExtra with AbortSignal)\n * @param sampling - Handler for sampling requests (receives request and RequestHandlerExtra with AbortSignal)\n * @example\n * ```typescript\n * const mcp = await MCPClient.create(\n * 'https://api.example.com/mcp',\n * MCPTransport.HTTP,\n * {},\n * undefined,\n * undefined,\n * {\n * elicitation: (e, extra) => Promise.resolve({...}),\n * },\n * );\n * ```\n */\nexport interface MCPHandlers {\n elicitation: MCPElicitationHandler;\n sampling: MCPSamplingHandler;\n}\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 /**\n * The underlying MCP client\n *\n * Be careful not to mutate the client directly, use the methods provided instead.\n */\n 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 private handlers: Partial<MCPHandlers>;\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 handlers: Partial<MCPHandlers> = {},\n ) {\n this.endpoint = endpoint;\n this.headers = headers ?? {};\n this.authProvider = authProvider;\n this.transportType = transportType;\n this.handlers = handlers;\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 handlers: Partial<MCPHandlers> = {},\n ): Promise<MCPClient> {\n const mcpClient = new MCPClient(\n endpoint,\n transportType,\n headers,\n authProvider,\n sessionId,\n handlers,\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 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 /**\n * Initializes the MCP client with the appropriate capabilities and handlers\n * @returns The initialized MCP client\n */\n private initializeClient() {\n const elicitationCapability = this.handlers.elicitation\n ? { elicitation: {} }\n : {};\n const samplingCapability = this.handlers.sampling ? { sampling: {} } : {};\n const client = new Client(\n {\n name: \"tambo-mcp-client\",\n version: \"1.0.0\",\n },\n {\n capabilities: {\n ...elicitationCapability,\n ...samplingCapability,\n },\n },\n );\n\n if (this.handlers.elicitation) {\n client.setRequestHandler(ElicitRequestSchema, this.handlers.elicitation);\n }\n if (this.handlers.sampling) {\n client.setRequestHandler(\n CreateMessageRequestSchema,\n this.handlers.sampling,\n );\n }\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 // make sure the right type is used\n const inputSchemaType: string = tool.inputSchema.type;\n if (inputSchemaType !== \"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 _meta?: Record<string, unknown>,\n ): Promise<MCPToolCallResult> {\n const result = await this.client.callTool({\n name,\n arguments: args,\n _meta,\n });\n return result;\n }\n\n updateElicitationHandler(handler: MCPElicitationHandler | undefined) {\n // Skip if handler hasn't changed\n if (handler === this.handlers.elicitation) {\n return;\n }\n\n // Because we advertise the elicitation capability on initial connection, we can only update\n // an existing handler, not add it if we haven't set it yet.\n if (handler && !this.handlers.elicitation) {\n throw new Error(\"Elicitation handler must be set on create\");\n }\n this.handlers = {\n ...this.handlers,\n elicitation: handler,\n };\n if (!handler) {\n const method = ElicitRequestSchema.shape.method.value;\n this.client.removeRequestHandler(method);\n return;\n }\n this.client.setRequestHandler(ElicitRequestSchema, handler);\n }\n\n updateSamplingHandler(handler: MCPSamplingHandler | undefined) {\n // Skip if handler hasn't changed\n if (handler === this.handlers.sampling) {\n return;\n }\n\n // Because we advertise the sampling capability on initial connection, we can only update\n // an existing handler, not add it if we haven't set it yet.\n if (handler && !this.handlers.sampling) {\n throw new Error(\"Sampling handler must be set on create\");\n }\n this.handlers = {\n ...this.handlers,\n sampling: handler,\n };\n if (!handler) {\n const method = CreateMessageRequestSchema.shape.method.value;\n this.client.removeRequestHandler(method);\n return;\n }\n this.client.setRequestHandler(CreateMessageRequestSchema, handler);\n }\n\n async close() {\n // Not really sure which one of these to close first, but we'll close the\n // transport first so that no requests can come in and hit closing/closed\n // clients\n await this.transport.close();\n await this.client.close();\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
+ {"version":3,"file":"mcp-client.js","sourceRoot":"","sources":["../../src/mcp/mcp-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAEnG,OAAO,EAIL,0BAA0B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AAuC;QAC3D,iCAAiC;QACjC,IAAI,OAAO,KAAK,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACvC,OAAO;QACT,CAAC;QAED,yFAAyF;QACzF,4DAA4D;QAC5D,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG;YACd,GAAG,IAAI,CAAC,QAAQ;YAChB,QAAQ,EAAE,OAAO;SAClB,CAAC;QACF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,MAAM,GAAG,0BAA0B,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;YAC7D,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;YACzC,OAAO;QACT,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC;IAED,KAAK,CAAC,KAAK;QACT,yEAAyE;QACzE,yEAAyE;QACzE,UAAU;QACV,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QAC7B,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","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 type { RequestHandlerExtra } from \"@modelcontextprotocol/sdk/shared/protocol.js\";\nimport {\n ClientNotification,\n ClientRequest,\n CreateMessageRequest,\n CreateMessageRequestSchema,\n CreateMessageResult,\n ElicitRequest,\n ElicitRequestSchema,\n ElicitResult,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { JSONSchema7 } from \"json-schema\";\nimport { MCPTransport } from \"../model/mcp-server-info\";\n\n// Re-export for backwards compatibility\nexport { MCPTransport };\n\n/**\n * Handler for MCP elicitation requests.\n * Receives the elicit request and a RequestHandlerExtra containing an AbortSignal that fires when the request is cancelled.\n * @param request - The elicitation request from the server\n * @param extra - Additional context including AbortSignal for cancellation\n * @returns Promise resolving to the elicitation result\n * @example\n * ```typescript\n * const handler: MCPElicitationHandler = async (request, extra) => {\n * // Listen for cancellation\n * extra.signal.addEventListener('abort', () => {\n * console.log('Request cancelled');\n * });\n *\n * // Return user's response\n * return {\n * action: 'accept',\n * content: { name: 'John' }\n * };\n * };\n * ```\n */\nexport type MCPElicitationHandler = (\n e: ElicitRequest,\n extra: RequestHandlerExtra<ClientRequest, ClientNotification>,\n) => Promise<ElicitResult>;\n\n/**\n * Handler for MCP sampling requests (create_message).\n * Receives the sampling request and a RequestHandlerExtra containing an AbortSignal that fires when the request is cancelled.\n * @param request - The sampling/create_message request from the server\n * @param extra - Additional context including AbortSignal for cancellation\n * @returns Promise resolving to the sampling result\n */\nexport type MCPSamplingHandler = (\n e: CreateMessageRequest,\n extra: RequestHandlerExtra<ClientRequest, ClientNotification>,\n) => Promise<CreateMessageResult>;\n\n/**\n * Handlers for MCP requests - these are only used if the server supports the corresponding capabilities\n * @param elicitation - Handler for elicitation requests (receives request and RequestHandlerExtra with AbortSignal)\n * @param sampling - Handler for sampling requests (receives request and RequestHandlerExtra with AbortSignal)\n * @example\n * ```typescript\n * const mcp = await MCPClient.create(\n * 'https://api.example.com/mcp',\n * MCPTransport.HTTP,\n * {},\n * undefined,\n * undefined,\n * {\n * elicitation: (e, extra) => Promise.resolve({...}),\n * },\n * );\n * ```\n */\nexport interface MCPHandlers {\n elicitation: MCPElicitationHandler;\n sampling: MCPSamplingHandler;\n}\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 /**\n * The underlying MCP client\n *\n * Be careful not to mutate the client directly, use the methods provided instead.\n */\n 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 private handlers: Partial<MCPHandlers>;\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 handlers: Partial<MCPHandlers> = {},\n ) {\n this.endpoint = endpoint;\n this.headers = headers ?? {};\n this.authProvider = authProvider;\n this.transportType = transportType;\n this.handlers = handlers;\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 handlers: Partial<MCPHandlers> = {},\n ): Promise<MCPClient> {\n const mcpClient = new MCPClient(\n endpoint,\n transportType,\n headers,\n authProvider,\n sessionId,\n handlers,\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 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 /**\n * Initializes the MCP client with the appropriate capabilities and handlers\n * @returns The initialized MCP client\n */\n private initializeClient() {\n const elicitationCapability = this.handlers.elicitation\n ? { elicitation: {} }\n : {};\n const samplingCapability = this.handlers.sampling ? { sampling: {} } : {};\n const client = new Client(\n {\n name: \"tambo-mcp-client\",\n version: \"1.0.0\",\n },\n {\n capabilities: {\n ...elicitationCapability,\n ...samplingCapability,\n },\n },\n );\n\n if (this.handlers.elicitation) {\n client.setRequestHandler(ElicitRequestSchema, this.handlers.elicitation);\n }\n if (this.handlers.sampling) {\n client.setRequestHandler(\n CreateMessageRequestSchema,\n this.handlers.sampling,\n );\n }\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 // make sure the right type is used\n const inputSchemaType: string = tool.inputSchema.type;\n if (inputSchemaType !== \"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 _meta?: Record<string, unknown>,\n ): Promise<MCPToolCallResult> {\n const result = await this.client.callTool({\n name,\n arguments: args,\n _meta,\n });\n return result;\n }\n\n updateElicitationHandler(handler: MCPElicitationHandler | undefined) {\n // Skip if handler hasn't changed\n if (handler === this.handlers.elicitation) {\n return;\n }\n\n // Because we advertise the elicitation capability on initial connection, we can only update\n // an existing handler, not add it if we haven't set it yet.\n if (handler && !this.handlers.elicitation) {\n throw new Error(\"Elicitation handler must be set on create\");\n }\n this.handlers = {\n ...this.handlers,\n elicitation: handler,\n };\n if (!handler) {\n const method = ElicitRequestSchema.shape.method.value;\n this.client.removeRequestHandler(method);\n return;\n }\n this.client.setRequestHandler(ElicitRequestSchema, handler);\n }\n\n updateSamplingHandler(handler: MCPSamplingHandler | undefined) {\n // Skip if handler hasn't changed\n if (handler === this.handlers.sampling) {\n return;\n }\n\n // Because we advertise the sampling capability on initial connection, we can only update\n // an existing handler, not add it if we haven't set it yet.\n if (handler && !this.handlers.sampling) {\n throw new Error(\"Sampling handler must be set on create\");\n }\n this.handlers = {\n ...this.handlers,\n sampling: handler,\n };\n if (!handler) {\n const method = CreateMessageRequestSchema.shape.method.value;\n this.client.removeRequestHandler(method);\n return;\n }\n this.client.setRequestHandler(CreateMessageRequestSchema, handler);\n }\n\n async close() {\n // Not really sure which one of these to close first, but we'll close the\n // transport first so that no requests can come in and hit closing/closed\n // clients\n await this.transport.close();\n await this.client.close();\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"]}
@@ -16,29 +16,7 @@ export interface ListResourceEntry {
16
16
  * @returns The prompts for the MCP servers, including the server that the prompt was found on.
17
17
  */
18
18
  export declare function useTamboMcpPromptList(): {
19
- data: {
20
- prompt: {
21
- name: string;
22
- title?: string | undefined;
23
- description?: string | undefined;
24
- _meta?: {
25
- [x: string]: unknown;
26
- } | undefined;
27
- arguments?: {
28
- [x: string]: unknown;
29
- name: string;
30
- description?: string | undefined;
31
- required?: boolean | undefined;
32
- }[] | undefined;
33
- icons?: {
34
- [x: string]: unknown;
35
- src: string;
36
- mimeType?: string | undefined;
37
- sizes?: string[] | undefined;
38
- }[] | undefined;
39
- };
40
- server: ConnectedMcpServer;
41
- }[];
19
+ data: ListPromptEntry[];
42
20
  error: Error | null;
43
21
  errors: Error[];
44
22
  isPending: boolean;
@@ -59,72 +37,63 @@ export declare function useTamboMcpPromptList(): {
59
37
  export declare function useTamboMcpPrompt(promptName: string | undefined, args?: Record<string, string>): UseQueryResult<{
60
38
  [x: string]: unknown;
61
39
  messages: {
62
- [x: string]: unknown;
40
+ role: "user" | "assistant";
63
41
  content: {
64
- [x: string]: unknown;
65
- text: string;
66
42
  type: "text";
43
+ text: string;
67
44
  _meta?: {
68
45
  [x: string]: unknown;
69
46
  } | undefined;
70
47
  } | {
71
- [x: string]: unknown;
72
- data: string;
73
48
  type: "image";
49
+ data: string;
74
50
  mimeType: string;
75
51
  _meta?: {
76
52
  [x: string]: unknown;
77
53
  } | undefined;
78
54
  } | {
79
- [x: string]: unknown;
80
- data: string;
81
55
  type: "audio";
56
+ data: string;
82
57
  mimeType: string;
83
58
  _meta?: {
84
59
  [x: string]: unknown;
85
60
  } | undefined;
86
61
  } | {
87
- [x: string]: unknown;
88
- name: string;
89
- type: "resource_link";
90
- uri: string;
91
- title?: string | undefined;
92
- description?: string | undefined;
93
- _meta?: {
94
- [x: string]: unknown;
95
- } | undefined;
96
- mimeType?: string | undefined;
97
- icons?: {
98
- [x: string]: unknown;
99
- src: string;
100
- mimeType?: string | undefined;
101
- sizes?: string[] | undefined;
102
- }[] | undefined;
103
- } | {
104
- [x: string]: unknown;
105
62
  type: "resource";
106
63
  resource: {
107
- [x: string]: unknown;
108
- text: string;
109
64
  uri: string;
65
+ text: string;
110
66
  _meta?: {
111
67
  [x: string]: unknown;
112
68
  } | undefined;
113
- mimeType?: string | undefined;
69
+ mimeType?: string | undefined | undefined;
114
70
  } | {
115
- [x: string]: unknown;
116
71
  uri: string;
117
72
  blob: string;
118
73
  _meta?: {
119
74
  [x: string]: unknown;
120
75
  } | undefined;
121
- mimeType?: string | undefined;
76
+ mimeType?: string | undefined | undefined;
122
77
  };
123
78
  _meta?: {
124
79
  [x: string]: unknown;
125
80
  } | undefined;
81
+ } | {
82
+ type: "resource_link";
83
+ name: string;
84
+ uri: string;
85
+ _meta?: {
86
+ [x: string]: unknown;
87
+ } | undefined;
88
+ mimeType?: string | undefined | undefined;
89
+ icons?: {
90
+ src: string;
91
+ mimeType?: string | undefined | undefined;
92
+ sizes?: string[] | undefined;
93
+ }[] | undefined;
94
+ title?: string | undefined | undefined;
95
+ description?: string | undefined | undefined;
126
96
  };
127
- role: "user" | "assistant";
128
97
  }[];
129
98
  description?: string | undefined;
130
99
  _meta?: {
@@ -136,25 +105,7 @@ export declare function useTamboMcpPrompt(promptName: string | undefined, args?:
136
105
  * @returns The resources for the MCP servers, including the server that the resource was found on.
137
106
  */
138
107
  export declare function useTamboMcpResourceList(): {
139
- data: {
140
- resource: {
141
- uri: string;
142
- name: string;
143
- title?: string | undefined;
144
- description?: string | undefined;
145
- _meta?: {
146
- [x: string]: unknown;
147
- } | undefined;
148
- mimeType?: string | undefined;
149
- icons?: {
150
- [x: string]: unknown;
151
- src: string;
152
- mimeType?: string | undefined;
153
- sizes?: string[] | undefined;
154
- }[] | undefined;
155
- };
156
- server: ConnectedMcpServer;
157
- }[];
108
+ data: ListResourceEntry[];
158
109
  error: Error | null;
159
110
  errors: Error[];
160
111
  isPending: boolean;
@@ -174,21 +125,19 @@ export declare function useTamboMcpResourceList(): {
174
125
  export declare function useTamboMcpResource(resourceUri: string | undefined): UseQueryResult<{
175
126
  [x: string]: unknown;
176
127
  contents: ({
177
- [x: string]: unknown;
178
- text: string;
179
128
  uri: string;
129
+ text: string;
180
130
  _meta?: {
181
131
  [x: string]: unknown;
182
132
  } | undefined;
183
- mimeType?: string | undefined;
133
+ mimeType?: string | undefined | undefined;
184
134
  } | {
185
- [x: string]: unknown;
186
135
  uri: string;
187
136
  blob: string;
188
137
  _meta?: {
189
138
  [x: string]: unknown;
190
139
  } | undefined;
191
- mimeType?: string | undefined;
140
+ mimeType?: string | undefined | undefined;
192
141
  })[];
193
142
  _meta?: {
194
143
  [x: string]: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-hooks.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EAEzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EACL,KAAK,kBAAkB,EAGxB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAClE,MAAM,WAAW,eAAe;IAE9B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,WAAW,CAAC,C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MAAM,MAAM,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAClE,MAAM,WAAW,eAAe;IAE9B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AACxE,MAAM,WAAW,iBAAiB;IAEhC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAgB,qBAAqB;;WAiD5B,KAAK,GAAG,IAAI;YACX,KAAK,EAAE;eACJ,OAAO;eACP,OAAO;aACT,OAAO;cACN,OAAO;kBACH,OAAO;gBACT,OAAO;eACR,OAAO;aACT,MAAM,OAAO,CAAC,IAAI,CAAC;EAb7B;AAwDD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0ClC;AAED;;;GAGG;AACH,wBAAgB,uBAAuB;;WA5G9B,KAAK,GAAG,IAAI;YACX,KAAK,EAAE;eACJ,OAAO;eACP,OAAO;aACT,OAAO;cACN,OAAO;kBACH,OAAO;gBACT,OAAO;eACR,OAAO;aACT,MAAM,OAAO,CAAC,IAAI,CAAC;EAgJ7B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;iBAqClE"}
@@ -1,5 +1,7 @@
1
1
  import React, { FC } from "react";
2
- import { MCPClient, MCPElicitationHandler, MCPHandlers, MCPSamplingHandler, MCPTransport } from "./mcp-client";
2
+ import { type NormalizedMcpServerInfo } from "../model/mcp-server-info";
3
+ import { type ElicitationContextState } from "./elicitation";
4
+ import { MCPClient, MCPElicitationHandler, MCPHandlers, MCPSamplingHandler } from "./mcp-client";
3
5
  /**
4
6
  * Extracts error message from MCP tool result content.
5
7
  * Handles both array and string content formats.
@@ -8,51 +10,27 @@ import { MCPClient, MCPElicitationHandler, MCPHandlers, MCPSamplingHandler, MCPT
8
10
  */
9
11
  export declare function extractErrorMessage(content: unknown): string;
10
12
  /**
11
- * User-provided configuration for an MCP server.
13
+ * Normalized MCP server information as consumed by the provider.
14
+ *
15
+ * Extends `NormalizedMcpServerInfo` from the core model by:
16
+ * - narrowing `handlers` to `Partial<MCPHandlers>`
17
+ * - adding a stable `key` derived from URL/transport/headers
18
+ *
19
+ * The registry is responsible for producing `NormalizedMcpServerInfo`
20
+ * instances; this type adds the MCP-specific wiring needed to connect and
21
+ * track clients.
12
22
  */
13
- export interface McpServerInfo {
14
- /** Optional name for the MCP server */
15
- name?: string;
16
- /** The URL of the MCP server to connect to */
17
- url: string;
18
- /** Optional description of the MCP server */
19
- description?: string;
20
- /** The transport type to use (SSE or HTTP). Defaults to HTTP for string URLs */
21
- transport?: MCPTransport;
22
- /** Optional custom headers to include in requests */
23
- customHeaders?: Record<string, string>;
24
- /**
25
- * Optional short name for namespacing MCP resources, prompts, and tools.
26
- * When multiple MCP servers are configured, this key is used to prefix:
27
- * - prompts: `<serverKey>:<promptName>`
28
- * - resources: `<serverKey>:<resourceUrl>`
29
- * - tools: `<serverKey>__<toolName>`
30
- *
31
- * If not provided, a key will be derived from the URL hostname.
32
- * For example, "https://mcp.linear.app/mcp" becomes "linear".
33
- */
34
- serverKey?: string;
23
+ interface McpServerConfig extends NormalizedMcpServerInfo {
35
24
  /**
36
25
  * Optional handlers for elicitation and sampling requests from the server.
37
- * Note: These callbacks should be stable (e.g., wrapped in useCallback or defined outside the component)
38
- * to avoid constant re-registration of the MCP server on every render.
26
+ * Interpreted as a partial set of MCP handlers.
39
27
  */
40
28
  handlers?: Partial<MCPHandlers>;
41
- }
42
- /**
43
- * Normalized server information with a stable derived key.
44
- */
45
- interface McpServerConfig extends McpServerInfo {
46
29
  /**
47
30
  * Stable identity for this server derived from its URL/transport/headers.
48
31
  * Present for all server states (connected or failed).
49
32
  */
50
33
  key: string;
51
- /**
52
- * Short name for namespacing, either provided by user or derived from URL.
53
- * Used to prefix tools, prompts, and resources when multiple servers are present.
54
- */
55
- serverKey: string;
56
34
  }
57
35
  /**
58
36
  * Connected MCP server with an active client.
@@ -87,14 +65,16 @@ export interface ProviderMCPHandlers {
87
65
  /**
88
66
  * This provider is used to register tools from MCP servers.
89
67
  * It automatically includes an internal Tambo MCP server when an MCP access token is available.
68
+ *
69
+ * **BREAKING CHANGE**: This provider no longer accepts `mcpServers` as a prop.
70
+ * Instead, pass `mcpServers` to `TamboProvider` or `TamboRegistryProvider`.
71
+ * This provider must be wrapped inside `TamboProvider` to access the MCP server registry.
90
72
  * @param props - The provider props
91
- * @param props.mcpServers - Array of MCP server configurations
92
73
  * @param props.handlers - Optional handlers applied to all MCP servers unless overridden per-server
93
74
  * @param props.children - The children to wrap
94
75
  * @returns The TamboMcpProvider component
95
76
  */
96
77
  export declare const TamboMcpProvider: FC<{
97
- mcpServers: (McpServerInfo | string)[];
98
78
  handlers?: ProviderMCPHandlers;
99
79
  children: React.ReactNode;
100
80
  }>;
@@ -123,16 +103,16 @@ export declare const TamboMcpProvider: FC<{
123
103
  */
124
104
  export declare const useTamboMcpServers: () => McpServer[];
125
105
  /**
126
- * Hook to access elicitation context from TamboMcpProvider.
106
+ * Hook to access MCP elicitation state from TamboMcpProvider.
127
107
  * This provides access to the current elicitation request and methods to respond to it.
128
108
  *
129
109
  * The elicitation state is automatically managed by TamboMcpProvider when MCP servers
130
110
  * request user input through the elicitation protocol.
131
- * @returns The elicitation context with current request and response handlers
111
+ * @returns The elicitation state with current request and response handler
132
112
  * @example
133
113
  * ```tsx
134
114
  * function ElicitationUI() {
135
- * const { elicitation, resolveElicitation } = useTamboElicitationContext();
115
+ * const { elicitation, resolveElicitation } = useTamboMcpElicitation();
136
116
  *
137
117
  * if (!elicitation) return null;
138
118
  *
@@ -147,9 +127,11 @@ export declare const useTamboMcpServers: () => McpServer[];
147
127
  * }
148
128
  * ```
149
129
  */
150
- export declare const useTamboElicitationContext: () => {
151
- elicitation: import("./elicitation").TamboElicitationRequest | null;
152
- resolveElicitation: ((response: import("./elicitation").TamboElicitationResponse) => void) | null;
153
- };
130
+ export declare const useTamboMcpElicitation: () => ElicitationContextState;
131
+ /**
132
+ * @deprecated Use `useTamboMcpElicitation` instead.
133
+ * This hook will be removed in a future version.
134
+ */
135
+ export declare const useTamboElicitationContext: () => ElicitationContextState;
154
136
  export {};
155
137
  //# sourceMappingURL=tambo-mcp-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-mcp-provider.d.ts","sourceRoot":"","sources":["../../src/mcp/tambo-mcp-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAEZ,EAAE,EAMH,MAAM,OAAO,CAAC;AAMf,OAAO,EACL,SAAS,EACT,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,YAAY,EACb,MAAM,cAAc,CAAC;AAEtB;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAoB5D;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,GAAG,EAAE,MAAM,CAAC;IACZ,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,QAAQ,CAAC,EAAE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