integrate-sdk 0.6.6 → 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.
@@ -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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AAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAEvB,wBAAsB,UAAU,CAC9B,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,QAAQ,EAAE,YAAY,EACtB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;AAEhC,wBAAsB,UAAU,CAC9B,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,QAAQ,EAAE,WAAW,EACrB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAEvB,wBAAsB,UAAU,CAC9B,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,QAAQ,EAAE,YAAY,EACtB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAEvB,wBAAsB,UAAU,CAC9B,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC"}
@@ -0,0 +1,139 @@
1
+ /**
2
+ * LangChain Integration
3
+ *
4
+ * Helper functions to convert MCP tools to LangChain DynamicStructuredTool format
5
+ */
6
+ import { z } from "zod";
7
+ import type { MCPClient } from "../client.js";
8
+ import type { MCPTool } from "../protocol/messages.js";
9
+ import { type AIToolsOptions } from "./utils.js";
10
+ /**
11
+ * LangChain DynamicStructuredTool definition
12
+ * Compatible with @langchain/core/tools
13
+ */
14
+ export interface LangChainTool {
15
+ name: string;
16
+ description: string;
17
+ schema: z.ZodType<any>;
18
+ func: (...args: any[]) => Promise<string>;
19
+ }
20
+ /**
21
+ * Options for converting MCP tools to LangChain format
22
+ */
23
+ export interface LangChainToolsOptions extends AIToolsOptions {
24
+ }
25
+ /**
26
+ * Convert a single MCP tool to LangChain DynamicStructuredTool format
27
+ *
28
+ * @param mcpTool - The MCP tool definition
29
+ * @param client - The MCP client instance (used for executing the tool)
30
+ * @param options - Optional configuration including provider tokens
31
+ * @returns LangChain compatible tool definition
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const langchainTool = convertMCPToolToLangChain(mcpTool, client);
36
+ * ```
37
+ */
38
+ export declare function convertMCPToolToLangChain(mcpTool: MCPTool, client: MCPClient<any>, options?: LangChainToolsOptions): LangChainTool;
39
+ /**
40
+ * Convert all enabled MCP tools to LangChain DynamicStructuredTool format
41
+ *
42
+ * @param client - The MCP client instance (must be connected)
43
+ * @param options - Optional configuration including provider tokens
44
+ * @returns Array of LangChain compatible tool definitions
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * // Client-side usage
49
+ * const tools = convertMCPToolsToLangChain(mcpClient);
50
+ *
51
+ * // Server-side with provider tokens
52
+ * const tools = convertMCPToolsToLangChain(serverClient, {
53
+ * providerTokens: { github: 'ghp_...', gmail: 'ya29...' }
54
+ * });
55
+ * ```
56
+ */
57
+ export declare function convertMCPToolsToLangChain(client: MCPClient<any>, options?: LangChainToolsOptions): LangChainTool[];
58
+ /**
59
+ * Get tools in a format compatible with LangChain
60
+ *
61
+ * Automatically connects the client if not already connected.
62
+ * Returns tool definitions that can be used with DynamicStructuredTool.
63
+ *
64
+ * @param client - The MCP client instance
65
+ * @param options - Optional configuration including provider tokens for server-side usage
66
+ * @returns Array of tools ready to use with LangChain
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * // Client-side usage
71
+ * import { createMCPClient, githubPlugin } from 'integrate-sdk';
72
+ * import { getLangChainTools } from 'integrate-sdk/integrations/langchain';
73
+ * import { DynamicStructuredTool } from '@langchain/core/tools';
74
+ * import { ChatOpenAI } from '@langchain/openai';
75
+ * import { AgentExecutor, createOpenAIFunctionsAgent } from 'langchain/agents';
76
+ *
77
+ * const client = createMCPClient({
78
+ * plugins: [githubPlugin({ clientId: '...' })],
79
+ * });
80
+ *
81
+ * const toolConfigs = await getLangChainTools(client);
82
+ *
83
+ * // Create DynamicStructuredTools from configs
84
+ * const tools = toolConfigs.map(config =>
85
+ * new DynamicStructuredTool(config)
86
+ * );
87
+ *
88
+ * const model = new ChatOpenAI({ temperature: 0 });
89
+ * const agent = await createOpenAIFunctionsAgent({
90
+ * llm: model,
91
+ * tools
92
+ * });
93
+ *
94
+ * const executor = new AgentExecutor({ agent, tools });
95
+ * const result = await executor.invoke({
96
+ * input: "Create a GitHub issue"
97
+ * });
98
+ * ```
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * // Server-side usage with tokens from client
103
+ * import { createMCPServer, githubPlugin } from 'integrate-sdk/server';
104
+ * import { getLangChainTools } from 'integrate-sdk/integrations/langchain';
105
+ *
106
+ * const { client: serverClient } = createMCPServer({
107
+ * plugins: [githubPlugin({
108
+ * clientId: '...',
109
+ * clientSecret: '...'
110
+ * })],
111
+ * });
112
+ *
113
+ * // In your API route
114
+ * export async function POST(req: Request) {
115
+ * const providerTokens = JSON.parse(req.headers.get('x-integrate-tokens') || '{}');
116
+ * const toolConfigs = await getLangChainTools(serverClient, { providerTokens });
117
+ *
118
+ * // Create DynamicStructuredTools
119
+ * const tools = toolConfigs.map(config =>
120
+ * new DynamicStructuredTool(config)
121
+ * );
122
+ *
123
+ * const model = new ChatOpenAI({ temperature: 0 });
124
+ * const agent = await createOpenAIFunctionsAgent({
125
+ * llm: model,
126
+ * tools
127
+ * });
128
+ *
129
+ * const executor = new AgentExecutor({ agent, tools });
130
+ * const result = await executor.invoke({
131
+ * input: "Create a GitHub issue"
132
+ * });
133
+ *
134
+ * return Response.json(result);
135
+ * }
136
+ * ```
137
+ */
138
+ export declare function getLangChainTools(client: MCPClient<any>, options?: LangChainToolsOptions): Promise<LangChainTool[]>;
139
+ //# sourceMappingURL=langchain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langchain.d.ts","sourceRoot":"","sources":["../../../src/integrations/langchain.ts"],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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
+ //#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AG3B"}
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAGrC"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * OpenAI Agents Integration
3
+ *
4
+ * Helper functions to convert MCP tools to @openai/agents 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
+ * OpenAI Agents tool definition
12
+ * Compatible with @openai/agents package
13
+ */
14
+ export interface OpenAIAgentsTool {
15
+ name: string;
16
+ description: string;
17
+ parameters: z.ZodType<any>;
18
+ execute: (args: any) => Promise<any>;
19
+ }
20
+ /**
21
+ * Options for converting MCP tools to OpenAI Agents format
22
+ */
23
+ export interface OpenAIAgentsToolsOptions extends AIToolsOptions {
24
+ }
25
+ /**
26
+ * Convert a single MCP tool to OpenAI Agents 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 OpenAI Agents compatible tool definition
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const agentTool = convertMCPToolToOpenAIAgents(mcpTool, client);
36
+ * ```
37
+ */
38
+ export declare function convertMCPToolToOpenAIAgents(mcpTool: MCPTool, client: MCPClient<any>, options?: OpenAIAgentsToolsOptions): OpenAIAgentsTool;
39
+ /**
40
+ * Convert all enabled MCP tools to OpenAI Agents format
41
+ *
42
+ * @param client - The MCP client instance (must be connected)
43
+ * @param options - Optional configuration including provider tokens
44
+ * @returns Array of OpenAI Agents compatible tool definitions
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * // Client-side usage
49
+ * const tools = convertMCPToolsToOpenAIAgents(mcpClient);
50
+ *
51
+ * // Server-side with provider tokens
52
+ * const tools = convertMCPToolsToOpenAIAgents(serverClient, {
53
+ * providerTokens: { github: 'ghp_...', gmail: 'ya29...' }
54
+ * });
55
+ * ```
56
+ */
57
+ export declare function convertMCPToolsToOpenAIAgents(client: MCPClient<any>, options?: OpenAIAgentsToolsOptions): OpenAIAgentsTool[];
58
+ /**
59
+ * Get tools in a format compatible with @openai/agents
60
+ *
61
+ * Automatically connects the client if not already connected.
62
+ *
63
+ * @param client - The MCP client instance
64
+ * @param options - Optional configuration including provider tokens for server-side usage
65
+ * @returns Array of tools ready to use with @openai/agents
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * // Client-side usage
70
+ * import { createMCPClient, githubPlugin } from 'integrate-sdk';
71
+ * import { getOpenAIAgentsTools } from 'integrate-sdk/integrations/openai-agents';
72
+ * import { Agent } from '@openai/agents';
73
+ *
74
+ * const client = createMCPClient({
75
+ * plugins: [githubPlugin({ clientId: '...' })],
76
+ * });
77
+ *
78
+ * const tools = await getOpenAIAgentsTools(client);
79
+ *
80
+ * const agent = new Agent({
81
+ * model: 'gpt-4o',
82
+ * tools,
83
+ * });
84
+ *
85
+ * const result = await agent.run('Create a GitHub issue');
86
+ * ```
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * // Server-side usage with tokens from client
91
+ * import { createMCPServer, githubPlugin } from 'integrate-sdk/server';
92
+ * import { getOpenAIAgentsTools } from 'integrate-sdk/integrations/openai-agents';
93
+ *
94
+ * const { client: serverClient } = createMCPServer({
95
+ * plugins: [githubPlugin({
96
+ * clientId: '...',
97
+ * clientSecret: '...'
98
+ * })],
99
+ * });
100
+ *
101
+ * // In your API route
102
+ * export async function POST(req: Request) {
103
+ * const providerTokens = JSON.parse(req.headers.get('x-integrate-tokens') || '{}');
104
+ * const tools = await getOpenAIAgentsTools(serverClient, { providerTokens });
105
+ *
106
+ * const agent = new Agent({
107
+ * model: 'gpt-4o',
108
+ * tools,
109
+ * });
110
+ *
111
+ * const result = await agent.run('Create a GitHub issue');
112
+ * return Response.json({ result });
113
+ * }
114
+ * ```
115
+ */
116
+ export declare function getOpenAIAgentsTools(client: MCPClient<any>, options?: OpenAIAgentsToolsOptions): Promise<OpenAIAgentsTool[]>;
117
+ //# sourceMappingURL=openai-agents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-agents.d.ts","sourceRoot":"","sources":["../../../src/integrations/openai-agents.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,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3B,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,cAAc;CAAG;AAEnE;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,wBAAwB,GACjC,gBAAgB,CASlB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,wBAAwB,GACjC,gBAAgB,EAAE,CAGpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAG7B"}