integrate-sdk 0.8.36 → 0.8.39
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 +371 -71
- package/dist/adapters/base-handler.js +561 -0
- package/dist/adapters/index.js +371 -71
- package/dist/adapters/nextjs.js +371 -71
- package/dist/adapters/node.js +371 -71
- package/dist/adapters/svelte-kit.js +371 -71
- package/dist/adapters/tanstack-start.js +371 -71
- package/dist/ai/anthropic.d.ts +3 -0
- package/dist/ai/anthropic.d.ts.map +1 -1
- package/dist/ai/anthropic.js +255 -2
- package/dist/ai/cloudflare.d.ts +158 -0
- package/dist/ai/cloudflare.d.ts.map +1 -0
- package/dist/ai/cloudflare.js +4249 -0
- package/dist/ai/google.d.ts +3 -0
- package/dist/ai/google.d.ts.map +1 -1
- package/dist/ai/google.js +256 -2
- package/dist/ai/index.d.ts +1 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +351 -7
- package/dist/ai/langchain.d.ts +139 -0
- package/dist/ai/langchain.d.ts.map +1 -0
- package/dist/ai/langchain.js +4237 -0
- package/dist/ai/llamaindex.d.ts +125 -0
- package/dist/ai/llamaindex.d.ts.map +1 -0
- package/dist/ai/llamaindex.js +4236 -0
- package/dist/ai/mastra.d.ts +138 -0
- package/dist/ai/mastra.d.ts.map +1 -0
- package/dist/ai/mastra.js +4240 -0
- package/dist/ai/openai.d.ts +3 -0
- package/dist/ai/openai.d.ts.map +1 -1
- package/dist/ai/openai.js +257 -2
- package/dist/ai/trigger-tools.d.ts +206 -0
- package/dist/ai/trigger-tools.d.ts.map +1 -0
- package/dist/ai/trigger-tools.js +4198 -0
- package/dist/ai/vercel-ai.d.ts.map +1 -1
- package/dist/ai/vercel-ai.js +217 -0
- package/dist/index.js +359 -59
- package/dist/oauth.js +371 -71
- package/dist/server.js +372 -71
- package/dist/src/ai/anthropic.d.ts +3 -0
- package/dist/src/ai/anthropic.d.ts.map +1 -1
- package/dist/src/ai/cloudflare.d.ts +158 -0
- package/dist/src/ai/cloudflare.d.ts.map +1 -0
- package/dist/src/ai/google.d.ts +3 -0
- package/dist/src/ai/google.d.ts.map +1 -1
- package/dist/src/ai/index.d.ts +1 -0
- package/dist/src/ai/index.d.ts.map +1 -1
- package/dist/src/ai/langchain.d.ts +139 -0
- package/dist/src/ai/langchain.d.ts.map +1 -0
- package/dist/src/ai/llamaindex.d.ts +125 -0
- package/dist/src/ai/llamaindex.d.ts.map +1 -0
- package/dist/src/ai/mastra.d.ts +138 -0
- package/dist/src/ai/mastra.d.ts.map +1 -0
- package/dist/src/ai/openai.d.ts +3 -0
- package/dist/src/ai/openai.d.ts.map +1 -1
- package/dist/src/ai/trigger-tools.d.ts +206 -0
- package/dist/src/ai/trigger-tools.d.ts.map +1 -0
- package/dist/src/ai/vercel-ai.d.ts.map +1 -1
- package/dist/src/integrations/vercel-ai.d.ts +127 -0
- package/dist/src/integrations/vercel-ai.d.ts.map +1 -0
- package/dist/src/plugins/generic.d.ts +99 -0
- package/dist/src/plugins/generic.d.ts.map +1 -0
- package/dist/src/plugins/github-client.d.ts +320 -0
- package/dist/src/plugins/github-client.d.ts.map +1 -0
- package/dist/src/plugins/github.d.ts +89 -0
- package/dist/src/plugins/github.d.ts.map +1 -0
- package/dist/src/plugins/gmail-client.d.ts +106 -0
- package/dist/src/plugins/gmail-client.d.ts.map +1 -0
- package/dist/src/plugins/gmail.d.ts +87 -0
- package/dist/src/plugins/gmail.d.ts.map +1 -0
- package/dist/src/plugins/server-client.d.ts +18 -0
- package/dist/src/plugins/server-client.d.ts.map +1 -0
- package/dist/src/plugins/types.d.ts +70 -0
- package/dist/src/plugins/types.d.ts.map +1 -0
- package/dist/src/server.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -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, githubIntegration } from 'integrate-sdk';
|
|
100
|
+
* import { getCloudflareTools, executeCloudflareToolCall } from 'integrate-sdk/ai/cloudflare';
|
|
101
|
+
*
|
|
102
|
+
* export default {
|
|
103
|
+
* async fetch(request: Request, env: Env): Promise<Response> {
|
|
104
|
+
* const client = createMCPClient({
|
|
105
|
+
* integrations: [githubIntegration({ 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, githubIntegration } from 'integrate-sdk/server';
|
|
125
|
+
* import { getCloudflareTools, executeCloudflareToolCall } from 'integrate-sdk/ai/cloudflare';
|
|
126
|
+
*
|
|
127
|
+
* const { client: serverClient } = createMCPServer({
|
|
128
|
+
* integrations: [githubIntegration({
|
|
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/ai/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,EAAkE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjH;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ,CAAC;YACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE;gBACzB,IAAI,EAAE,MAAM,CAAC;gBACb,WAAW,CAAC,EAAE,MAAM,CAAC;aACtB,CAAC,CAAC;YACH,QAAQ,EAAE,MAAM,EAAE,CAAC;SACpB,CAAC;KACH,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,cAAc;CAAI;AAElE;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,EACvB,QAAQ,CAAC,EAAE,sBAAsB,GAChC,cAAc,CAahB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAShC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,QAAQ,EAAE;IACR,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;CAC7C,EACD,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,MAAM,CAAC,CAOjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAezC"}
|
package/dist/src/ai/google.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Helper functions to convert MCP tools to Google GenAI format
|
|
5
5
|
*/
|
|
6
6
|
import type { MCPClient } from "../client.js";
|
|
7
|
+
import type { MCPContext } from "../config/types.js";
|
|
7
8
|
import { type AIToolsOptions } from "./utils.js";
|
|
8
9
|
import type { Schema, FunctionDeclaration, FunctionCall, Type } from "@google/genai";
|
|
9
10
|
export type GoogleTool = FunctionDeclaration;
|
|
@@ -13,6 +14,8 @@ export type { Schema, Type };
|
|
|
13
14
|
* Options for converting MCP tools to Google GenAI format
|
|
14
15
|
*/
|
|
15
16
|
export interface GoogleToolsOptions extends AIToolsOptions {
|
|
17
|
+
/** User context for multi-tenant token storage */
|
|
18
|
+
context?: MCPContext;
|
|
16
19
|
}
|
|
17
20
|
/**
|
|
18
21
|
* Execute multiple function calls from Google GenAI response
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../../src/ai/google.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAkE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../../src/ai/google.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAkE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAKjH,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,YAAY,EACZ,IAAI,EACL,MAAM,eAAe,CAAC;AAGvB,MAAM,MAAM,UAAU,GAAG,mBAAmB,CAAC;AAC7C,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAC9C,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAuB7B;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,kDAAkD;IAClD,OAAO,CAAC,EAAE,UAAU,CAAC;CACtB;AAsGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,aAAa,EAAE,kBAAkB,EAAE,GAAG,SAAS,GAAG,IAAI,EACtD,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,MAAM,EAAE,CAAC,CA2CnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,UAAU,EAAE,CAAC,CAwCvB"}
|
package/dist/src/ai/index.d.ts
CHANGED
|
@@ -7,5 +7,6 @@ export { getVercelAITools, type VercelAITool, type VercelAIToolsOptions } from "
|
|
|
7
7
|
export { getOpenAITools, handleOpenAIResponse, type OpenAITool, type OpenAIToolsOptions } from "./openai.js";
|
|
8
8
|
export { getAnthropicTools, handleAnthropicMessage, type AnthropicTool, type AnthropicToolsOptions, type AnthropicToolUseBlock, type AnthropicToolResultBlock } from "./anthropic.js";
|
|
9
9
|
export { getGoogleTools, executeGoogleFunctionCalls, type GoogleTool, type GoogleFunctionCall, type GoogleToolsOptions } from "./google.js";
|
|
10
|
+
export { createTriggerTools, type TriggerToolsConfig } from "./trigger-tools.js";
|
|
10
11
|
export type { AIToolsOptions } from "./utils.js";
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ai/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,gBAAgB,EAChB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC9B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,cAAc,EACd,0BAA0B,EAC1B,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ai/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,gBAAgB,EAChB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC9B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,cAAc,EACd,0BAA0B,EAC1B,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,kBAAkB,EAClB,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,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, githubIntegration } from 'integrate-sdk';
|
|
72
|
+
* import { getLangChainTools } from 'integrate-sdk/ai/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
|
+
* integrations: [githubIntegration({ 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, githubIntegration } from 'integrate-sdk/server';
|
|
104
|
+
* import { getLangChainTools } from 'integrate-sdk/ai/langchain';
|
|
105
|
+
*
|
|
106
|
+
* const { client: serverClient } = createMCPServer({
|
|
107
|
+
* integrations: [githubIntegration({
|
|
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/ai/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,EAKL,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;CAAI;AAEjE;;;;;;;;;;;;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,CAe1B"}
|
|
@@ -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, githubIntegration } from 'integrate-sdk';
|
|
72
|
+
* import { getLlamaIndexTools } from 'integrate-sdk/ai/llamaindex';
|
|
73
|
+
* import { OpenAIAgent, tool } from 'llamaindex';
|
|
74
|
+
*
|
|
75
|
+
* const client = createMCPClient({
|
|
76
|
+
* integrations: [githubIntegration({ 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, githubIntegration } from 'integrate-sdk/server';
|
|
96
|
+
* import { getLlamaIndexTools } from 'integrate-sdk/ai/llamaindex';
|
|
97
|
+
*
|
|
98
|
+
* const { client: serverClient } = createMCPServer({
|
|
99
|
+
* integrations: [githubIntegration({
|
|
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/ai/llamaindex.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,EAKL,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3B,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9D;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,cAAc;CAAI;AAElE;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,cAAc,CAUhB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,cAAc,EAAE,CAGlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,cAAc,EAAE,CAAC,CAe3B"}
|
|
@@ -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, githubIntegration } from 'integrate-sdk';
|
|
76
|
+
* import { getMastraTools } from 'integrate-sdk/ai/mastra';
|
|
77
|
+
* import { createTool, Agent } from '@mastra/core';
|
|
78
|
+
*
|
|
79
|
+
* const client = createMCPClient({
|
|
80
|
+
* integrations: [githubIntegration({ 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, githubIntegration } from 'integrate-sdk/server';
|
|
105
|
+
* import { getMastraTools } from 'integrate-sdk/ai/mastra';
|
|
106
|
+
*
|
|
107
|
+
* const { client: serverClient } = createMCPServer({
|
|
108
|
+
* integrations: [githubIntegration({
|
|
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/ai/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,EAKL,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;CAAI;AAE9D;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAerC"}
|
package/dist/src/ai/openai.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Helper functions to convert MCP tools to OpenAI Responses API format
|
|
5
5
|
*/
|
|
6
6
|
import type { MCPClient } from "../client.js";
|
|
7
|
+
import type { MCPContext } from "../config/types.js";
|
|
7
8
|
import { type AIToolsOptions } from "./utils.js";
|
|
8
9
|
import type { OpenAI } from "openai";
|
|
9
10
|
/**
|
|
@@ -28,6 +29,8 @@ export interface OpenAIToolsOptions extends AIToolsOptions {
|
|
|
28
29
|
* @default false
|
|
29
30
|
*/
|
|
30
31
|
strict?: boolean;
|
|
32
|
+
/** User context for multi-tenant token storage */
|
|
33
|
+
context?: MCPContext;
|
|
31
34
|
}
|
|
32
35
|
/**
|
|
33
36
|
* Get tools in a format compatible with OpenAI Responses API
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/ai/openai.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAkE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/ai/openai.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAkE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE;QACV,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,GAAG,IAAI,CAAC;IACT,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kDAAkD;IAClD,OAAO,CAAC,EAAE,UAAU,CAAC;CACtB;AAiCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,UAAU,EAAE,CAAC,CAuCvB;AAsHD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,QAAQ,EAAE;IAAE,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAA,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC,CAAA;CAAE,EAChE,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,kBAAkB,EAAE,GAAG;IAAE,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAA,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAyB3H"}
|