integrate-sdk 0.1.3 → 0.1.5

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # Integrate SDK
2
2
 
3
+ [![Tests](https://github.com/Revyo/integrate-sdk/actions/workflows/test.yml/badge.svg)](https://github.com/Revyo/integrate-sdk/actions/workflows/test.yml)
4
+ [![npm version](https://badge.fury.io/js/integrate-sdk.svg)](https://www.npmjs.com/package/integrate-sdk)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
3
7
  A type-safe TypeScript SDK for connecting to the Integrate MCP (Model Context Protocol) server. Access GitHub, Gmail, Notion, and other integrations through a simple, plugin-based API.
4
8
 
5
9
  **Server:** `https://mcp.integrate.dev/api/v1/mcp`
@@ -14,6 +18,7 @@ A type-safe TypeScript SDK for connecting to the Integrate MCP (Model Context Pr
14
18
  - [GitHub Plugin](#github-plugin)
15
19
  - [Gmail Plugin](#gmail-plugin)
16
20
  - [Creating Custom Plugins](#creating-custom-plugins)
21
+ - [Integration with Vercel AI SDK](#integration-with-vercel-ai-sdk)
17
22
  - [Advanced Usage](#advanced-usage)
18
23
  - [API Reference](#api-reference)
19
24
  - [Architecture](#architecture)
@@ -229,6 +234,57 @@ export function customPlugin(config: CustomConfig): MCPPlugin {
229
234
  }
230
235
  ```
231
236
 
237
+ ## Integration with Vercel AI SDK
238
+
239
+ The SDK includes built-in support for Vercel's AI SDK, allowing you to give AI models access to all your integrations.
240
+
241
+ ### Quick Example
242
+
243
+ ```typescript
244
+ import { createMCPClient, githubPlugin, getVercelAITools } from 'integrate-sdk';
245
+ import { generateText } from 'ai';
246
+ import { openai } from '@ai-sdk/openai';
247
+
248
+ // 1. Create and connect MCP client
249
+ const mcpClient = createMCPClient({
250
+ plugins: [
251
+ githubPlugin({
252
+ clientId: process.env.GITHUB_CLIENT_ID!,
253
+ clientSecret: process.env.GITHUB_CLIENT_SECRET!,
254
+ }),
255
+ ],
256
+ });
257
+
258
+ await mcpClient.connect();
259
+
260
+ // 2. Get tools in Vercel AI SDK format
261
+ const tools = getVercelAITools(mcpClient);
262
+
263
+ // 3. Use with AI models
264
+ const result = await generateText({
265
+ model: openai('gpt-4'),
266
+ prompt: 'Create a GitHub issue titled "Bug in login" in myrepo',
267
+ tools,
268
+ maxToolRoundtrips: 5,
269
+ });
270
+
271
+ console.log(result.text);
272
+ ```
273
+
274
+ ### How It Works
275
+
276
+ 1. **`getVercelAITools(client)`** - Converts all enabled MCP tools to Vercel AI SDK format
277
+ 2. **Automatic execution** - When the AI calls a tool, it executes through your MCP client
278
+ 3. **Type-safe** - Full TypeScript support with proper types
279
+
280
+ ### Available Functions
281
+
282
+ - **`getVercelAITools(client)`** - Get all enabled tools in Vercel AI SDK format
283
+ - **`convertMCPToolsToVercelAI(client)`** - Same as above, alternative name
284
+ - **`convertMCPToolToVercelAI(tool, client)`** - Convert a single MCP tool
285
+
286
+ See `examples/vercel-ai-integration.ts` for a complete working example.
287
+
232
288
  ## Advanced Usage
233
289
 
234
290
  ### 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";
@@ -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,EAAE,MAAM,wBAAwB,CAAC;AAGnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,YAAY,EACV,cAAc,EACd,2BAA2B,GAC5B,MAAM,6BAA6B,CAAC"}
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,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,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,EAAE,MAAM,wBAAwB,CAAC;AAGnD,OAAO,EAAE,oBAAoB,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",
3
+ "version": "0.1.5",
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",