integrate-sdk 0.6.5 → 0.6.7
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/auto-routes.js +268 -0
- package/dist/adapters/base-handler.js +144 -0
- package/dist/adapters/nextjs-oauth-redirect.js +152 -0
- package/dist/adapters/nextjs.js +405 -0
- package/dist/adapters/node.js +280 -0
- package/dist/adapters/solid-start.js +27 -0
- package/dist/adapters/svelte-kit.js +34 -0
- package/dist/adapters/tanstack-start.js +26 -0
- package/dist/index.js +203 -96
- package/dist/src/adapters/node.d.ts +48 -0
- package/dist/src/adapters/node.d.ts.map +1 -0
- package/dist/src/adapters/solid-start.d.ts +54 -0
- package/dist/src/adapters/solid-start.d.ts.map +1 -0
- package/dist/src/adapters/svelte-kit.d.ts +82 -0
- package/dist/src/adapters/svelte-kit.d.ts.map +1 -0
- package/dist/src/adapters/tanstack-start.d.ts +28 -144
- package/dist/src/adapters/tanstack-start.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -1
- package/dist/src/index.d.ts.map +1 -1
- 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/integrations.ts +9 -0
- package/package.json +104 -9
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
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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E,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.d.ts","sourceRoot":"","sources":["../../../src/integrations/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAa3B;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,WAAW,GACX,QAAQ,GACR,eAAe,GACf,WAAW,GACX,QAAQ,GACR,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,QAAQ,CAAC;AAEb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,QAAQ,EAAE,WAAW,EACrB,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,QAAQ,EAClB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,KAAK,CAAC,GAA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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 @@
|
|
|
1
|
+
{"version":3,"file":"langchain.d.ts","sourceRoot":"","sources":["../../../src/integrations/langchain.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACvB,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,cAAc;CAAG;AAEhE;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,aAAa,CAYf;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,aAAa,EAAE,CAGjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,aAAa,EAAE,CAAC,CAG1B"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
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=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C,CAG3B"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mastra AI SDK Integration
|
|
3
|
+
*
|
|
4
|
+
* Helper functions to convert MCP tools to Mastra AI SDK 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
|
+
* Mastra tool definition
|
|
12
|
+
* Compatible with @mastra/core
|
|
13
|
+
*/
|
|
14
|
+
export interface MastraTool {
|
|
15
|
+
id: string;
|
|
16
|
+
description: string;
|
|
17
|
+
inputSchema?: z.ZodType<any>;
|
|
18
|
+
outputSchema?: z.ZodType<any>;
|
|
19
|
+
execute: (params: {
|
|
20
|
+
context: Record<string, unknown>;
|
|
21
|
+
}) => Promise<any>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Options for converting MCP tools to Mastra format
|
|
25
|
+
*/
|
|
26
|
+
export interface MastraToolsOptions extends AIToolsOptions {
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Convert a single MCP tool to Mastra AI SDK format
|
|
30
|
+
*
|
|
31
|
+
* @param mcpTool - The MCP tool definition
|
|
32
|
+
* @param client - The MCP client instance (used for executing the tool)
|
|
33
|
+
* @param options - Optional configuration including provider tokens
|
|
34
|
+
* @returns Mastra compatible tool definition
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const mastraTool = convertMCPToolToMastra(mcpTool, client);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function convertMCPToolToMastra(mcpTool: MCPTool, client: MCPClient<any>, options?: MastraToolsOptions): MastraTool;
|
|
42
|
+
/**
|
|
43
|
+
* Convert all enabled MCP tools to Mastra AI SDK format
|
|
44
|
+
* Returns a dictionary keyed by tool ID
|
|
45
|
+
*
|
|
46
|
+
* @param client - The MCP client instance (must be connected)
|
|
47
|
+
* @param options - Optional configuration including provider tokens
|
|
48
|
+
* @returns Dictionary of Mastra compatible tool definitions
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* // Client-side usage
|
|
53
|
+
* const tools = convertMCPToolsToMastra(mcpClient);
|
|
54
|
+
*
|
|
55
|
+
* // Server-side with provider tokens
|
|
56
|
+
* const tools = convertMCPToolsToMastra(serverClient, {
|
|
57
|
+
* providerTokens: { github: 'ghp_...', gmail: 'ya29...' }
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function convertMCPToolsToMastra(client: MCPClient<any>, options?: MastraToolsOptions): Record<string, MastraTool>;
|
|
62
|
+
/**
|
|
63
|
+
* Get tools in a format compatible with Mastra AI SDK
|
|
64
|
+
*
|
|
65
|
+
* Automatically connects the client if not already connected.
|
|
66
|
+
* Returns tool configurations that can be used with Mastra's tool system.
|
|
67
|
+
*
|
|
68
|
+
* @param client - The MCP client instance
|
|
69
|
+
* @param options - Optional configuration including provider tokens for server-side usage
|
|
70
|
+
* @returns Dictionary of tools ready to use with Mastra AI SDK
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* // Client-side usage
|
|
75
|
+
* import { createMCPClient, githubPlugin } from 'integrate-sdk';
|
|
76
|
+
* import { getMastraTools } from 'integrate-sdk/integrations/mastra';
|
|
77
|
+
* import { createTool, Agent } from '@mastra/core';
|
|
78
|
+
*
|
|
79
|
+
* const client = createMCPClient({
|
|
80
|
+
* plugins: [githubPlugin({ clientId: '...' })],
|
|
81
|
+
* });
|
|
82
|
+
*
|
|
83
|
+
* const toolConfigs = await getMastraTools(client);
|
|
84
|
+
*
|
|
85
|
+
* // Create Mastra tools
|
|
86
|
+
* const tools = Object.fromEntries(
|
|
87
|
+
* Object.entries(toolConfigs).map(([id, config]) => [
|
|
88
|
+
* id,
|
|
89
|
+
* createTool(config)
|
|
90
|
+
* ])
|
|
91
|
+
* );
|
|
92
|
+
*
|
|
93
|
+
* const agent = new Agent({
|
|
94
|
+
* tools,
|
|
95
|
+
* model: { provider: 'openai', name: 'gpt-4' }
|
|
96
|
+
* });
|
|
97
|
+
*
|
|
98
|
+
* const result = await agent.generate('Create a GitHub issue');
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* // Server-side usage with tokens from client
|
|
104
|
+
* import { createMCPServer, githubPlugin } from 'integrate-sdk/server';
|
|
105
|
+
* import { getMastraTools } from 'integrate-sdk/integrations/mastra';
|
|
106
|
+
*
|
|
107
|
+
* const { client: serverClient } = createMCPServer({
|
|
108
|
+
* plugins: [githubPlugin({
|
|
109
|
+
* clientId: '...',
|
|
110
|
+
* clientSecret: '...'
|
|
111
|
+
* })],
|
|
112
|
+
* });
|
|
113
|
+
*
|
|
114
|
+
* // In your API route
|
|
115
|
+
* export async function POST(req: Request) {
|
|
116
|
+
* const providerTokens = JSON.parse(req.headers.get('x-integrate-tokens') || '{}');
|
|
117
|
+
* const toolConfigs = await getMastraTools(serverClient, { providerTokens });
|
|
118
|
+
*
|
|
119
|
+
* // Create Mastra tools
|
|
120
|
+
* const tools = Object.fromEntries(
|
|
121
|
+
* Object.entries(toolConfigs).map(([id, config]) => [
|
|
122
|
+
* id,
|
|
123
|
+
* createTool(config)
|
|
124
|
+
* ])
|
|
125
|
+
* );
|
|
126
|
+
*
|
|
127
|
+
* const agent = new Agent({
|
|
128
|
+
* tools,
|
|
129
|
+
* model: { provider: 'openai', name: 'gpt-4' }
|
|
130
|
+
* });
|
|
131
|
+
*
|
|
132
|
+
* const result = await agent.generate('Create a GitHub issue');
|
|
133
|
+
* return Response.json(result);
|
|
134
|
+
* }
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
export declare function getMastraTools(client: MCPClient<any>, options?: MastraToolsOptions): Promise<Record<string, MastraTool>>;
|
|
138
|
+
//# sourceMappingURL=mastra.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mastra.d.ts","sourceRoot":"","sources":["../../../src/integrations/mastra.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7B,YAAY,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC9B,OAAO,EAAE,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACzE;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,cAAc;CAAG;AAE7D;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,UAAU,CAUZ;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAS5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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