integrate-sdk 0.6.6 → 0.6.8
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/dist/adapters/svelte-kit.js +1 -1
- package/dist/index.js +68 -33
- package/dist/server.js +67 -11
- package/dist/src/adapters/node.d.ts +1 -1
- package/dist/src/adapters/solid-start.d.ts +1 -1
- package/dist/src/adapters/svelte-kit.d.ts +2 -2
- package/dist/src/adapters/svelte-kit.d.ts.map +1 -1
- package/dist/src/adapters/tanstack-start.d.ts +2 -2
- package/dist/src/integrations/anthropic.d.ts +208 -0
- package/dist/src/integrations/anthropic.d.ts.map +1 -0
- package/dist/src/integrations/cloudflare.d.ts +158 -0
- package/dist/src/integrations/cloudflare.d.ts.map +1 -0
- package/dist/src/integrations/google.d.ts +159 -0
- package/dist/src/integrations/google.d.ts.map +1 -0
- package/dist/src/integrations/index.d.ts +79 -0
- package/dist/src/integrations/index.d.ts.map +1 -0
- package/dist/src/integrations/langchain.d.ts +139 -0
- package/dist/src/integrations/langchain.d.ts.map +1 -0
- package/dist/src/integrations/llamaindex.d.ts +125 -0
- package/dist/src/integrations/llamaindex.d.ts.map +1 -0
- package/dist/src/integrations/mastra.d.ts +138 -0
- package/dist/src/integrations/mastra.d.ts.map +1 -0
- package/dist/src/integrations/openai-agents.d.ts +117 -0
- package/dist/src/integrations/openai-agents.d.ts.map +1 -0
- package/dist/src/integrations/openai.d.ts +158 -0
- package/dist/src/integrations/openai.d.ts.map +1 -0
- package/dist/src/integrations/utils.d.ts +56 -0
- package/dist/src/integrations/utils.d.ts.map +1 -0
- package/dist/src/integrations/vercel-ai.d.ts +2 -16
- package/dist/src/integrations/vercel-ai.d.ts.map +1 -1
- package/dist/src/plugins/generic.d.ts.map +1 -1
- package/dist/src/plugins/github.d.ts.map +1 -1
- package/dist/src/plugins/gmail.d.ts.map +1 -1
- package/dist/src/server.d.ts +7 -0
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/utils/env.d.ts +18 -0
- package/dist/src/utils/env.d.ts.map +1 -0
- package/integrations.ts +9 -0
- package/package.json +77 -4
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare Workers AI Integration
|
|
3
|
+
*
|
|
4
|
+
* Helper functions to convert MCP tools to Cloudflare Workers AI format
|
|
5
|
+
*/
|
|
6
|
+
import type { MCPClient } from "../client.js";
|
|
7
|
+
import type { MCPTool } from "../protocol/messages.js";
|
|
8
|
+
import { type AIToolsOptions } from "./utils.js";
|
|
9
|
+
/**
|
|
10
|
+
* Cloudflare AI tool definition
|
|
11
|
+
* Compatible with Cloudflare Workers AI
|
|
12
|
+
*/
|
|
13
|
+
export interface CloudflareTool {
|
|
14
|
+
type: 'function';
|
|
15
|
+
function: {
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
parameters: {
|
|
19
|
+
type: 'object';
|
|
20
|
+
properties: Record<string, {
|
|
21
|
+
type: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
}>;
|
|
24
|
+
required: string[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Options for converting MCP tools to Cloudflare format
|
|
30
|
+
*/
|
|
31
|
+
export interface CloudflareToolsOptions extends AIToolsOptions {
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Convert a single MCP tool to Cloudflare Workers AI format
|
|
35
|
+
*
|
|
36
|
+
* @param mcpTool - The MCP tool definition
|
|
37
|
+
* @param client - The MCP client instance (used for executing the tool)
|
|
38
|
+
* @param options - Optional configuration including provider tokens
|
|
39
|
+
* @returns Cloudflare compatible tool definition
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const cloudflareTool = convertMCPToolToCloudflare(mcpTool, client);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function convertMCPToolToCloudflare(mcpTool: MCPTool, _client: MCPClient<any>, _options?: CloudflareToolsOptions): CloudflareTool;
|
|
47
|
+
/**
|
|
48
|
+
* Convert all enabled MCP tools to Cloudflare Workers AI format
|
|
49
|
+
* Returns a dictionary keyed by tool name
|
|
50
|
+
*
|
|
51
|
+
* @param client - The MCP client instance (must be connected)
|
|
52
|
+
* @param options - Optional configuration including provider tokens
|
|
53
|
+
* @returns Dictionary of Cloudflare compatible tool definitions
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* // Client-side usage
|
|
58
|
+
* const tools = convertMCPToolsToCloudflare(mcpClient);
|
|
59
|
+
*
|
|
60
|
+
* // Server-side with provider tokens
|
|
61
|
+
* const tools = convertMCPToolsToCloudflare(serverClient, {
|
|
62
|
+
* providerTokens: { github: 'ghp_...', gmail: 'ya29...' }
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function convertMCPToolsToCloudflare(client: MCPClient<any>, options?: CloudflareToolsOptions): Record<string, CloudflareTool>;
|
|
67
|
+
/**
|
|
68
|
+
* Execute a tool call from Cloudflare Workers AI
|
|
69
|
+
*
|
|
70
|
+
* @param client - The MCP client instance
|
|
71
|
+
* @param toolCall - The tool call with name and arguments
|
|
72
|
+
* @param options - Optional configuration including provider tokens
|
|
73
|
+
* @returns Tool execution result as JSON string
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const result = await executeCloudflareToolCall(client, {
|
|
78
|
+
* name: 'github_create_issue',
|
|
79
|
+
* arguments: { owner: 'user', repo: 'repo', title: 'Bug' }
|
|
80
|
+
* }, { providerTokens });
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare function executeCloudflareToolCall(client: MCPClient<any>, toolCall: {
|
|
84
|
+
name: string;
|
|
85
|
+
arguments: Record<string, unknown> | string;
|
|
86
|
+
}, options?: CloudflareToolsOptions): Promise<string>;
|
|
87
|
+
/**
|
|
88
|
+
* Get tools in a format compatible with Cloudflare Workers AI
|
|
89
|
+
*
|
|
90
|
+
* Automatically connects the client if not already connected.
|
|
91
|
+
*
|
|
92
|
+
* @param client - The MCP client instance
|
|
93
|
+
* @param options - Optional configuration including provider tokens for server-side usage
|
|
94
|
+
* @returns Dictionary of tools ready to use with Cloudflare Workers AI
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* // Cloudflare Worker usage
|
|
99
|
+
* import { createMCPClient, githubPlugin } from 'integrate-sdk';
|
|
100
|
+
* import { getCloudflareTools, executeCloudflareToolCall } from 'integrate-sdk/integrations/cloudflare';
|
|
101
|
+
*
|
|
102
|
+
* export default {
|
|
103
|
+
* async fetch(request: Request, env: Env): Promise<Response> {
|
|
104
|
+
* const client = createMCPClient({
|
|
105
|
+
* plugins: [githubPlugin({ clientId: env.GITHUB_CLIENT_ID })],
|
|
106
|
+
* });
|
|
107
|
+
*
|
|
108
|
+
* const tools = await getCloudflareTools(client);
|
|
109
|
+
* const ai = new Ai(env.AI);
|
|
110
|
+
*
|
|
111
|
+
* const response = await ai.run('@cf/meta/llama-3-8b-instruct', {
|
|
112
|
+
* messages: [{ role: 'user', content: 'Create a GitHub issue' }],
|
|
113
|
+
* tools: Object.values(tools)
|
|
114
|
+
* });
|
|
115
|
+
*
|
|
116
|
+
* return Response.json(response);
|
|
117
|
+
* }
|
|
118
|
+
* };
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* // Server-side usage with tokens from client
|
|
124
|
+
* import { createMCPServer, githubPlugin } from 'integrate-sdk/server';
|
|
125
|
+
* import { getCloudflareTools, executeCloudflareToolCall } from 'integrate-sdk/integrations/cloudflare';
|
|
126
|
+
*
|
|
127
|
+
* const { client: serverClient } = createMCPServer({
|
|
128
|
+
* plugins: [githubPlugin({
|
|
129
|
+
* clientId: '...',
|
|
130
|
+
* clientSecret: '...'
|
|
131
|
+
* })],
|
|
132
|
+
* });
|
|
133
|
+
*
|
|
134
|
+
* // In your API route
|
|
135
|
+
* export async function POST(req: Request) {
|
|
136
|
+
* const providerTokens = JSON.parse(req.headers.get('x-integrate-tokens') || '{}');
|
|
137
|
+
* const tools = await getCloudflareTools(serverClient, { providerTokens });
|
|
138
|
+
*
|
|
139
|
+
* // Use with Cloudflare AI
|
|
140
|
+
* const ai = new Ai(env.AI);
|
|
141
|
+
* const response = await ai.run('@cf/meta/llama-3-8b-instruct', {
|
|
142
|
+
* messages: [{ role: 'user', content: 'Create a GitHub issue' }],
|
|
143
|
+
* tools: Object.values(tools)
|
|
144
|
+
* });
|
|
145
|
+
*
|
|
146
|
+
* // Handle tool calls
|
|
147
|
+
* if (response.tool_calls) {
|
|
148
|
+
* for (const toolCall of response.tool_calls) {
|
|
149
|
+
* await executeCloudflareToolCall(serverClient, toolCall, { providerTokens });
|
|
150
|
+
* }
|
|
151
|
+
* }
|
|
152
|
+
*
|
|
153
|
+
* return Response.json(response);
|
|
154
|
+
* }
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
export declare function getCloudflareTools(client: MCPClient<any>, options?: CloudflareToolsOptions): Promise<Record<string, CloudflareTool>>;
|
|
158
|
+
//# sourceMappingURL=cloudflare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../../../src/integrations/cloudflare.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAA+C,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAE9F;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM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
/**
|
|
2
|
+
* Google GenAI Integration
|
|
3
|
+
*
|
|
4
|
+
* Helper functions to convert MCP tools to Google GenAI format
|
|
5
|
+
*/
|
|
6
|
+
import type { MCPClient } from "../client.js";
|
|
7
|
+
import type { MCPTool } from "../protocol/messages.js";
|
|
8
|
+
import { type AIToolsOptions } from "./utils.js";
|
|
9
|
+
/**
|
|
10
|
+
* Google GenAI function declaration
|
|
11
|
+
* Compatible with @google/genai SDK
|
|
12
|
+
*/
|
|
13
|
+
export interface GoogleTool {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
parameters: {
|
|
17
|
+
type: 'object';
|
|
18
|
+
description?: string;
|
|
19
|
+
properties?: Record<string, unknown>;
|
|
20
|
+
required?: string[];
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Google GenAI function call
|
|
26
|
+
*/
|
|
27
|
+
export interface GoogleFunctionCall {
|
|
28
|
+
name: string;
|
|
29
|
+
args: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Options for converting MCP tools to Google GenAI format
|
|
33
|
+
*/
|
|
34
|
+
export interface GoogleToolsOptions extends AIToolsOptions {
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Convert a single MCP tool to Google GenAI format
|
|
38
|
+
*
|
|
39
|
+
* @param mcpTool - The MCP tool definition
|
|
40
|
+
* @param client - The MCP client instance (used for executing the tool)
|
|
41
|
+
* @param options - Optional configuration including provider tokens
|
|
42
|
+
* @returns Google GenAI compatible tool definition
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const googleTool = convertMCPToolToGoogle(mcpTool, client);
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function convertMCPToolToGoogle(mcpTool: MCPTool, _client: MCPClient<any>, _options?: GoogleToolsOptions): GoogleTool;
|
|
50
|
+
/**
|
|
51
|
+
* Convert all enabled MCP tools to Google GenAI format
|
|
52
|
+
*
|
|
53
|
+
* @param client - The MCP client instance (must be connected)
|
|
54
|
+
* @param options - Optional configuration including provider tokens
|
|
55
|
+
* @returns Array of Google GenAI compatible tool definitions
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* // Client-side usage
|
|
60
|
+
* const tools = convertMCPToolsToGoogle(mcpClient);
|
|
61
|
+
*
|
|
62
|
+
* // Server-side with provider tokens
|
|
63
|
+
* const tools = convertMCPToolsToGoogle(serverClient, {
|
|
64
|
+
* providerTokens: { github: 'ghp_...', gmail: 'ya29...' }
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function convertMCPToolsToGoogle(client: MCPClient<any>, options?: GoogleToolsOptions): GoogleTool[];
|
|
69
|
+
/**
|
|
70
|
+
* Execute a function call from Google GenAI
|
|
71
|
+
*
|
|
72
|
+
* @param client - The MCP client instance
|
|
73
|
+
* @param functionCall - The function call from Google GenAI response
|
|
74
|
+
* @param options - Optional configuration including provider tokens
|
|
75
|
+
* @returns Tool execution result as JSON string
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const result = await executeGoogleFunctionCall(client, {
|
|
80
|
+
* name: 'github_create_issue',
|
|
81
|
+
* args: { owner: 'user', repo: 'repo', title: 'Bug' }
|
|
82
|
+
* }, { providerTokens });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare function executeGoogleFunctionCall(client: MCPClient<any>, functionCall: GoogleFunctionCall, options?: GoogleToolsOptions): Promise<string>;
|
|
86
|
+
/**
|
|
87
|
+
* Get tools in a format compatible with Google GenAI
|
|
88
|
+
*
|
|
89
|
+
* Automatically connects the client if not already connected.
|
|
90
|
+
*
|
|
91
|
+
* @param client - The MCP client instance
|
|
92
|
+
* @param options - Optional configuration including provider tokens for server-side usage
|
|
93
|
+
* @returns Array of tools ready to use with Google GenAI
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* // Client-side usage
|
|
98
|
+
* import { createMCPClient, githubPlugin } from 'integrate-sdk';
|
|
99
|
+
* import { getGoogleTools } from 'integrate-sdk/integrations/google';
|
|
100
|
+
* import { GoogleGenerativeAI } from '@google/generative-ai';
|
|
101
|
+
*
|
|
102
|
+
* const client = createMCPClient({
|
|
103
|
+
* plugins: [githubPlugin({ clientId: '...' })],
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* const tools = await getGoogleTools(client);
|
|
107
|
+
* const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
|
|
108
|
+
* const model = genAI.getGenerativeModel({
|
|
109
|
+
* model: 'gemini-pro',
|
|
110
|
+
* tools: [{ functionDeclarations: tools }]
|
|
111
|
+
* });
|
|
112
|
+
*
|
|
113
|
+
* const result = await model.generateContent({
|
|
114
|
+
* contents: [{ role: 'user', parts: [{ text: 'Create a GitHub issue' }] }]
|
|
115
|
+
* });
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* // Server-side usage with tokens from client
|
|
121
|
+
* import { createMCPServer, githubPlugin } from 'integrate-sdk/server';
|
|
122
|
+
* import { getGoogleTools, executeGoogleFunctionCall } from 'integrate-sdk/integrations/google';
|
|
123
|
+
*
|
|
124
|
+
* const { client: serverClient } = createMCPServer({
|
|
125
|
+
* plugins: [githubPlugin({
|
|
126
|
+
* clientId: '...',
|
|
127
|
+
* clientSecret: '...'
|
|
128
|
+
* })],
|
|
129
|
+
* });
|
|
130
|
+
*
|
|
131
|
+
* // In your API route
|
|
132
|
+
* export async function POST(req: Request) {
|
|
133
|
+
* const providerTokens = JSON.parse(req.headers.get('x-integrate-tokens') || '{}');
|
|
134
|
+
* const tools = await getGoogleTools(serverClient, { providerTokens });
|
|
135
|
+
*
|
|
136
|
+
* const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY);
|
|
137
|
+
* const model = genAI.getGenerativeModel({
|
|
138
|
+
* model: 'gemini-pro',
|
|
139
|
+
* tools: [{ functionDeclarations: tools }]
|
|
140
|
+
* });
|
|
141
|
+
*
|
|
142
|
+
* const result = await model.generateContent({
|
|
143
|
+
* contents: [{ role: 'user', parts: [{ text: 'Create a GitHub issue' }] }]
|
|
144
|
+
* });
|
|
145
|
+
*
|
|
146
|
+
* // Handle function calls if any
|
|
147
|
+
* const functionCalls = result.response.functionCalls();
|
|
148
|
+
* if (functionCalls) {
|
|
149
|
+
* for (const call of functionCalls) {
|
|
150
|
+
* await executeGoogleFunctionCall(serverClient, call, { providerTokens });
|
|
151
|
+
* }
|
|
152
|
+
* }
|
|
153
|
+
*
|
|
154
|
+
* return Response.json(result.response);
|
|
155
|
+
* }
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
export declare function getGoogleTools(client: MCPClient<any>, options?: GoogleToolsOptions): Promise<GoogleTool[]>;
|
|
159
|
+
//# sourceMappingURL=google.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../../src/integrations/google.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAA+C,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAE9F;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACrC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,cAAc;CAAI;AAE9D;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,EACvB,QAAQ,CAAC,EAAE,kBAAkB,GAC5B,UAAU,CAWZ;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,UAAU,EAAE,CAGd;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,YAAY,EAAE,kBAAkB,EAChC,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,MAAM,CAAC,CAGjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,UAAU,EAAE,CAAC,CAGvB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Provider Integrations
|
|
3
|
+
*
|
|
4
|
+
* Unified interface for all AI provider integrations
|
|
5
|
+
*/
|
|
6
|
+
import type { MCPClient } from "../client.js";
|
|
7
|
+
import type { AIToolsOptions } from "./utils.js";
|
|
8
|
+
export * from "./vercel-ai.js";
|
|
9
|
+
export * from "./openai.js";
|
|
10
|
+
export * from "./openai-agents.js";
|
|
11
|
+
export * from "./anthropic.js";
|
|
12
|
+
export * from "./google.js";
|
|
13
|
+
export * from "./cloudflare.js";
|
|
14
|
+
export * from "./langchain.js";
|
|
15
|
+
export * from "./llamaindex.js";
|
|
16
|
+
export * from "./mastra.js";
|
|
17
|
+
export * from "./utils.js";
|
|
18
|
+
/**
|
|
19
|
+
* Supported AI provider names
|
|
20
|
+
*/
|
|
21
|
+
export type AIProviderName = "vercel-ai" | "openai" | "openai-agents" | "anthropic" | "google" | "cloudflare" | "langchain" | "llamaindex" | "mastra";
|
|
22
|
+
/**
|
|
23
|
+
* Generic function to get AI tools for any supported provider
|
|
24
|
+
*
|
|
25
|
+
* This provides a unified interface for getting tools from any AI provider.
|
|
26
|
+
* Use this when you want to dynamically switch between providers or support multiple providers.
|
|
27
|
+
*
|
|
28
|
+
* @param client - The MCP client instance
|
|
29
|
+
* @param provider - The AI provider name
|
|
30
|
+
* @param options - Optional configuration including provider tokens for server-side usage
|
|
31
|
+
* @returns Tools in the format expected by the specified provider
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // Dynamic provider selection
|
|
36
|
+
* import { createMCPClient, githubPlugin } from 'integrate-sdk';
|
|
37
|
+
* import { getAITools } from 'integrate-sdk/integrations';
|
|
38
|
+
*
|
|
39
|
+
* const client = createMCPClient({
|
|
40
|
+
* plugins: [githubPlugin({ clientId: '...' })],
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* // Choose provider at runtime
|
|
44
|
+
* const provider = process.env.AI_PROVIDER || 'openai';
|
|
45
|
+
* const tools = await getAITools(client, provider as any);
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // Server-side with provider tokens
|
|
51
|
+
* import { createMCPServer, githubPlugin } from 'integrate-sdk/server';
|
|
52
|
+
* import { getAITools } from 'integrate-sdk/integrations';
|
|
53
|
+
*
|
|
54
|
+
* const { client: serverClient } = createMCPServer({
|
|
55
|
+
* plugins: [githubPlugin({
|
|
56
|
+
* clientId: '...',
|
|
57
|
+
* clientSecret: '...'
|
|
58
|
+
* })],
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* export async function POST(req: Request) {
|
|
62
|
+
* const providerTokens = JSON.parse(req.headers.get('x-integrate-tokens') || '{}');
|
|
63
|
+
*
|
|
64
|
+
* // Support multiple providers
|
|
65
|
+
* const tools = await getAITools(serverClient, 'anthropic', { providerTokens });
|
|
66
|
+
* // ... use with Anthropic SDK
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function getAITools(client: MCPClient<any>, provider: "vercel-ai", options?: AIToolsOptions): Promise<Record<string, any>>;
|
|
71
|
+
export declare function getAITools(client: MCPClient<any>, provider: "openai", options?: AIToolsOptions): Promise<Array<any>>;
|
|
72
|
+
export declare function getAITools(client: MCPClient<any>, provider: "openai-agents", options?: AIToolsOptions): Promise<Array<any>>;
|
|
73
|
+
export declare function getAITools(client: MCPClient<any>, provider: "anthropic", options?: AIToolsOptions): Promise<Array<any>>;
|
|
74
|
+
export declare function getAITools(client: MCPClient<any>, provider: "google", options?: AIToolsOptions): Promise<Array<any>>;
|
|
75
|
+
export declare function getAITools(client: MCPClient<any>, provider: "cloudflare", options?: AIToolsOptions): Promise<Record<string, any>>;
|
|
76
|
+
export declare function getAITools(client: MCPClient<any>, provider: "langchain", options?: AIToolsOptions): Promise<Array<any>>;
|
|
77
|
+
export declare function getAITools(client: MCPClient<any>, provider: "llamaindex", options?: AIToolsOptions): Promise<Array<any>>;
|
|
78
|
+
export declare function getAITools(client: MCPClient<any>, provider: "mastra", options?: AIToolsOptions): Promise<Record<string, any>>;
|
|
79
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index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E,SAAS,CAAC,GAAG,CAAC,EACtB,QAAQ,EAAE,WAAW,EACrB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAEvB,wBAAsB,UAAU,CAC9B,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAEvB,wBAAsB,UAAU,CAC9B,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,QAAQ,EAAE,YAAY,EACtB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;AAEhC,wBAAsB,UAAU,CAC9B,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,QAAQ,EAAE,WAAW,EACrB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAEvB,wBAAsB,UAAU,CAC9B,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,QAAQ,EAAE,YAAY,EACtB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAEvB,wBAAsB,UAAU,CAC9B,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangChain Integration
|
|
3
|
+
*
|
|
4
|
+
* Helper functions to convert MCP tools to LangChain DynamicStructuredTool format
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import type { MCPClient } from "../client.js";
|
|
8
|
+
import type { MCPTool } from "../protocol/messages.js";
|
|
9
|
+
import { type AIToolsOptions } from "./utils.js";
|
|
10
|
+
/**
|
|
11
|
+
* LangChain DynamicStructuredTool definition
|
|
12
|
+
* Compatible with @langchain/core/tools
|
|
13
|
+
*/
|
|
14
|
+
export interface LangChainTool {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
schema: z.ZodType<any>;
|
|
18
|
+
func: (...args: any[]) => Promise<string>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for converting MCP tools to LangChain format
|
|
22
|
+
*/
|
|
23
|
+
export interface LangChainToolsOptions extends AIToolsOptions {
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Convert a single MCP tool to LangChain DynamicStructuredTool format
|
|
27
|
+
*
|
|
28
|
+
* @param mcpTool - The MCP tool definition
|
|
29
|
+
* @param client - The MCP client instance (used for executing the tool)
|
|
30
|
+
* @param options - Optional configuration including provider tokens
|
|
31
|
+
* @returns LangChain compatible tool definition
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const langchainTool = convertMCPToolToLangChain(mcpTool, client);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function convertMCPToolToLangChain(mcpTool: MCPTool, client: MCPClient<any>, options?: LangChainToolsOptions): LangChainTool;
|
|
39
|
+
/**
|
|
40
|
+
* Convert all enabled MCP tools to LangChain DynamicStructuredTool format
|
|
41
|
+
*
|
|
42
|
+
* @param client - The MCP client instance (must be connected)
|
|
43
|
+
* @param options - Optional configuration including provider tokens
|
|
44
|
+
* @returns Array of LangChain compatible tool definitions
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* // Client-side usage
|
|
49
|
+
* const tools = convertMCPToolsToLangChain(mcpClient);
|
|
50
|
+
*
|
|
51
|
+
* // Server-side with provider tokens
|
|
52
|
+
* const tools = convertMCPToolsToLangChain(serverClient, {
|
|
53
|
+
* providerTokens: { github: 'ghp_...', gmail: 'ya29...' }
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function convertMCPToolsToLangChain(client: MCPClient<any>, options?: LangChainToolsOptions): LangChainTool[];
|
|
58
|
+
/**
|
|
59
|
+
* Get tools in a format compatible with LangChain
|
|
60
|
+
*
|
|
61
|
+
* Automatically connects the client if not already connected.
|
|
62
|
+
* Returns tool definitions that can be used with DynamicStructuredTool.
|
|
63
|
+
*
|
|
64
|
+
* @param client - The MCP client instance
|
|
65
|
+
* @param options - Optional configuration including provider tokens for server-side usage
|
|
66
|
+
* @returns Array of tools ready to use with LangChain
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* // Client-side usage
|
|
71
|
+
* import { createMCPClient, githubPlugin } from 'integrate-sdk';
|
|
72
|
+
* import { getLangChainTools } from 'integrate-sdk/integrations/langchain';
|
|
73
|
+
* import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
74
|
+
* import { ChatOpenAI } from '@langchain/openai';
|
|
75
|
+
* import { AgentExecutor, createOpenAIFunctionsAgent } from 'langchain/agents';
|
|
76
|
+
*
|
|
77
|
+
* const client = createMCPClient({
|
|
78
|
+
* plugins: [githubPlugin({ clientId: '...' })],
|
|
79
|
+
* });
|
|
80
|
+
*
|
|
81
|
+
* const toolConfigs = await getLangChainTools(client);
|
|
82
|
+
*
|
|
83
|
+
* // Create DynamicStructuredTools from configs
|
|
84
|
+
* const tools = toolConfigs.map(config =>
|
|
85
|
+
* new DynamicStructuredTool(config)
|
|
86
|
+
* );
|
|
87
|
+
*
|
|
88
|
+
* const model = new ChatOpenAI({ temperature: 0 });
|
|
89
|
+
* const agent = await createOpenAIFunctionsAgent({
|
|
90
|
+
* llm: model,
|
|
91
|
+
* tools
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* const executor = new AgentExecutor({ agent, tools });
|
|
95
|
+
* const result = await executor.invoke({
|
|
96
|
+
* input: "Create a GitHub issue"
|
|
97
|
+
* });
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* // Server-side usage with tokens from client
|
|
103
|
+
* import { createMCPServer, githubPlugin } from 'integrate-sdk/server';
|
|
104
|
+
* import { getLangChainTools } from 'integrate-sdk/integrations/langchain';
|
|
105
|
+
*
|
|
106
|
+
* const { client: serverClient } = createMCPServer({
|
|
107
|
+
* plugins: [githubPlugin({
|
|
108
|
+
* clientId: '...',
|
|
109
|
+
* clientSecret: '...'
|
|
110
|
+
* })],
|
|
111
|
+
* });
|
|
112
|
+
*
|
|
113
|
+
* // In your API route
|
|
114
|
+
* export async function POST(req: Request) {
|
|
115
|
+
* const providerTokens = JSON.parse(req.headers.get('x-integrate-tokens') || '{}');
|
|
116
|
+
* const toolConfigs = await getLangChainTools(serverClient, { providerTokens });
|
|
117
|
+
*
|
|
118
|
+
* // Create DynamicStructuredTools
|
|
119
|
+
* const tools = toolConfigs.map(config =>
|
|
120
|
+
* new DynamicStructuredTool(config)
|
|
121
|
+
* );
|
|
122
|
+
*
|
|
123
|
+
* const model = new ChatOpenAI({ temperature: 0 });
|
|
124
|
+
* const agent = await createOpenAIFunctionsAgent({
|
|
125
|
+
* llm: model,
|
|
126
|
+
* tools
|
|
127
|
+
* });
|
|
128
|
+
*
|
|
129
|
+
* const executor = new AgentExecutor({ agent, tools });
|
|
130
|
+
* const result = await executor.invoke({
|
|
131
|
+
* input: "Create a GitHub issue"
|
|
132
|
+
* });
|
|
133
|
+
*
|
|
134
|
+
* return Response.json(result);
|
|
135
|
+
* }
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export declare function getLangChainTools(client: MCPClient<any>, options?: LangChainToolsOptions): Promise<LangChainTool[]>;
|
|
139
|
+
//# sourceMappingURL=langchain.d.ts.map
|
|
@@ -0,0 +1 @@
|
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+
/**
|
|
2
|
+
* LlamaIndex Integration
|
|
3
|
+
*
|
|
4
|
+
* Helper functions to convert MCP tools to LlamaIndex tool format
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import type { MCPClient } from "../client.js";
|
|
8
|
+
import type { MCPTool } from "../protocol/messages.js";
|
|
9
|
+
import { type AIToolsOptions } from "./utils.js";
|
|
10
|
+
/**
|
|
11
|
+
* LlamaIndex tool definition
|
|
12
|
+
* Compatible with llamaindex package
|
|
13
|
+
*/
|
|
14
|
+
export interface LlamaIndexTool {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
parameters: z.ZodType<any>;
|
|
18
|
+
execute: (input: Record<string, unknown>) => Promise<string>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for converting MCP tools to LlamaIndex format
|
|
22
|
+
*/
|
|
23
|
+
export interface LlamaIndexToolsOptions extends AIToolsOptions {
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Convert a single MCP tool to LlamaIndex format
|
|
27
|
+
*
|
|
28
|
+
* @param mcpTool - The MCP tool definition
|
|
29
|
+
* @param client - The MCP client instance (used for executing the tool)
|
|
30
|
+
* @param options - Optional configuration including provider tokens
|
|
31
|
+
* @returns LlamaIndex compatible tool definition
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const llamaIndexTool = convertMCPToolToLlamaIndex(mcpTool, client);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function convertMCPToolToLlamaIndex(mcpTool: MCPTool, client: MCPClient<any>, options?: LlamaIndexToolsOptions): LlamaIndexTool;
|
|
39
|
+
/**
|
|
40
|
+
* Convert all enabled MCP tools to LlamaIndex format
|
|
41
|
+
*
|
|
42
|
+
* @param client - The MCP client instance (must be connected)
|
|
43
|
+
* @param options - Optional configuration including provider tokens
|
|
44
|
+
* @returns Array of LlamaIndex compatible tool definitions
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* // Client-side usage
|
|
49
|
+
* const tools = convertMCPToolsToLlamaIndex(mcpClient);
|
|
50
|
+
*
|
|
51
|
+
* // Server-side with provider tokens
|
|
52
|
+
* const tools = convertMCPToolsToLlamaIndex(serverClient, {
|
|
53
|
+
* providerTokens: { github: 'ghp_...', gmail: 'ya29...' }
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function convertMCPToolsToLlamaIndex(client: MCPClient<any>, options?: LlamaIndexToolsOptions): LlamaIndexTool[];
|
|
58
|
+
/**
|
|
59
|
+
* Get tools in a format compatible with LlamaIndex
|
|
60
|
+
*
|
|
61
|
+
* Automatically connects the client if not already connected.
|
|
62
|
+
* Returns tool configurations that can be used with LlamaIndex's tool system.
|
|
63
|
+
*
|
|
64
|
+
* @param client - The MCP client instance
|
|
65
|
+
* @param options - Optional configuration including provider tokens for server-side usage
|
|
66
|
+
* @returns Array of tools ready to use with LlamaIndex
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* // Client-side usage
|
|
71
|
+
* import { createMCPClient, githubPlugin } from 'integrate-sdk';
|
|
72
|
+
* import { getLlamaIndexTools } from 'integrate-sdk/integrations/llamaindex';
|
|
73
|
+
* import { OpenAIAgent, tool } from 'llamaindex';
|
|
74
|
+
*
|
|
75
|
+
* const client = createMCPClient({
|
|
76
|
+
* plugins: [githubPlugin({ clientId: '...' })],
|
|
77
|
+
* });
|
|
78
|
+
*
|
|
79
|
+
* const toolConfigs = await getLlamaIndexTools(client);
|
|
80
|
+
*
|
|
81
|
+
* // Create LlamaIndex tools
|
|
82
|
+
* const tools = toolConfigs.map(config =>
|
|
83
|
+
* tool(config)
|
|
84
|
+
* );
|
|
85
|
+
*
|
|
86
|
+
* const agent = new OpenAIAgent({ tools });
|
|
87
|
+
* const response = await agent.chat({
|
|
88
|
+
* message: "Create a GitHub issue"
|
|
89
|
+
* });
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* // Server-side usage with tokens from client
|
|
95
|
+
* import { createMCPServer, githubPlugin } from 'integrate-sdk/server';
|
|
96
|
+
* import { getLlamaIndexTools } from 'integrate-sdk/integrations/llamaindex';
|
|
97
|
+
*
|
|
98
|
+
* const { client: serverClient } = createMCPServer({
|
|
99
|
+
* plugins: [githubPlugin({
|
|
100
|
+
* clientId: '...',
|
|
101
|
+
* clientSecret: '...'
|
|
102
|
+
* })],
|
|
103
|
+
* });
|
|
104
|
+
*
|
|
105
|
+
* // In your API route
|
|
106
|
+
* export async function POST(req: Request) {
|
|
107
|
+
* const providerTokens = JSON.parse(req.headers.get('x-integrate-tokens') || '{}');
|
|
108
|
+
* const toolConfigs = await getLlamaIndexTools(serverClient, { providerTokens });
|
|
109
|
+
*
|
|
110
|
+
* // Create LlamaIndex tools
|
|
111
|
+
* const tools = toolConfigs.map(config =>
|
|
112
|
+
* tool(config)
|
|
113
|
+
* );
|
|
114
|
+
*
|
|
115
|
+
* const agent = new OpenAIAgent({ tools });
|
|
116
|
+
* const response = await agent.chat({
|
|
117
|
+
* message: "Create a GitHub issue"
|
|
118
|
+
* });
|
|
119
|
+
*
|
|
120
|
+
* return Response.json(response);
|
|
121
|
+
* }
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
export declare function getLlamaIndexTools(client: MCPClient<any>, options?: LlamaIndexToolsOptions): Promise<LlamaIndexTool[]>;
|
|
125
|
+
//# sourceMappingURL=llamaindex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llamaindex.d.ts","sourceRoot":"","sources":["../../../src/integrations/llamaindex.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM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