integrate-sdk 0.8.39 → 0.8.41-dev.0

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.
Files changed (57) hide show
  1. package/dist/adapters/auto-routes.js +1471 -60
  2. package/dist/adapters/index.js +1471 -60
  3. package/dist/adapters/nextjs.js +1471 -60
  4. package/dist/adapters/node.js +1471 -60
  5. package/dist/adapters/svelte-kit.js +1471 -60
  6. package/dist/adapters/tanstack-start.js +1471 -60
  7. package/dist/ai/anthropic.d.ts.map +1 -1
  8. package/dist/ai/anthropic.js +1240 -21
  9. package/dist/ai/google.d.ts.map +1 -1
  10. package/dist/ai/google.js +1292 -18
  11. package/dist/ai/index.js +1300 -60
  12. package/dist/ai/openai.d.ts.map +1 -1
  13. package/dist/ai/openai.js +1240 -21
  14. package/dist/index.js +1471 -60
  15. package/dist/oauth.js +1471 -60
  16. package/dist/server.js +1471 -60
  17. package/dist/src/ai/anthropic.d.ts.map +1 -1
  18. package/dist/src/ai/google.d.ts.map +1 -1
  19. package/dist/src/ai/openai.d.ts.map +1 -1
  20. package/package.json +6 -5
  21. package/dist/adapters/base-handler.js +0 -561
  22. package/dist/ai/cloudflare.d.ts +0 -158
  23. package/dist/ai/cloudflare.d.ts.map +0 -1
  24. package/dist/ai/cloudflare.js +0 -4249
  25. package/dist/ai/langchain.d.ts +0 -139
  26. package/dist/ai/langchain.d.ts.map +0 -1
  27. package/dist/ai/langchain.js +0 -4237
  28. package/dist/ai/llamaindex.d.ts +0 -125
  29. package/dist/ai/llamaindex.d.ts.map +0 -1
  30. package/dist/ai/llamaindex.js +0 -4236
  31. package/dist/ai/mastra.d.ts +0 -138
  32. package/dist/ai/mastra.d.ts.map +0 -1
  33. package/dist/ai/mastra.js +0 -4240
  34. package/dist/src/ai/cloudflare.d.ts +0 -158
  35. package/dist/src/ai/cloudflare.d.ts.map +0 -1
  36. package/dist/src/ai/langchain.d.ts +0 -139
  37. package/dist/src/ai/langchain.d.ts.map +0 -1
  38. package/dist/src/ai/llamaindex.d.ts +0 -125
  39. package/dist/src/ai/llamaindex.d.ts.map +0 -1
  40. package/dist/src/ai/mastra.d.ts +0 -138
  41. package/dist/src/ai/mastra.d.ts.map +0 -1
  42. package/dist/src/integrations/vercel-ai.d.ts +0 -127
  43. package/dist/src/integrations/vercel-ai.d.ts.map +0 -1
  44. package/dist/src/plugins/generic.d.ts +0 -99
  45. package/dist/src/plugins/generic.d.ts.map +0 -1
  46. package/dist/src/plugins/github-client.d.ts +0 -320
  47. package/dist/src/plugins/github-client.d.ts.map +0 -1
  48. package/dist/src/plugins/github.d.ts +0 -89
  49. package/dist/src/plugins/github.d.ts.map +0 -1
  50. package/dist/src/plugins/gmail-client.d.ts +0 -106
  51. package/dist/src/plugins/gmail-client.d.ts.map +0 -1
  52. package/dist/src/plugins/gmail.d.ts +0 -87
  53. package/dist/src/plugins/gmail.d.ts.map +0 -1
  54. package/dist/src/plugins/server-client.d.ts +0 -18
  55. package/dist/src/plugins/server-client.d.ts.map +0 -1
  56. package/dist/src/plugins/types.d.ts +0 -70
  57. package/dist/src/plugins/types.d.ts.map +0 -1
@@ -1,158 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,139 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,125 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,138 +0,0 @@
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
@@ -1 +0,0 @@
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"}