@tambo-ai/client 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +100 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +78 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/elicitation.d.ts +59 -0
- package/dist/mcp/elicitation.d.ts.map +1 -0
- package/dist/mcp/elicitation.js +27 -0
- package/dist/mcp/elicitation.js.map +1 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +14 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/mcp-client.d.ts +185 -0
- package/dist/mcp/mcp-client.d.ts.map +1 -0
- package/dist/mcp/mcp-client.js +219 -0
- package/dist/mcp/mcp-client.js.map +1 -0
- package/dist/mcp/mcp-constants.d.ts +19 -0
- package/dist/mcp/mcp-constants.d.ts.map +1 -0
- package/dist/mcp/mcp-constants.js +21 -0
- package/dist/mcp/mcp-constants.js.map +1 -0
- package/dist/model/component-metadata.d.ts +390 -0
- package/dist/model/component-metadata.d.ts.map +1 -0
- package/dist/model/component-metadata.js +3 -0
- package/dist/model/component-metadata.js.map +1 -0
- package/dist/model/mcp-server-info.d.ts +72 -0
- package/dist/model/mcp-server-info.d.ts.map +1 -0
- package/dist/model/mcp-server-info.js +29 -0
- package/dist/model/mcp-server-info.js.map +1 -0
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +15 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/json-schema.d.ts +42 -0
- package/dist/schema/json-schema.d.ts.map +1 -0
- package/dist/schema/json-schema.js +114 -0
- package/dist/schema/json-schema.js.map +1 -0
- package/dist/schema/schema.d.ts +49 -0
- package/dist/schema/schema.d.ts.map +1 -0
- package/dist/schema/schema.js +129 -0
- package/dist/schema/schema.js.map +1 -0
- package/dist/schema/standard-schema.d.ts +22 -0
- package/dist/schema/standard-schema.d.ts.map +1 -0
- package/dist/schema/standard-schema.js +42 -0
- package/dist/schema/standard-schema.js.map +1 -0
- package/dist/schema/validate.d.ts +14 -0
- package/dist/schema/validate.d.ts.map +1 -0
- package/dist/schema/validate.js +148 -0
- package/dist/schema/validate.js.map +1 -0
- package/dist/tambo-client.d.ts +292 -0
- package/dist/tambo-client.d.ts.map +1 -0
- package/dist/tambo-client.js +508 -0
- package/dist/tambo-client.js.map +1 -0
- package/dist/tambo-stream.d.ts +112 -0
- package/dist/tambo-stream.d.ts.map +1 -0
- package/dist/tambo-stream.js +345 -0
- package/dist/tambo-stream.js.map +1 -0
- package/dist/types/auth.d.ts +24 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/auth.js +3 -0
- package/dist/types/auth.js.map +1 -0
- package/dist/types/event.d.ts +89 -0
- package/dist/types/event.d.ts.map +1 -0
- package/dist/types/event.js +57 -0
- package/dist/types/event.js.map +1 -0
- package/dist/types/message.d.ts +122 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/message.js +10 -0
- package/dist/types/message.js.map +1 -0
- package/dist/types/thread.d.ts +58 -0
- package/dist/types/thread.d.ts.map +1 -0
- package/dist/types/thread.js +9 -0
- package/dist/types/thread.js.map +1 -0
- package/dist/types/tool-choice.d.ts +8 -0
- package/dist/types/tool-choice.d.ts.map +1 -0
- package/dist/types/tool-choice.js +3 -0
- package/dist/types/tool-choice.js.map +1 -0
- package/dist/utils/event-accumulator.d.ts +165 -0
- package/dist/utils/event-accumulator.d.ts.map +1 -0
- package/dist/utils/event-accumulator.js +1278 -0
- package/dist/utils/event-accumulator.js.map +1 -0
- package/dist/utils/json-patch.d.ts +18 -0
- package/dist/utils/json-patch.d.ts.map +1 -0
- package/dist/utils/json-patch.js +35 -0
- package/dist/utils/json-patch.js.map +1 -0
- package/dist/utils/keyed-throttle.d.ts +42 -0
- package/dist/utils/keyed-throttle.d.ts.map +1 -0
- package/dist/utils/keyed-throttle.js +86 -0
- package/dist/utils/keyed-throttle.js.map +1 -0
- package/dist/utils/registry-conversion.d.ts +53 -0
- package/dist/utils/registry-conversion.d.ts.map +1 -0
- package/dist/utils/registry-conversion.js +115 -0
- package/dist/utils/registry-conversion.js.map +1 -0
- package/dist/utils/send-message.d.ts +140 -0
- package/dist/utils/send-message.d.ts.map +1 -0
- package/dist/utils/send-message.js +183 -0
- package/dist/utils/send-message.js.map +1 -0
- package/dist/utils/stream-handler.d.ts +45 -0
- package/dist/utils/stream-handler.d.ts.map +1 -0
- package/dist/utils/stream-handler.js +47 -0
- package/dist/utils/stream-handler.js.map +1 -0
- package/dist/utils/thread-utils.d.ts +16 -0
- package/dist/utils/thread-utils.d.ts.map +1 -0
- package/dist/utils/thread-utils.js +34 -0
- package/dist/utils/thread-utils.js.map +1 -0
- package/dist/utils/tool-call-tracker.d.ts +74 -0
- package/dist/utils/tool-call-tracker.d.ts.map +1 -0
- package/dist/utils/tool-call-tracker.js +181 -0
- package/dist/utils/tool-call-tracker.js.map +1 -0
- package/dist/utils/tool-executor.d.ts +67 -0
- package/dist/utils/tool-executor.d.ts.map +1 -0
- package/dist/utils/tool-executor.js +160 -0
- package/dist/utils/tool-executor.js.map +1 -0
- package/dist/utils/unstrictify.d.ts +32 -0
- package/dist/utils/unstrictify.d.ts.map +1 -0
- package/dist/utils/unstrictify.js +160 -0
- package/dist/utils/unstrictify.js.map +1 -0
- package/esm/index.d.ts +43 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +78 -0
- package/esm/index.js.map +1 -0
- package/esm/mcp/elicitation.d.ts +59 -0
- package/esm/mcp/elicitation.d.ts.map +1 -0
- package/esm/mcp/elicitation.js +27 -0
- package/esm/mcp/elicitation.js.map +1 -0
- package/esm/mcp/index.d.ts +6 -0
- package/esm/mcp/index.d.ts.map +1 -0
- package/esm/mcp/index.js +14 -0
- package/esm/mcp/index.js.map +1 -0
- package/esm/mcp/mcp-client.d.ts +185 -0
- package/esm/mcp/mcp-client.d.ts.map +1 -0
- package/esm/mcp/mcp-client.js +219 -0
- package/esm/mcp/mcp-client.js.map +1 -0
- package/esm/mcp/mcp-constants.d.ts +19 -0
- package/esm/mcp/mcp-constants.d.ts.map +1 -0
- package/esm/mcp/mcp-constants.js +21 -0
- package/esm/mcp/mcp-constants.js.map +1 -0
- package/esm/model/component-metadata.d.ts +390 -0
- package/esm/model/component-metadata.d.ts.map +1 -0
- package/esm/model/component-metadata.js +3 -0
- package/esm/model/component-metadata.js.map +1 -0
- package/esm/model/mcp-server-info.d.ts +72 -0
- package/esm/model/mcp-server-info.d.ts.map +1 -0
- package/esm/model/mcp-server-info.js +29 -0
- package/esm/model/mcp-server-info.js.map +1 -0
- package/esm/schema/index.d.ts +5 -0
- package/esm/schema/index.d.ts.map +1 -0
- package/esm/schema/index.js +15 -0
- package/esm/schema/index.js.map +1 -0
- package/esm/schema/json-schema.d.ts +42 -0
- package/esm/schema/json-schema.d.ts.map +1 -0
- package/esm/schema/json-schema.js +114 -0
- package/esm/schema/json-schema.js.map +1 -0
- package/esm/schema/schema.d.ts +49 -0
- package/esm/schema/schema.d.ts.map +1 -0
- package/esm/schema/schema.js +129 -0
- package/esm/schema/schema.js.map +1 -0
- package/esm/schema/standard-schema.d.ts +22 -0
- package/esm/schema/standard-schema.d.ts.map +1 -0
- package/esm/schema/standard-schema.js +42 -0
- package/esm/schema/standard-schema.js.map +1 -0
- package/esm/schema/validate.d.ts +14 -0
- package/esm/schema/validate.d.ts.map +1 -0
- package/esm/schema/validate.js +148 -0
- package/esm/schema/validate.js.map +1 -0
- package/esm/tambo-client.d.ts +292 -0
- package/esm/tambo-client.d.ts.map +1 -0
- package/esm/tambo-client.js +508 -0
- package/esm/tambo-client.js.map +1 -0
- package/esm/tambo-stream.d.ts +112 -0
- package/esm/tambo-stream.d.ts.map +1 -0
- package/esm/tambo-stream.js +345 -0
- package/esm/tambo-stream.js.map +1 -0
- package/esm/types/auth.d.ts +24 -0
- package/esm/types/auth.d.ts.map +1 -0
- package/esm/types/auth.js +3 -0
- package/esm/types/auth.js.map +1 -0
- package/esm/types/event.d.ts +89 -0
- package/esm/types/event.d.ts.map +1 -0
- package/esm/types/event.js +57 -0
- package/esm/types/event.js.map +1 -0
- package/esm/types/message.d.ts +122 -0
- package/esm/types/message.d.ts.map +1 -0
- package/esm/types/message.js +10 -0
- package/esm/types/message.js.map +1 -0
- package/esm/types/thread.d.ts +58 -0
- package/esm/types/thread.d.ts.map +1 -0
- package/esm/types/thread.js +9 -0
- package/esm/types/thread.js.map +1 -0
- package/esm/types/tool-choice.d.ts +8 -0
- package/esm/types/tool-choice.d.ts.map +1 -0
- package/esm/types/tool-choice.js +3 -0
- package/esm/types/tool-choice.js.map +1 -0
- package/esm/utils/event-accumulator.d.ts +165 -0
- package/esm/utils/event-accumulator.d.ts.map +1 -0
- package/esm/utils/event-accumulator.js +1278 -0
- package/esm/utils/event-accumulator.js.map +1 -0
- package/esm/utils/json-patch.d.ts +18 -0
- package/esm/utils/json-patch.d.ts.map +1 -0
- package/esm/utils/json-patch.js +35 -0
- package/esm/utils/json-patch.js.map +1 -0
- package/esm/utils/keyed-throttle.d.ts +42 -0
- package/esm/utils/keyed-throttle.d.ts.map +1 -0
- package/esm/utils/keyed-throttle.js +86 -0
- package/esm/utils/keyed-throttle.js.map +1 -0
- package/esm/utils/registry-conversion.d.ts +53 -0
- package/esm/utils/registry-conversion.d.ts.map +1 -0
- package/esm/utils/registry-conversion.js +115 -0
- package/esm/utils/registry-conversion.js.map +1 -0
- package/esm/utils/send-message.d.ts +140 -0
- package/esm/utils/send-message.d.ts.map +1 -0
- package/esm/utils/send-message.js +183 -0
- package/esm/utils/send-message.js.map +1 -0
- package/esm/utils/stream-handler.d.ts +45 -0
- package/esm/utils/stream-handler.d.ts.map +1 -0
- package/esm/utils/stream-handler.js +47 -0
- package/esm/utils/stream-handler.js.map +1 -0
- package/esm/utils/thread-utils.d.ts +16 -0
- package/esm/utils/thread-utils.d.ts.map +1 -0
- package/esm/utils/thread-utils.js +34 -0
- package/esm/utils/thread-utils.js.map +1 -0
- package/esm/utils/tool-call-tracker.d.ts +74 -0
- package/esm/utils/tool-call-tracker.d.ts.map +1 -0
- package/esm/utils/tool-call-tracker.js +181 -0
- package/esm/utils/tool-call-tracker.js.map +1 -0
- package/esm/utils/tool-executor.d.ts +67 -0
- package/esm/utils/tool-executor.d.ts.map +1 -0
- package/esm/utils/tool-executor.js +160 -0
- package/esm/utils/tool-executor.js.map +1 -0
- package/esm/utils/unstrictify.d.ts +32 -0
- package/esm/utils/unstrictify.d.ts.map +1 -0
- package/esm/utils/unstrictify.js +160 -0
- package/esm/utils/unstrictify.js.map +1 -0
- package/package.json +90 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MCPClient = exports.MCPTransport = void 0;
|
|
4
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/client/index.js");
|
|
5
|
+
const sse_js_1 = require("@modelcontextprotocol/sdk/client/sse.js");
|
|
6
|
+
const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
7
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
8
|
+
const mcp_server_info_1 = require("../model/mcp-server-info");
|
|
9
|
+
Object.defineProperty(exports, "MCPTransport", { enumerable: true, get: function () { return mcp_server_info_1.MCPTransport; } });
|
|
10
|
+
/**
|
|
11
|
+
* A client for interacting with MCP (Model Context Protocol) servers.
|
|
12
|
+
* Provides a simple interface for listing and calling tools exposed by the server.
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const mcp = await MCPClient.create('https://api.example.com/mcp');
|
|
16
|
+
* const tools = await mcp.listTools();
|
|
17
|
+
* const result = await mcp.callTool('toolName', { arg1: 'value1' });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
class MCPClient {
|
|
21
|
+
/**
|
|
22
|
+
* The underlying MCP client
|
|
23
|
+
*
|
|
24
|
+
* Be careful not to mutate the client directly, use the methods provided instead.
|
|
25
|
+
*/
|
|
26
|
+
client;
|
|
27
|
+
transport;
|
|
28
|
+
transportType;
|
|
29
|
+
sessionId;
|
|
30
|
+
endpoint;
|
|
31
|
+
headers;
|
|
32
|
+
authProvider;
|
|
33
|
+
handlers;
|
|
34
|
+
/**
|
|
35
|
+
* Private constructor to enforce using the static create method.
|
|
36
|
+
* @param endpoint - The URL of the MCP server to connect to
|
|
37
|
+
* @param transportType - The transport to use for the MCP client
|
|
38
|
+
* @param headers - Optional custom headers to include in requests
|
|
39
|
+
*/
|
|
40
|
+
constructor(endpoint, transportType, headers, authProvider, sessionId, handlers = {}) {
|
|
41
|
+
this.endpoint = endpoint;
|
|
42
|
+
this.headers = headers ?? {};
|
|
43
|
+
this.authProvider = authProvider;
|
|
44
|
+
this.transportType = transportType;
|
|
45
|
+
this.handlers = handlers;
|
|
46
|
+
this.transport = this.initializeTransport(sessionId);
|
|
47
|
+
this.client = this.initializeClient();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates and initializes a new MCPClient instance. This is the recommended
|
|
51
|
+
* way to create an MCPClient as it handles both instantiation and connection
|
|
52
|
+
* setup.
|
|
53
|
+
* @param endpoint - The URL of the MCP server to connect to
|
|
54
|
+
* @param transportType - The transport type to use for the MCP client. Defaults to HTTP.
|
|
55
|
+
* @param headers - Optional custom headers to include in requests
|
|
56
|
+
* @param authProvider - Optional auth provider to use for authentication
|
|
57
|
+
* @param sessionId - Optional session id to use for the MCP client - if not
|
|
58
|
+
* provided, a new session will be created
|
|
59
|
+
* @returns A connected MCPClient instance ready for use
|
|
60
|
+
* @throws {Error} Will throw an error if connection fails
|
|
61
|
+
*/
|
|
62
|
+
static async create(endpoint, transportType = mcp_server_info_1.MCPTransport.HTTP, headers, authProvider, sessionId, handlers = {}) {
|
|
63
|
+
const mcpClient = new MCPClient(endpoint, transportType, headers, authProvider, sessionId, handlers);
|
|
64
|
+
await mcpClient.client.connect(mcpClient.transport);
|
|
65
|
+
if ("sessionId" in mcpClient.transport) {
|
|
66
|
+
mcpClient.sessionId = mcpClient.transport.sessionId;
|
|
67
|
+
}
|
|
68
|
+
return mcpClient;
|
|
69
|
+
}
|
|
70
|
+
initializeTransport(sessionId) {
|
|
71
|
+
if (this.transportType === mcp_server_info_1.MCPTransport.SSE) {
|
|
72
|
+
return new sse_js_1.SSEClientTransport(new URL(this.endpoint), {
|
|
73
|
+
authProvider: this.authProvider,
|
|
74
|
+
requestInit: { headers: this.headers },
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return new streamableHttp_js_1.StreamableHTTPClientTransport(new URL(this.endpoint), {
|
|
79
|
+
authProvider: this.authProvider,
|
|
80
|
+
requestInit: { headers: this.headers },
|
|
81
|
+
sessionId,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Initializes the MCP client with the appropriate capabilities and handlers
|
|
87
|
+
* @returns The initialized MCP client
|
|
88
|
+
*/
|
|
89
|
+
initializeClient() {
|
|
90
|
+
const elicitationCapability = this.handlers.elicitation
|
|
91
|
+
? { elicitation: {} }
|
|
92
|
+
: {};
|
|
93
|
+
const samplingCapability = this.handlers.sampling ? { sampling: {} } : {};
|
|
94
|
+
const client = new index_js_1.Client({
|
|
95
|
+
name: "tambo-mcp-client",
|
|
96
|
+
version: "1.0.0",
|
|
97
|
+
}, {
|
|
98
|
+
capabilities: {
|
|
99
|
+
...elicitationCapability,
|
|
100
|
+
...samplingCapability,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
if (this.handlers.elicitation) {
|
|
104
|
+
client.setRequestHandler(types_js_1.ElicitRequestSchema, this.handlers.elicitation);
|
|
105
|
+
}
|
|
106
|
+
if (this.handlers.sampling) {
|
|
107
|
+
client.setRequestHandler(types_js_1.CreateMessageRequestSchema, this.handlers.sampling);
|
|
108
|
+
}
|
|
109
|
+
return client;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Retrieves a complete list of all available tools from the MCP server.
|
|
113
|
+
* Handles pagination automatically by following cursors until all tools are fetched.
|
|
114
|
+
* @returns A complete list of all available tools and their descriptions
|
|
115
|
+
* @throws {Error} Will throw an error if any server request fails during pagination
|
|
116
|
+
*/
|
|
117
|
+
async listTools() {
|
|
118
|
+
const allTools = [];
|
|
119
|
+
let hasMore = true;
|
|
120
|
+
let cursor = undefined;
|
|
121
|
+
while (hasMore) {
|
|
122
|
+
const response = await this.client.listTools({ cursor }, {});
|
|
123
|
+
allTools.push(...response.tools.map((tool) => {
|
|
124
|
+
// make sure the right type is used
|
|
125
|
+
const inputSchemaType = tool.inputSchema.type;
|
|
126
|
+
if (inputSchemaType !== "object") {
|
|
127
|
+
throw new Error(`Input schema for tool ${tool.name} is not an object`);
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
name: tool.name,
|
|
131
|
+
description: tool.description,
|
|
132
|
+
inputSchema: tool.inputSchema,
|
|
133
|
+
};
|
|
134
|
+
}));
|
|
135
|
+
if (response.nextCursor) {
|
|
136
|
+
cursor = response.nextCursor;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
hasMore = false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return allTools;
|
|
143
|
+
}
|
|
144
|
+
getServerCapabilities() {
|
|
145
|
+
return this.client.getServerCapabilities();
|
|
146
|
+
}
|
|
147
|
+
getServerVersion() {
|
|
148
|
+
return this.client.getServerVersion();
|
|
149
|
+
}
|
|
150
|
+
getInstructions() {
|
|
151
|
+
return this.client.getInstructions();
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Calls a specific tool on the MCP server with the provided arguments.
|
|
155
|
+
* @param name - The name of the tool to call
|
|
156
|
+
* @param args - Arguments to pass to the tool, must match the tool's expected schema
|
|
157
|
+
* @returns The result from the tool execution
|
|
158
|
+
* @throws {Error} Will throw an error if the tool call fails or if arguments are invalid
|
|
159
|
+
*/
|
|
160
|
+
async callTool(name, args, _meta) {
|
|
161
|
+
const result = await this.client.callTool({
|
|
162
|
+
name,
|
|
163
|
+
arguments: args,
|
|
164
|
+
_meta,
|
|
165
|
+
});
|
|
166
|
+
return result;
|
|
167
|
+
}
|
|
168
|
+
updateElicitationHandler(handler) {
|
|
169
|
+
// Skip if handler hasn't changed
|
|
170
|
+
if (handler === this.handlers.elicitation) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
// Because we advertise the elicitation capability on initial connection, we can only update
|
|
174
|
+
// an existing handler, not add it if we haven't set it yet.
|
|
175
|
+
if (handler && !this.handlers.elicitation) {
|
|
176
|
+
throw new Error("Elicitation handler must be set on create");
|
|
177
|
+
}
|
|
178
|
+
this.handlers = {
|
|
179
|
+
...this.handlers,
|
|
180
|
+
elicitation: handler,
|
|
181
|
+
};
|
|
182
|
+
if (!handler) {
|
|
183
|
+
const method = types_js_1.ElicitRequestSchema.shape.method.value;
|
|
184
|
+
this.client.removeRequestHandler(method);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
this.client.setRequestHandler(types_js_1.ElicitRequestSchema, handler);
|
|
188
|
+
}
|
|
189
|
+
updateSamplingHandler(handler) {
|
|
190
|
+
// Skip if handler hasn't changed
|
|
191
|
+
if (handler === this.handlers.sampling) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
// Because we advertise the sampling capability on initial connection, we can only update
|
|
195
|
+
// an existing handler, not add it if we haven't set it yet.
|
|
196
|
+
if (handler && !this.handlers.sampling) {
|
|
197
|
+
throw new Error("Sampling handler must be set on create");
|
|
198
|
+
}
|
|
199
|
+
this.handlers = {
|
|
200
|
+
...this.handlers,
|
|
201
|
+
sampling: handler,
|
|
202
|
+
};
|
|
203
|
+
if (!handler) {
|
|
204
|
+
const method = types_js_1.CreateMessageRequestSchema.shape.method.value;
|
|
205
|
+
this.client.removeRequestHandler(method);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
this.client.setRequestHandler(types_js_1.CreateMessageRequestSchema, handler);
|
|
209
|
+
}
|
|
210
|
+
async close() {
|
|
211
|
+
// Not really sure which one of these to close first, but we'll close the
|
|
212
|
+
// transport first so that no requests can come in and hit closing/closed
|
|
213
|
+
// clients
|
|
214
|
+
await this.transport.close();
|
|
215
|
+
await this.client.close();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
exports.MCPClient = MCPClient;
|
|
219
|
+
//# sourceMappingURL=mcp-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-client.js","sourceRoot":"","sources":["../../src/mcp/mcp-client.ts"],"names":[],"mappings":";;;AACA,wEAAmE;AACnE,oEAA6E;AAC7E,0FAAmG;AAEnG,iEAS4C;AAE5C,8DAAwD;AAG/C,6FAHA,8BAAY,OAGA;AAgErB;;;;;;;;;GASG;AACH,MAAa,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,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,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;QACrD,IAAI,CAAC,MAAM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AAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF;AAzPD,8BAyPC","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 maxCalls?: number;\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server type enum for distinguishing different kinds of MCP servers.
|
|
3
|
+
* Used to determine how resources should be resolved.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ServerType: {
|
|
6
|
+
/** Client-side MCP server passed via mcpServers prop */
|
|
7
|
+
readonly BROWSER_SIDE: "browser-side";
|
|
8
|
+
/** Internal Tambo MCP server at /mcp endpoint (server-side MCP) */
|
|
9
|
+
readonly TAMBO_INTERNAL: "tambo-internal";
|
|
10
|
+
/** Virtual server representing browser-only registry resources */
|
|
11
|
+
readonly TAMBO_REGISTRY: "tambo-registry";
|
|
12
|
+
};
|
|
13
|
+
export type ServerType = (typeof ServerType)[keyof typeof ServerType];
|
|
14
|
+
/**
|
|
15
|
+
* Synthetic server key for local registry resources.
|
|
16
|
+
* Used to give registry resources the same `@serverKey:uri` format as MCP resources.
|
|
17
|
+
*/
|
|
18
|
+
export declare const REGISTRY_SERVER_KEY = "registry";
|
|
19
|
+
//# sourceMappingURL=mcp-constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-constants.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp-constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,UAAU;IACrB,wDAAwD;;IAExD,mEAAmE;;IAEnE,kEAAkE;;CAE1D,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAEtE;;;GAGG;AACH,eAAO,MAAM,mBAAmB,aAAa,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REGISTRY_SERVER_KEY = exports.ServerType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Server type enum for distinguishing different kinds of MCP servers.
|
|
6
|
+
* Used to determine how resources should be resolved.
|
|
7
|
+
*/
|
|
8
|
+
exports.ServerType = {
|
|
9
|
+
/** Client-side MCP server passed via mcpServers prop */
|
|
10
|
+
BROWSER_SIDE: "browser-side",
|
|
11
|
+
/** Internal Tambo MCP server at /mcp endpoint (server-side MCP) */
|
|
12
|
+
TAMBO_INTERNAL: "tambo-internal",
|
|
13
|
+
/** Virtual server representing browser-only registry resources */
|
|
14
|
+
TAMBO_REGISTRY: "tambo-registry",
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Synthetic server key for local registry resources.
|
|
18
|
+
* Used to give registry resources the same `@serverKey:uri` format as MCP resources.
|
|
19
|
+
*/
|
|
20
|
+
exports.REGISTRY_SERVER_KEY = "registry";
|
|
21
|
+
//# sourceMappingURL=mcp-constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-constants.js","sourceRoot":"","sources":["../../src/mcp/mcp-constants.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,UAAU,GAAG;IACxB,wDAAwD;IACxD,YAAY,EAAE,cAAc;IAC5B,mEAAmE;IACnE,cAAc,EAAE,gBAAgB;IAChC,kEAAkE;IAClE,cAAc,EAAE,gBAAgB;CACxB,CAAC;AAIX;;;GAGG;AACU,QAAA,mBAAmB,GAAG,UAAU,CAAC","sourcesContent":["/**\n * Server type enum for distinguishing different kinds of MCP servers.\n * Used to determine how resources should be resolved.\n */\nexport const ServerType = {\n /** Client-side MCP server passed via mcpServers prop */\n BROWSER_SIDE: \"browser-side\",\n /** Internal Tambo MCP server at /mcp endpoint (server-side MCP) */\n TAMBO_INTERNAL: \"tambo-internal\",\n /** Virtual server representing browser-only registry resources */\n TAMBO_REGISTRY: \"tambo-registry\",\n} as const;\n\nexport type ServerType = (typeof ServerType)[keyof typeof ServerType];\n\n/**\n * Synthetic server key for local registry resources.\n * Used to give registry resources the same `@serverKey:uri` format as MCP resources.\n */\nexport const REGISTRY_SERVER_KEY = \"registry\";\n"]}
|