integrate-sdk 0.1.5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +114 -584
- package/dist/client.d.ts +88 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/config/types.d.ts +45 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/errors.d.ts +67 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +336 -7
- package/dist/integrations/vercel-ai.d.ts +1 -1
- package/dist/integrations/vercel-ai.d.ts.map +1 -1
- package/dist/plugins/generic.d.ts +17 -10
- package/dist/plugins/generic.d.ts.map +1 -1
- package/dist/plugins/github-client.d.ts +320 -0
- package/dist/plugins/github-client.d.ts.map +1 -0
- package/dist/plugins/github.d.ts +4 -1
- package/dist/plugins/github.d.ts.map +1 -1
- package/dist/plugins/gmail-client.d.ts +200 -0
- package/dist/plugins/gmail-client.d.ts.map +1 -0
- package/dist/plugins/gmail.d.ts +4 -1
- package/dist/plugins/gmail.d.ts.map +1 -1
- package/dist/plugins/server-client.d.ts +18 -0
- package/dist/plugins/server-client.d.ts.map +1 -0
- package/dist/plugins/types.d.ts +4 -4
- package/dist/plugins/types.d.ts.map +1 -1
- package/dist/transport/http-session.d.ts.map +1 -1
- package/dist/utils/naming.d.ts +37 -0
- package/dist/utils/naming.d.ts.map +1 -0
- package/package.json +8 -4
package/dist/index.js
CHANGED
|
@@ -1,3 +1,153 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, {
|
|
5
|
+
get: all[name],
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true,
|
|
8
|
+
set: (newValue) => all[name] = () => newValue
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
12
|
+
|
|
13
|
+
// src/errors.ts
|
|
14
|
+
var exports_errors = {};
|
|
15
|
+
__export(exports_errors, {
|
|
16
|
+
parseServerError: () => parseServerError,
|
|
17
|
+
isTokenExpiredError: () => isTokenExpiredError,
|
|
18
|
+
isAuthorizationError: () => isAuthorizationError,
|
|
19
|
+
isAuthError: () => isAuthError,
|
|
20
|
+
ToolCallError: () => ToolCallError,
|
|
21
|
+
TokenExpiredError: () => TokenExpiredError,
|
|
22
|
+
IntegrateSDKError: () => IntegrateSDKError,
|
|
23
|
+
ConnectionError: () => ConnectionError,
|
|
24
|
+
AuthorizationError: () => AuthorizationError,
|
|
25
|
+
AuthenticationError: () => AuthenticationError
|
|
26
|
+
});
|
|
27
|
+
function isAuthError(error) {
|
|
28
|
+
return error instanceof AuthenticationError;
|
|
29
|
+
}
|
|
30
|
+
function isTokenExpiredError(error) {
|
|
31
|
+
return error instanceof TokenExpiredError;
|
|
32
|
+
}
|
|
33
|
+
function isAuthorizationError(error) {
|
|
34
|
+
return error instanceof AuthorizationError;
|
|
35
|
+
}
|
|
36
|
+
function parseServerError(error, context) {
|
|
37
|
+
if (error && typeof error === "object" && "jsonrpcError" in error) {
|
|
38
|
+
const jsonrpcError = error.jsonrpcError;
|
|
39
|
+
if (jsonrpcError && typeof jsonrpcError === "object") {
|
|
40
|
+
return parseServerError(jsonrpcError, context);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (error && typeof error === "object" && "code" in error && "message" in error) {
|
|
44
|
+
const code = error.code;
|
|
45
|
+
const message = error.message || "Unknown error";
|
|
46
|
+
if (code === -32600) {
|
|
47
|
+
return new IntegrateSDKError(`Invalid request: ${message}`);
|
|
48
|
+
}
|
|
49
|
+
if (code === -32601) {
|
|
50
|
+
return new IntegrateSDKError(`Method not found: ${message}`);
|
|
51
|
+
}
|
|
52
|
+
if (code === -32602) {
|
|
53
|
+
return new IntegrateSDKError(`Invalid params: ${message}`);
|
|
54
|
+
}
|
|
55
|
+
if (code === 401 || code === -32001) {
|
|
56
|
+
if (message.toLowerCase().includes("expired") || message.toLowerCase().includes("token")) {
|
|
57
|
+
return new TokenExpiredError(message, context?.provider);
|
|
58
|
+
}
|
|
59
|
+
return new AuthenticationError(message, 401, context?.provider);
|
|
60
|
+
}
|
|
61
|
+
if (code === 403 || code === -32002) {
|
|
62
|
+
return new AuthorizationError(message, 403);
|
|
63
|
+
}
|
|
64
|
+
if (context?.toolName) {
|
|
65
|
+
return new ToolCallError(message, context.toolName, error);
|
|
66
|
+
}
|
|
67
|
+
return new IntegrateSDKError(message);
|
|
68
|
+
}
|
|
69
|
+
if (error instanceof Error) {
|
|
70
|
+
const message = error.message;
|
|
71
|
+
const statusCode = error.statusCode;
|
|
72
|
+
if (statusCode === 401) {
|
|
73
|
+
if (message.toLowerCase().includes("expired") || message.toLowerCase().includes("token")) {
|
|
74
|
+
return new TokenExpiredError(message, context?.provider);
|
|
75
|
+
}
|
|
76
|
+
return new AuthenticationError(message, 401, context?.provider);
|
|
77
|
+
}
|
|
78
|
+
if (statusCode === 403) {
|
|
79
|
+
return new AuthorizationError(message, 403);
|
|
80
|
+
}
|
|
81
|
+
if (message.includes("401") || message.includes("Unauthorized") || message.includes("unauthenticated")) {
|
|
82
|
+
if (message.toLowerCase().includes("expired") || message.toLowerCase().includes("token")) {
|
|
83
|
+
return new TokenExpiredError(message, context?.provider);
|
|
84
|
+
}
|
|
85
|
+
return new AuthenticationError(message, 401, context?.provider);
|
|
86
|
+
}
|
|
87
|
+
if (message.includes("403") || message.includes("Forbidden") || message.includes("unauthorized")) {
|
|
88
|
+
return new AuthorizationError(message, 403);
|
|
89
|
+
}
|
|
90
|
+
if (context?.toolName) {
|
|
91
|
+
return new ToolCallError(message, context.toolName, error);
|
|
92
|
+
}
|
|
93
|
+
return new IntegrateSDKError(message);
|
|
94
|
+
}
|
|
95
|
+
return new IntegrateSDKError(String(error));
|
|
96
|
+
}
|
|
97
|
+
var IntegrateSDKError, AuthenticationError, AuthorizationError, TokenExpiredError, ConnectionError, ToolCallError;
|
|
98
|
+
var init_errors = __esm(() => {
|
|
99
|
+
IntegrateSDKError = class IntegrateSDKError extends Error {
|
|
100
|
+
constructor(message) {
|
|
101
|
+
super(message);
|
|
102
|
+
this.name = "IntegrateSDKError";
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
AuthenticationError = class AuthenticationError extends IntegrateSDKError {
|
|
106
|
+
statusCode;
|
|
107
|
+
provider;
|
|
108
|
+
constructor(message, statusCode, provider) {
|
|
109
|
+
super(message);
|
|
110
|
+
this.name = "AuthenticationError";
|
|
111
|
+
this.statusCode = statusCode;
|
|
112
|
+
this.provider = provider;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
AuthorizationError = class AuthorizationError extends IntegrateSDKError {
|
|
116
|
+
statusCode;
|
|
117
|
+
requiredScopes;
|
|
118
|
+
constructor(message, statusCode, requiredScopes) {
|
|
119
|
+
super(message);
|
|
120
|
+
this.name = "AuthorizationError";
|
|
121
|
+
this.statusCode = statusCode;
|
|
122
|
+
this.requiredScopes = requiredScopes;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
TokenExpiredError = class TokenExpiredError extends AuthenticationError {
|
|
126
|
+
constructor(message, provider) {
|
|
127
|
+
super(message, 401, provider);
|
|
128
|
+
this.name = "TokenExpiredError";
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
ConnectionError = class ConnectionError extends IntegrateSDKError {
|
|
132
|
+
statusCode;
|
|
133
|
+
constructor(message, statusCode) {
|
|
134
|
+
super(message);
|
|
135
|
+
this.name = "ConnectionError";
|
|
136
|
+
this.statusCode = statusCode;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
ToolCallError = class ToolCallError extends IntegrateSDKError {
|
|
140
|
+
toolName;
|
|
141
|
+
originalError;
|
|
142
|
+
constructor(message, toolName, originalError) {
|
|
143
|
+
super(message);
|
|
144
|
+
this.name = "ToolCallError";
|
|
145
|
+
this.toolName = toolName;
|
|
146
|
+
this.originalError = originalError;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
|
|
1
151
|
// src/protocol/jsonrpc.ts
|
|
2
152
|
function parseMessage(message) {
|
|
3
153
|
try {
|
|
@@ -55,7 +205,9 @@ class HttpSessionTransport {
|
|
|
55
205
|
});
|
|
56
206
|
clearTimeout(timeoutId);
|
|
57
207
|
if (!response.ok) {
|
|
58
|
-
|
|
208
|
+
const error = new Error(`Request failed: ${response.statusText}`);
|
|
209
|
+
error.statusCode = response.status;
|
|
210
|
+
throw error;
|
|
59
211
|
}
|
|
60
212
|
if (!this.sessionId) {
|
|
61
213
|
const sid = response.headers.get("mcp-session-id");
|
|
@@ -67,11 +219,25 @@ class HttpSessionTransport {
|
|
|
67
219
|
}
|
|
68
220
|
const jsonResponse = await response.json();
|
|
69
221
|
if ("error" in jsonResponse) {
|
|
70
|
-
|
|
222
|
+
const error = new Error(`JSON-RPC Error ${jsonResponse.error.code}: ${jsonResponse.error.message}`);
|
|
223
|
+
error.code = jsonResponse.error.code;
|
|
224
|
+
if (jsonResponse.error.data) {
|
|
225
|
+
error.data = jsonResponse.error.data;
|
|
226
|
+
}
|
|
227
|
+
error.jsonrpcError = jsonResponse.error;
|
|
228
|
+
throw error;
|
|
71
229
|
}
|
|
72
230
|
return jsonResponse.result;
|
|
73
231
|
} catch (error) {
|
|
74
|
-
|
|
232
|
+
if (error instanceof Error) {
|
|
233
|
+
if (error.name === "AbortError") {
|
|
234
|
+
const timeoutError = new Error("Request timeout");
|
|
235
|
+
timeoutError.code = -32000;
|
|
236
|
+
throw timeoutError;
|
|
237
|
+
}
|
|
238
|
+
throw error;
|
|
239
|
+
}
|
|
240
|
+
throw new Error(String(error));
|
|
75
241
|
}
|
|
76
242
|
}
|
|
77
243
|
async startSSEListener() {
|
|
@@ -183,6 +349,18 @@ var MCPMethod;
|
|
|
183
349
|
MCPMethod2["PROMPTS_GET"] = "prompts/get";
|
|
184
350
|
})(MCPMethod ||= {});
|
|
185
351
|
|
|
352
|
+
// src/client.ts
|
|
353
|
+
init_errors();
|
|
354
|
+
|
|
355
|
+
// src/utils/naming.ts
|
|
356
|
+
function camelToSnake(str) {
|
|
357
|
+
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
358
|
+
}
|
|
359
|
+
function methodToToolName(methodName, pluginId) {
|
|
360
|
+
const snakeCaseMethod = camelToSnake(methodName);
|
|
361
|
+
return `${pluginId}_${snakeCaseMethod}`;
|
|
362
|
+
}
|
|
363
|
+
|
|
186
364
|
// src/client.ts
|
|
187
365
|
var MCP_SERVER_URL = "https://mcp.integrate.dev/api/v1/mcp";
|
|
188
366
|
|
|
@@ -193,6 +371,12 @@ class MCPClient {
|
|
|
193
371
|
enabledToolNames = new Set;
|
|
194
372
|
initialized = false;
|
|
195
373
|
clientInfo;
|
|
374
|
+
onReauthRequired;
|
|
375
|
+
maxReauthRetries;
|
|
376
|
+
authState = new Map;
|
|
377
|
+
github;
|
|
378
|
+
gmail;
|
|
379
|
+
server;
|
|
196
380
|
constructor(config) {
|
|
197
381
|
this.transport = new HttpSessionTransport({
|
|
198
382
|
url: MCP_SERVER_URL,
|
|
@@ -204,13 +388,61 @@ class MCPClient {
|
|
|
204
388
|
name: "integrate-sdk",
|
|
205
389
|
version: "0.1.0"
|
|
206
390
|
};
|
|
391
|
+
this.onReauthRequired = config.onReauthRequired;
|
|
392
|
+
this.maxReauthRetries = config.maxReauthRetries ?? 1;
|
|
207
393
|
for (const plugin of this.plugins) {
|
|
208
394
|
for (const toolName of plugin.tools) {
|
|
209
395
|
this.enabledToolNames.add(toolName);
|
|
210
396
|
}
|
|
397
|
+
if (plugin.oauth) {
|
|
398
|
+
this.authState.set(plugin.oauth.provider, { authenticated: true });
|
|
399
|
+
}
|
|
211
400
|
}
|
|
401
|
+
this.github = this.createPluginProxy("github");
|
|
402
|
+
this.gmail = this.createPluginProxy("gmail");
|
|
403
|
+
this.server = this.createServerProxy();
|
|
212
404
|
this.initializePlugins();
|
|
213
405
|
}
|
|
406
|
+
createPluginProxy(pluginId) {
|
|
407
|
+
return new Proxy({}, {
|
|
408
|
+
get: (_target, methodName) => {
|
|
409
|
+
return async (args) => {
|
|
410
|
+
const toolName = methodToToolName(methodName, pluginId);
|
|
411
|
+
return await this.callToolWithRetry(toolName, args, 0);
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
createServerProxy() {
|
|
417
|
+
return new Proxy({}, {
|
|
418
|
+
get: (_target, methodName) => {
|
|
419
|
+
return async (args) => {
|
|
420
|
+
const toolName = methodToToolName(methodName, "");
|
|
421
|
+
const finalToolName = toolName.startsWith("_") ? toolName.substring(1) : toolName;
|
|
422
|
+
return await this.callServerToolInternal(finalToolName, args);
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
async callServerToolInternal(name, args) {
|
|
428
|
+
if (!this.initialized) {
|
|
429
|
+
throw new Error("Client not initialized. Call connect() first.");
|
|
430
|
+
}
|
|
431
|
+
if (!this.availableTools.has(name)) {
|
|
432
|
+
throw new Error(`Tool "${name}" is not available on the server. Available tools: ${Array.from(this.availableTools.keys()).join(", ")}`);
|
|
433
|
+
}
|
|
434
|
+
const params = {
|
|
435
|
+
name,
|
|
436
|
+
arguments: args
|
|
437
|
+
};
|
|
438
|
+
try {
|
|
439
|
+
const response = await this.transport.sendRequest("tools/call" /* TOOLS_CALL */, params);
|
|
440
|
+
return response;
|
|
441
|
+
} catch (error) {
|
|
442
|
+
const parsedError = parseServerError(error, { toolName: name });
|
|
443
|
+
throw parsedError;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
214
446
|
async initializePlugins() {
|
|
215
447
|
for (const plugin of this.plugins) {
|
|
216
448
|
if (plugin.onInit) {
|
|
@@ -253,7 +485,29 @@ class MCPClient {
|
|
|
253
485
|
const enabledTools = response.tools.filter((tool) => this.enabledToolNames.has(tool.name));
|
|
254
486
|
console.log(`Discovered ${response.tools.length} tools, ${enabledTools.length} enabled by plugins`);
|
|
255
487
|
}
|
|
256
|
-
async
|
|
488
|
+
async _callToolByName(name, args) {
|
|
489
|
+
return await this.callToolWithRetry(name, args, 0);
|
|
490
|
+
}
|
|
491
|
+
async callServerTool(name, args) {
|
|
492
|
+
if (!this.initialized) {
|
|
493
|
+
throw new Error("Client not initialized. Call connect() first.");
|
|
494
|
+
}
|
|
495
|
+
if (!this.availableTools.has(name)) {
|
|
496
|
+
throw new Error(`Tool "${name}" is not available on the server. Available tools: ${Array.from(this.availableTools.keys()).join(", ")}`);
|
|
497
|
+
}
|
|
498
|
+
const params = {
|
|
499
|
+
name,
|
|
500
|
+
arguments: args
|
|
501
|
+
};
|
|
502
|
+
try {
|
|
503
|
+
const response = await this.transport.sendRequest("tools/call" /* TOOLS_CALL */, params);
|
|
504
|
+
return response;
|
|
505
|
+
} catch (error) {
|
|
506
|
+
const parsedError = parseServerError(error, { toolName: name });
|
|
507
|
+
throw parsedError;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
async callToolWithRetry(name, args, retryCount = 0) {
|
|
257
511
|
if (!this.initialized) {
|
|
258
512
|
throw new Error("Client not initialized. Call connect() first.");
|
|
259
513
|
}
|
|
@@ -267,7 +521,44 @@ class MCPClient {
|
|
|
267
521
|
name,
|
|
268
522
|
arguments: args
|
|
269
523
|
};
|
|
270
|
-
|
|
524
|
+
try {
|
|
525
|
+
const response = await this.transport.sendRequest("tools/call" /* TOOLS_CALL */, params);
|
|
526
|
+
const provider = this.getProviderForTool(name);
|
|
527
|
+
if (provider) {
|
|
528
|
+
this.authState.set(provider, { authenticated: true });
|
|
529
|
+
}
|
|
530
|
+
return response;
|
|
531
|
+
} catch (error) {
|
|
532
|
+
const provider = this.getProviderForTool(name);
|
|
533
|
+
const parsedError = parseServerError(error, { toolName: name, provider });
|
|
534
|
+
if (isAuthError(parsedError) && retryCount < this.maxReauthRetries) {
|
|
535
|
+
if (provider) {
|
|
536
|
+
this.authState.set(provider, {
|
|
537
|
+
authenticated: false,
|
|
538
|
+
lastError: parsedError
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
if (this.onReauthRequired && provider) {
|
|
542
|
+
const reauthSuccess = await this.onReauthRequired({
|
|
543
|
+
provider,
|
|
544
|
+
error: parsedError,
|
|
545
|
+
toolName: name
|
|
546
|
+
});
|
|
547
|
+
if (reauthSuccess) {
|
|
548
|
+
return await this.callToolWithRetry(name, args, retryCount + 1);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
throw parsedError;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
getProviderForTool(toolName) {
|
|
556
|
+
for (const plugin of this.plugins) {
|
|
557
|
+
if (plugin.tools.includes(toolName) && plugin.oauth) {
|
|
558
|
+
return plugin.oauth.provider;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
return;
|
|
271
562
|
}
|
|
272
563
|
getTool(name) {
|
|
273
564
|
return this.availableTools.get(name);
|
|
@@ -309,10 +600,38 @@ class MCPClient {
|
|
|
309
600
|
isInitialized() {
|
|
310
601
|
return this.initialized;
|
|
311
602
|
}
|
|
603
|
+
getAuthState(provider) {
|
|
604
|
+
return this.authState.get(provider);
|
|
605
|
+
}
|
|
606
|
+
isProviderAuthenticated(provider) {
|
|
607
|
+
return this.authState.get(provider)?.authenticated ?? false;
|
|
608
|
+
}
|
|
609
|
+
async reauthenticate(provider) {
|
|
610
|
+
const state = this.authState.get(provider);
|
|
611
|
+
if (!state) {
|
|
612
|
+
throw new Error(`Provider "${provider}" not found in configured plugins`);
|
|
613
|
+
}
|
|
614
|
+
if (!this.onReauthRequired) {
|
|
615
|
+
throw new Error("No re-authentication handler configured. Set onReauthRequired in client config.");
|
|
616
|
+
}
|
|
617
|
+
const lastError = state.lastError || new (await Promise.resolve().then(() => (init_errors(), exports_errors))).AuthenticationError("Manual re-authentication requested", undefined, provider);
|
|
618
|
+
const success = await this.onReauthRequired({
|
|
619
|
+
provider,
|
|
620
|
+
error: lastError
|
|
621
|
+
});
|
|
622
|
+
if (success) {
|
|
623
|
+
this.authState.set(provider, { authenticated: true });
|
|
624
|
+
}
|
|
625
|
+
return success;
|
|
626
|
+
}
|
|
312
627
|
}
|
|
313
628
|
function createMCPClient(config) {
|
|
314
629
|
return new MCPClient(config);
|
|
315
630
|
}
|
|
631
|
+
|
|
632
|
+
// src/index.ts
|
|
633
|
+
init_errors();
|
|
634
|
+
|
|
316
635
|
// src/plugins/github.ts
|
|
317
636
|
var GITHUB_TOOLS = [
|
|
318
637
|
"github_create_issue",
|
|
@@ -440,7 +759,7 @@ function convertMCPToolToVercelAI(mcpTool, client) {
|
|
|
440
759
|
description: mcpTool.description || `Execute ${mcpTool.name}`,
|
|
441
760
|
parameters: convertMCPSchemaToParameters(mcpTool.inputSchema),
|
|
442
761
|
execute: async (args) => {
|
|
443
|
-
const result = await client.
|
|
762
|
+
const result = await client._callToolByName(mcpTool.name, args);
|
|
444
763
|
return result;
|
|
445
764
|
}
|
|
446
765
|
};
|
|
@@ -457,6 +776,10 @@ function getVercelAITools(client) {
|
|
|
457
776
|
return convertMCPToolsToVercelAI(client);
|
|
458
777
|
}
|
|
459
778
|
export {
|
|
779
|
+
parseServerError,
|
|
780
|
+
isTokenExpiredError,
|
|
781
|
+
isAuthorizationError,
|
|
782
|
+
isAuthError,
|
|
460
783
|
gmailPlugin,
|
|
461
784
|
githubPlugin,
|
|
462
785
|
getVercelAITools,
|
|
@@ -465,7 +788,13 @@ export {
|
|
|
465
788
|
createMCPClient,
|
|
466
789
|
convertMCPToolsToVercelAI,
|
|
467
790
|
convertMCPToolToVercelAI,
|
|
791
|
+
ToolCallError,
|
|
792
|
+
TokenExpiredError,
|
|
468
793
|
MCPMethod,
|
|
469
794
|
MCPClient,
|
|
470
|
-
|
|
795
|
+
IntegrateSDKError,
|
|
796
|
+
HttpSessionTransport,
|
|
797
|
+
ConnectionError,
|
|
798
|
+
AuthorizationError,
|
|
799
|
+
AuthenticationError
|
|
471
800
|
};
|
|
@@ -42,7 +42,7 @@ export declare function convertMCPToolToVercelAI(mcpTool: MCPTool, client: MCPCl
|
|
|
42
42
|
* const tools = convertMCPToolsToVercelAI(mcpClient);
|
|
43
43
|
*
|
|
44
44
|
* const result = await generateText({
|
|
45
|
-
* model: openai('gpt-
|
|
45
|
+
* model: openai('gpt-5'),
|
|
46
46
|
* prompt: 'Create a GitHub issue in my repo',
|
|
47
47
|
* tools,
|
|
48
48
|
* });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel-ai.d.ts","sourceRoot":"","sources":["../../src/integrations/vercel-ai.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9D;AAcD;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,SAAS,GAChB,YAAY,
|
|
1
|
+
{"version":3,"file":"vercel-ai.d.ts","sourceRoot":"","sources":["../../src/integrations/vercel-ai.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9D;AAcD;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,SAAS,GAChB,YAAY,CAUd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,GAChB,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAS9B;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,gCAEjD"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generic OAuth Plugin
|
|
3
|
-
*
|
|
3
|
+
* Configure OAuth and enable tools for any integration supported by the server
|
|
4
4
|
*/
|
|
5
5
|
import type { MCPPlugin } from "./types.js";
|
|
6
6
|
/**
|
|
7
7
|
* Generic OAuth plugin configuration
|
|
8
8
|
*/
|
|
9
9
|
export interface GenericOAuthPluginConfig {
|
|
10
|
-
/** Plugin unique identifier */
|
|
10
|
+
/** Plugin unique identifier (must match the integration ID on the server) */
|
|
11
11
|
id: string;
|
|
12
12
|
/** OAuth provider name */
|
|
13
13
|
provider: string;
|
|
@@ -17,7 +17,7 @@ export interface GenericOAuthPluginConfig {
|
|
|
17
17
|
clientSecret: string;
|
|
18
18
|
/** OAuth scopes */
|
|
19
19
|
scopes: string[];
|
|
20
|
-
/** Tool names to enable */
|
|
20
|
+
/** Tool names to enable from the server (must exist on the server) */
|
|
21
21
|
tools: string[];
|
|
22
22
|
/** OAuth redirect URI */
|
|
23
23
|
redirectUri?: string;
|
|
@@ -33,10 +33,13 @@ export interface GenericOAuthPluginConfig {
|
|
|
33
33
|
/**
|
|
34
34
|
* Generic OAuth Plugin
|
|
35
35
|
*
|
|
36
|
-
*
|
|
36
|
+
* Configure OAuth and enable tools for any integration supported by the Integrate MCP server.
|
|
37
|
+
* Note: This does NOT create new tools - it only configures access to existing server-side tools.
|
|
38
|
+
* All tools must be implemented on the server and exposed via the MCP protocol.
|
|
37
39
|
*
|
|
38
40
|
* @example
|
|
39
41
|
* ```typescript
|
|
42
|
+
* // Configure Slack integration (assuming server supports Slack tools)
|
|
40
43
|
* const slackPlugin = genericOAuthPlugin({
|
|
41
44
|
* id: 'slack',
|
|
42
45
|
* provider: 'slack',
|
|
@@ -44,28 +47,32 @@ export interface GenericOAuthPluginConfig {
|
|
|
44
47
|
* clientSecret: process.env.SLACK_CLIENT_SECRET!,
|
|
45
48
|
* scopes: ['chat:write', 'channels:read'],
|
|
46
49
|
* tools: [
|
|
47
|
-
* '
|
|
48
|
-
* '
|
|
49
|
-
* 'slack/getChannel',
|
|
50
|
+
* 'slack_send_message', // Must exist on server
|
|
51
|
+
* 'slack_list_channels', // Must exist on server
|
|
50
52
|
* ],
|
|
51
53
|
* });
|
|
52
54
|
*
|
|
53
55
|
* const client = createMCPClient({
|
|
54
|
-
* serverUrl: 'http://localhost:3000/mcp',
|
|
55
56
|
* plugins: [slackPlugin],
|
|
56
57
|
* });
|
|
58
|
+
*
|
|
59
|
+
* await client.connect();
|
|
60
|
+
* // Call server tools using _callToolByName
|
|
61
|
+
* await client._callToolByName('slack_send_message', { channel: '#general', text: 'Hello' });
|
|
57
62
|
* ```
|
|
58
63
|
*/
|
|
59
64
|
export declare function genericOAuthPlugin(config: GenericOAuthPluginConfig): MCPPlugin;
|
|
60
65
|
/**
|
|
61
66
|
* Create a simple plugin without OAuth
|
|
62
|
-
*
|
|
67
|
+
* Enable server-provided tools that don't require authentication
|
|
68
|
+
* Note: Tools must exist on the server - this does not create new tools
|
|
63
69
|
*
|
|
64
70
|
* @example
|
|
65
71
|
* ```typescript
|
|
72
|
+
* // Enable server-provided math tools (if they exist on the server)
|
|
66
73
|
* const mathPlugin = createSimplePlugin({
|
|
67
74
|
* id: 'math',
|
|
68
|
-
* tools: ['
|
|
75
|
+
* tools: ['math_add', 'math_subtract', 'math_multiply', 'math_divide'],
|
|
69
76
|
* });
|
|
70
77
|
* ```
|
|
71
78
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../src/plugins/generic.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC
|
|
1
|
+
{"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../src/plugins/generic.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,6EAA6E;IAC7E,EAAE,EAAE,MAAM,CAAC;IACX,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,sEAAsE;IACtE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,uCAAuC;IACvC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC/C,sCAAsC;IACtC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACvD,mCAAmC;IACnC,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACtD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,wBAAwB,GAC/B,SAAS,CAmBX;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC/C,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACvD,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACtD,GAAG,SAAS,CAQZ"}
|