integrate-sdk 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -0
- package/dist/integrations/vercel-ai.d.ts +61 -0
- package/dist/integrations/vercel-ai.d.ts.map +1 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ A type-safe TypeScript SDK for connecting to the Integrate MCP (Model Context Pr
|
|
|
14
14
|
- [GitHub Plugin](#github-plugin)
|
|
15
15
|
- [Gmail Plugin](#gmail-plugin)
|
|
16
16
|
- [Creating Custom Plugins](#creating-custom-plugins)
|
|
17
|
+
- [Integration with Vercel AI SDK](#integration-with-vercel-ai-sdk)
|
|
17
18
|
- [Advanced Usage](#advanced-usage)
|
|
18
19
|
- [API Reference](#api-reference)
|
|
19
20
|
- [Architecture](#architecture)
|
|
@@ -229,6 +230,57 @@ export function customPlugin(config: CustomConfig): MCPPlugin {
|
|
|
229
230
|
}
|
|
230
231
|
```
|
|
231
232
|
|
|
233
|
+
## Integration with Vercel AI SDK
|
|
234
|
+
|
|
235
|
+
The SDK includes built-in support for Vercel's AI SDK, allowing you to give AI models access to all your integrations.
|
|
236
|
+
|
|
237
|
+
### Quick Example
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
import { createMCPClient, githubPlugin, getVercelAITools } from 'integrate-sdk';
|
|
241
|
+
import { generateText } from 'ai';
|
|
242
|
+
import { openai } from '@ai-sdk/openai';
|
|
243
|
+
|
|
244
|
+
// 1. Create and connect MCP client
|
|
245
|
+
const mcpClient = createMCPClient({
|
|
246
|
+
plugins: [
|
|
247
|
+
githubPlugin({
|
|
248
|
+
clientId: process.env.GITHUB_CLIENT_ID!,
|
|
249
|
+
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
|
|
250
|
+
}),
|
|
251
|
+
],
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
await mcpClient.connect();
|
|
255
|
+
|
|
256
|
+
// 2. Get tools in Vercel AI SDK format
|
|
257
|
+
const tools = getVercelAITools(mcpClient);
|
|
258
|
+
|
|
259
|
+
// 3. Use with AI models
|
|
260
|
+
const result = await generateText({
|
|
261
|
+
model: openai('gpt-4'),
|
|
262
|
+
prompt: 'Create a GitHub issue titled "Bug in login" in myrepo',
|
|
263
|
+
tools,
|
|
264
|
+
maxToolRoundtrips: 5,
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
console.log(result.text);
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### How It Works
|
|
271
|
+
|
|
272
|
+
1. **`getVercelAITools(client)`** - Converts all enabled MCP tools to Vercel AI SDK format
|
|
273
|
+
2. **Automatic execution** - When the AI calls a tool, it executes through your MCP client
|
|
274
|
+
3. **Type-safe** - Full TypeScript support with proper types
|
|
275
|
+
|
|
276
|
+
### Available Functions
|
|
277
|
+
|
|
278
|
+
- **`getVercelAITools(client)`** - Get all enabled tools in Vercel AI SDK format
|
|
279
|
+
- **`convertMCPToolsToVercelAI(client)`** - Same as above, alternative name
|
|
280
|
+
- **`convertMCPToolToVercelAI(tool, client)`** - Convert a single MCP tool
|
|
281
|
+
|
|
282
|
+
See `examples/vercel-ai-integration.ts` for a complete working example.
|
|
283
|
+
|
|
232
284
|
## Advanced Usage
|
|
233
285
|
|
|
234
286
|
### Accessing OAuth Configurations
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export { gmailPlugin } from "./plugins/gmail.js";
|
|
|
12
12
|
export type { GmailPluginConfig, GmailTools } from "./plugins/gmail.js";
|
|
13
13
|
export { genericOAuthPlugin, createSimplePlugin, } from "./plugins/generic.js";
|
|
14
14
|
export type { GenericOAuthPluginConfig } from "./plugins/generic.js";
|
|
15
|
+
export { convertMCPToolToVercelAI, convertMCPToolsToVercelAI, getVercelAITools, } from "./integrations/vercel-ai.js";
|
|
16
|
+
export type { VercelAITool } from "./integrations/vercel-ai.js";
|
|
15
17
|
export type { JSONRPCRequest, JSONRPCResponse, JSONRPCSuccessResponse, JSONRPCErrorResponse, JSONRPCNotification, MCPTool, MCPToolsListResponse, MCPToolCallParams, MCPToolCallResponse, MCPInitializeParams, MCPInitializeResponse, } from "./protocol/messages.js";
|
|
16
18
|
export { MCPMethod } from "./protocol/messages.js";
|
|
17
19
|
export { HttpSessionTransport } from "./transport/http-session.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACzD,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGzD,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,YAAY,EACV,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAGrE,YAAY,EACV,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,OAAO,EACP,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,SAAS,E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oB,EAAE,MAAM,6BAA6B,CAAC;AACnE,YAAY,EACV,cAAc,EACd,2BAA2B,GAC5B,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -431,12 +431,40 @@ function createSimplePlugin(config) {
|
|
|
431
431
|
onDisconnect: config.onDisconnect
|
|
432
432
|
};
|
|
433
433
|
}
|
|
434
|
+
// src/integrations/vercel-ai.ts
|
|
435
|
+
function convertMCPSchemaToParameters(inputSchema) {
|
|
436
|
+
return inputSchema;
|
|
437
|
+
}
|
|
438
|
+
function convertMCPToolToVercelAI(mcpTool, client) {
|
|
439
|
+
return {
|
|
440
|
+
description: mcpTool.description || `Execute ${mcpTool.name}`,
|
|
441
|
+
parameters: convertMCPSchemaToParameters(mcpTool.inputSchema),
|
|
442
|
+
execute: async (args) => {
|
|
443
|
+
const result = await client.callTool(mcpTool.name, args);
|
|
444
|
+
return result;
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
function convertMCPToolsToVercelAI(client) {
|
|
449
|
+
const mcpTools = client.getEnabledTools();
|
|
450
|
+
const vercelTools = {};
|
|
451
|
+
for (const mcpTool of mcpTools) {
|
|
452
|
+
vercelTools[mcpTool.name] = convertMCPToolToVercelAI(mcpTool, client);
|
|
453
|
+
}
|
|
454
|
+
return vercelTools;
|
|
455
|
+
}
|
|
456
|
+
function getVercelAITools(client) {
|
|
457
|
+
return convertMCPToolsToVercelAI(client);
|
|
458
|
+
}
|
|
434
459
|
export {
|
|
435
460
|
gmailPlugin,
|
|
436
461
|
githubPlugin,
|
|
462
|
+
getVercelAITools,
|
|
437
463
|
genericOAuthPlugin,
|
|
438
464
|
createSimplePlugin,
|
|
439
465
|
createMCPClient,
|
|
466
|
+
convertMCPToolsToVercelAI,
|
|
467
|
+
convertMCPToolToVercelAI,
|
|
440
468
|
MCPMethod,
|
|
441
469
|
MCPClient,
|
|
442
470
|
HttpSessionTransport
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vercel AI SDK Integration
|
|
3
|
+
*
|
|
4
|
+
* Helper functions to convert MCP tools to Vercel AI SDK format
|
|
5
|
+
*/
|
|
6
|
+
import type { MCPClient } from "../client.js";
|
|
7
|
+
import type { MCPTool } from "../protocol/messages.js";
|
|
8
|
+
/**
|
|
9
|
+
* Tool definition for Vercel AI SDK
|
|
10
|
+
*/
|
|
11
|
+
export interface VercelAITool {
|
|
12
|
+
description: string;
|
|
13
|
+
parameters: Record<string, unknown>;
|
|
14
|
+
execute: (args: Record<string, unknown>) => Promise<unknown>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Convert a single MCP tool to Vercel AI SDK format
|
|
18
|
+
*
|
|
19
|
+
* @param mcpTool - The MCP tool definition
|
|
20
|
+
* @param client - The MCP client instance (used for executing the tool)
|
|
21
|
+
* @returns Vercel AI SDK compatible tool definition
|
|
22
|
+
*/
|
|
23
|
+
export declare function convertMCPToolToVercelAI(mcpTool: MCPTool, client: MCPClient): VercelAITool;
|
|
24
|
+
/**
|
|
25
|
+
* Convert all enabled MCP tools to Vercel AI SDK format
|
|
26
|
+
*
|
|
27
|
+
* @param client - The MCP client instance (must be connected)
|
|
28
|
+
* @returns Object mapping tool names to Vercel AI SDK tool definitions
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* import { createMCPClient, githubPlugin } from 'integrate-sdk';
|
|
33
|
+
* import { convertMCPToolsToVercelAI } from 'integrate-sdk/vercel-ai';
|
|
34
|
+
* import { generateText } from 'ai';
|
|
35
|
+
*
|
|
36
|
+
* const mcpClient = createMCPClient({
|
|
37
|
+
* plugins: [githubPlugin({ clientId: '...', clientSecret: '...' })],
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* await mcpClient.connect();
|
|
41
|
+
*
|
|
42
|
+
* const tools = convertMCPToolsToVercelAI(mcpClient);
|
|
43
|
+
*
|
|
44
|
+
* const result = await generateText({
|
|
45
|
+
* model: openai('gpt-4'),
|
|
46
|
+
* prompt: 'Create a GitHub issue in my repo',
|
|
47
|
+
* tools,
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function convertMCPToolsToVercelAI(client: MCPClient): Record<string, VercelAITool>;
|
|
52
|
+
/**
|
|
53
|
+
* Get tools in a format compatible with Vercel AI SDK's tools parameter
|
|
54
|
+
*
|
|
55
|
+
* This is an alternative that returns the tools in the exact format expected by ai.generateText()
|
|
56
|
+
*
|
|
57
|
+
* @param client - The MCP client instance (must be connected)
|
|
58
|
+
* @returns Tools object ready to pass to generateText({ tools: ... })
|
|
59
|
+
*/
|
|
60
|
+
export declare function getVercelAITools(client: MCPClient): Record<string, VercelAITool>;
|
|
61
|
+
//# sourceMappingURL=vercel-ai.d.ts.map
|
|
@@ -0,0 +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,CASd;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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "integrate-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Type-safe TypeScript SDK for MCP Client with plugin-based OAuth provider configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"build:types": "tsc --emitDeclarationOnly --declaration --declarationMap",
|
|
29
29
|
"dev": "bun --watch src/index.ts",
|
|
30
30
|
"type-check": "tsc --noEmit",
|
|
31
|
-
"test": "bun test tests/protocol tests/plugins tests/client tests/integration/simple-integration.test.ts",
|
|
32
|
-
"test:watch": "bun test --watch tests/protocol tests/plugins tests/client tests/integration/simple-integration.test.ts",
|
|
33
|
-
"test:unit": "bun test tests/protocol tests/plugins tests/client",
|
|
31
|
+
"test": "bun test tests/protocol tests/plugins tests/client tests/integrations tests/integration/simple-integration.test.ts",
|
|
32
|
+
"test:watch": "bun test --watch tests/protocol tests/plugins tests/client tests/integrations tests/integration/simple-integration.test.ts",
|
|
33
|
+
"test:unit": "bun test tests/protocol tests/plugins tests/client tests/integrations",
|
|
34
34
|
"test:integration": "bun test tests/integration/simple-integration.test.ts",
|
|
35
|
-
"test:coverage": "bun test --coverage tests/protocol tests/plugins tests/client tests/integration/simple-integration.test.ts"
|
|
35
|
+
"test:coverage": "bun test --coverage tests/protocol tests/plugins tests/client tests/integrations tests/integration/simple-integration.test.ts"
|
|
36
36
|
},
|
|
37
37
|
"keywords": [
|
|
38
38
|
"mcp",
|