integrate-sdk 0.7.53 → 0.7.56

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 (71) hide show
  1. package/dist/ai/anthropic.d.ts +16 -117
  2. package/dist/ai/anthropic.d.ts.map +1 -1
  3. package/dist/ai/anthropic.js +11 -17
  4. package/dist/ai/google.d.ts +0 -63
  5. package/dist/ai/google.d.ts.map +1 -1
  6. package/dist/ai/google.js +11 -25
  7. package/dist/ai/index.d.ts +5 -71
  8. package/dist/ai/index.d.ts.map +1 -1
  9. package/dist/ai/index.js +33 -241
  10. package/dist/ai/openai.d.ts +0 -92
  11. package/dist/ai/openai.d.ts.map +1 -1
  12. package/dist/ai/openai.js +7 -17
  13. package/dist/ai/vercel-ai.d.ts +0 -66
  14. package/dist/ai/vercel-ai.d.ts.map +1 -1
  15. package/dist/ai/vercel-ai.js +7 -12
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +2 -1
  19. package/dist/server.d.ts +1 -1
  20. package/dist/server.d.ts.map +1 -1
  21. package/dist/server.js +676 -787
  22. package/dist/src/ai/anthropic.d.ts +16 -117
  23. package/dist/src/ai/anthropic.d.ts.map +1 -1
  24. package/dist/src/ai/google.d.ts +0 -63
  25. package/dist/src/ai/google.d.ts.map +1 -1
  26. package/dist/src/ai/index.d.ts +5 -71
  27. package/dist/src/ai/index.d.ts.map +1 -1
  28. package/dist/src/ai/openai.d.ts +0 -92
  29. package/dist/src/ai/openai.d.ts.map +1 -1
  30. package/dist/src/ai/vercel-ai.d.ts +0 -66
  31. package/dist/src/ai/vercel-ai.d.ts.map +1 -1
  32. package/dist/src/server.d.ts +5 -0
  33. package/dist/src/server.d.ts.map +1 -1
  34. package/package.json +4 -36
  35. package/server.ts +18 -41
  36. package/dist/ai/cloudflare.d.ts +0 -158
  37. package/dist/ai/cloudflare.d.ts.map +0 -1
  38. package/dist/ai/cloudflare.js +0 -4249
  39. package/dist/ai/langchain.d.ts +0 -139
  40. package/dist/ai/langchain.d.ts.map +0 -1
  41. package/dist/ai/langchain.js +0 -4237
  42. package/dist/ai/llamaindex.d.ts +0 -125
  43. package/dist/ai/llamaindex.d.ts.map +0 -1
  44. package/dist/ai/llamaindex.js +0 -4236
  45. package/dist/ai/mastra.d.ts +0 -138
  46. package/dist/ai/mastra.d.ts.map +0 -1
  47. package/dist/ai/mastra.js +0 -4240
  48. package/dist/src/ai/cloudflare.d.ts +0 -158
  49. package/dist/src/ai/cloudflare.d.ts.map +0 -1
  50. package/dist/src/ai/langchain.d.ts +0 -139
  51. package/dist/src/ai/langchain.d.ts.map +0 -1
  52. package/dist/src/ai/llamaindex.d.ts +0 -125
  53. package/dist/src/ai/llamaindex.d.ts.map +0 -1
  54. package/dist/src/ai/mastra.d.ts +0 -138
  55. package/dist/src/ai/mastra.d.ts.map +0 -1
  56. package/dist/src/integrations/vercel-ai.d.ts +0 -127
  57. package/dist/src/integrations/vercel-ai.d.ts.map +0 -1
  58. package/dist/src/plugins/generic.d.ts +0 -99
  59. package/dist/src/plugins/generic.d.ts.map +0 -1
  60. package/dist/src/plugins/github-client.d.ts +0 -320
  61. package/dist/src/plugins/github-client.d.ts.map +0 -1
  62. package/dist/src/plugins/github.d.ts +0 -89
  63. package/dist/src/plugins/github.d.ts.map +0 -1
  64. package/dist/src/plugins/gmail-client.d.ts +0 -106
  65. package/dist/src/plugins/gmail-client.d.ts.map +0 -1
  66. package/dist/src/plugins/gmail.d.ts +0 -87
  67. package/dist/src/plugins/gmail.d.ts.map +0 -1
  68. package/dist/src/plugins/server-client.d.ts +0 -18
  69. package/dist/src/plugins/server-client.d.ts.map +0 -1
  70. package/dist/src/plugins/types.d.ts +0 -70
  71. package/dist/src/plugins/types.d.ts.map +0 -1
@@ -4,7 +4,6 @@
4
4
  * Helper functions to convert MCP tools to Anthropic Claude API format
5
5
  */
6
6
  import type { MCPClient } from "../client.js";
7
- import type { MCPTool } from "../protocol/messages.js";
8
7
  import { type AIToolsOptions } from "./utils.js";
9
8
  import type Anthropic from "@anthropic-ai/sdk";
10
9
  /**
@@ -43,100 +42,6 @@ export interface AnthropicToolResultBlock {
43
42
  tool_use_id: string;
44
43
  content: string;
45
44
  }
46
- /**
47
- * Convert a single MCP tool to Anthropic Claude API format
48
- *
49
- * @param mcpTool - The MCP tool definition
50
- * @param client - The MCP client instance (used for executing the tool)
51
- * @param options - Optional configuration including provider tokens
52
- * @returns Anthropic compatible tool definition
53
- *
54
- * @example
55
- * ```typescript
56
- * const anthropicTool = convertMCPToolToAnthropic(mcpTool, client);
57
- * ```
58
- */
59
- export declare function convertMCPToolToAnthropic(mcpTool: MCPTool, _client: MCPClient<any>, _options?: AnthropicToolsOptions): AnthropicTool;
60
- /**
61
- * Convert all enabled MCP tools to Anthropic Claude API format
62
- *
63
- * @param client - The MCP client instance (must be connected)
64
- * @param options - Optional configuration including provider tokens
65
- * @returns Array of Anthropic compatible tool definitions
66
- *
67
- * @example
68
- * ```typescript
69
- * // Client-side usage
70
- * const tools = convertMCPToolsToAnthropic(mcpClient);
71
- *
72
- * // Server-side with provider tokens
73
- * const tools = convertMCPToolsToAnthropic(serverClient, {
74
- * providerTokens: { github: 'ghp_...', gmail: 'ya29...' }
75
- * });
76
- * ```
77
- */
78
- export declare function convertMCPToolsToAnthropic(client: MCPClient<any>, options?: AnthropicToolsOptions): AnthropicTool[];
79
- /**
80
- * Execute a tool call from Anthropic's response
81
- *
82
- * @param client - The MCP client instance
83
- * @param toolUse - The tool use block from Anthropic response
84
- * @param options - Optional configuration including provider tokens
85
- * @returns Tool execution result as JSON string
86
- *
87
- * @example
88
- * ```typescript
89
- * const result = await executeAnthropicToolCall(client, {
90
- * type: 'tool_use',
91
- * id: 'toolu_123',
92
- * name: 'github_create_issue',
93
- * input: { owner: 'user', repo: 'repo', title: 'Bug' }
94
- * }, { providerTokens });
95
- * ```
96
- */
97
- export declare function executeAnthropicToolCall(client: MCPClient<any>, toolUse: AnthropicToolUseBlock, options?: AnthropicToolsOptions): Promise<string>;
98
- /**
99
- * Handle all tool calls from Anthropic's message response
100
- * Executes all tool use blocks and returns tool result blocks
101
- *
102
- * @param client - The MCP client instance
103
- * @param messageContent - Array of content blocks from Anthropic message
104
- * @param options - Optional configuration including provider tokens
105
- * @returns Array of tool result blocks ready to send back to Claude
106
- *
107
- * @example
108
- * ```typescript
109
- * const response = await anthropic.messages.create({
110
- * model: 'claude-3-5-sonnet-20241022',
111
- * max_tokens: 1024,
112
- * tools,
113
- * messages: [{ role: 'user', content: 'Create a GitHub issue' }]
114
- * });
115
- *
116
- * // Handle tool calls
117
- * const toolResults = await handleAnthropicToolCalls(
118
- * client,
119
- * response.content,
120
- * { providerTokens }
121
- * );
122
- *
123
- * // Continue conversation with tool results
124
- * const finalResponse = await anthropic.messages.create({
125
- * model: 'claude-3-5-sonnet-20241022',
126
- * max_tokens: 1024,
127
- * tools,
128
- * messages: [
129
- * { role: 'user', content: 'Create a GitHub issue' },
130
- * { role: 'assistant', content: response.content },
131
- * { role: 'user', content: toolResults }
132
- * ]
133
- * });
134
- * ```
135
- */
136
- export declare function handleAnthropicToolCalls(client: MCPClient<any>, messageContent: Array<{
137
- type: string;
138
- [key: string]: any;
139
- }>, options?: AnthropicToolsOptions): Promise<AnthropicToolResultBlock[]>;
140
45
  /**
141
46
  * Get tools in a format compatible with Anthropic Claude API
142
47
  *
@@ -193,7 +98,7 @@ export declare function getAnthropicTools(client: MCPClient<any>, options?: Anth
193
98
  * @param client - The MCP client instance
194
99
  * @param message - The complete Message object from Anthropic
195
100
  * @param options - Optional configuration including provider tokens
196
- * @returns Array with a single user message containing tool results, or empty array if no tool calls
101
+ * @returns Tool execution results as MessageParam[] if tools were called, otherwise returns the original message
197
102
  *
198
103
  * @example
199
104
  * ```typescript
@@ -206,7 +111,6 @@ export declare function getAnthropicTools(client: MCPClient<any>, options?: Anth
206
111
  * export async function POST(req: Request) {
207
112
  * const { messages } = await req.json();
208
113
  *
209
- * // Initial request with tools
210
114
  * const message = await anthropic.messages.create({
211
115
  * model: 'claude-3-5-sonnet-20241022',
212
116
  * max_tokens: 1024,
@@ -214,26 +118,9 @@ export declare function getAnthropicTools(client: MCPClient<any>, options?: Anth
214
118
  * messages,
215
119
  * });
216
120
  *
217
- * // If there are tool calls, handle them automatically
218
- * if (message.stop_reason === 'tool_use') {
219
- * const toolMessages = await handleAnthropicMessage(serverClient, message);
220
- *
221
- * // Continue conversation with tool results
222
- * const finalMessage = await anthropic.messages.create({
223
- * model: 'claude-3-5-sonnet-20241022',
224
- * max_tokens: 1024,
225
- * tools: await getAnthropicTools(serverClient),
226
- * messages: [
227
- * ...messages,
228
- * { role: 'assistant', content: message.content },
229
- * ...toolMessages,
230
- * ],
231
- * });
232
- *
233
- * return Response.json(finalMessage);
234
- * }
121
+ * const result = await handleAnthropicMessage(serverClient, message);
235
122
  *
236
- * return Response.json(message);
123
+ * return Response.json(result);
237
124
  * }
238
125
  * ```
239
126
  *
@@ -245,5 +132,17 @@ export declare function getAnthropicTools(client: MCPClient<any>, options?: Anth
245
132
  * });
246
133
  * ```
247
134
  */
248
- export declare function handleAnthropicMessage(client: MCPClient<any>, message: Anthropic.Messages.Message, options?: AnthropicToolsOptions): Promise<Anthropic.Messages.MessageParam[]>;
135
+ export declare function handleAnthropicMessage(client: MCPClient<any>, message: {
136
+ role: string;
137
+ content: Array<{
138
+ type: string;
139
+ [key: string]: any;
140
+ }>;
141
+ } & Record<string, any>, options?: AnthropicToolsOptions): Promise<Anthropic.Messages.MessageParam[] | ({
142
+ role: string;
143
+ content: Array<{
144
+ type: string;
145
+ [key: string]: any;
146
+ }>;
147
+ } & Record<string, any>)>;
249
148
  //# sourceMappingURL=anthropic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../../src/ai/anthropic.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;A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AAM,EAAE,GAAG,CAAC,EACpG,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAA,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAkC5I"}
@@ -4214,24 +4214,17 @@ function convertMCPToolToAnthropic(mcpTool, _client, _options) {
4214
4214
  }
4215
4215
  };
4216
4216
  }
4217
- function convertMCPToolsToAnthropic(client, options) {
4218
- const mcpTools = client.getEnabledTools();
4219
- return mcpTools.map((mcpTool) => convertMCPToolToAnthropic(mcpTool, client, options));
4220
- }
4221
- async function executeAnthropicToolCall(client, toolUse, options) {
4222
- const result = await executeToolWithToken(client, toolUse.name, toolUse.input, options);
4223
- return JSON.stringify(result);
4224
- }
4225
4217
  async function handleAnthropicToolCalls(client, messageContent, options) {
4226
4218
  const toolResults = [];
4227
4219
  const toolUseBlocks = messageContent.filter((block) => block.type === "tool_use" && ("id" in block) && ("name" in block) && ("input" in block));
4228
4220
  for (const toolUse of toolUseBlocks) {
4229
4221
  try {
4230
- const result = await executeAnthropicToolCall(client, toolUse, options);
4222
+ const result = await executeToolWithToken(client, toolUse.name, toolUse.input, options);
4223
+ const resultString = JSON.stringify(result);
4231
4224
  toolResults.push({
4232
4225
  type: "tool_result",
4233
4226
  tool_use_id: toolUse.id,
4234
- content: result
4227
+ content: resultString
4235
4228
  });
4236
4229
  } catch (error) {
4237
4230
  toolResults.push({
@@ -4254,7 +4247,8 @@ async function getAnthropicTools(client, options) {
4254
4247
  } catch {}
4255
4248
  }
4256
4249
  const finalOptions = providerTokens ? { ...options, providerTokens } : options;
4257
- return convertMCPToolsToAnthropic(client, finalOptions);
4250
+ const mcpTools = client.getEnabledTools();
4251
+ return mcpTools.map((mcpTool) => convertMCPToolToAnthropic(mcpTool, client, finalOptions));
4258
4252
  }
4259
4253
  async function handleAnthropicMessage(client, message, options) {
4260
4254
  let providerTokens = options?.providerTokens;
@@ -4266,9 +4260,13 @@ async function handleAnthropicMessage(client, message, options) {
4266
4260
  const finalOptions = providerTokens ? { ...options, providerTokens } : options;
4267
4261
  const toolResults = await handleAnthropicToolCalls(client, message.content, finalOptions);
4268
4262
  if (toolResults.length === 0) {
4269
- return [];
4263
+ return message;
4270
4264
  }
4271
4265
  return [
4266
+ {
4267
+ role: message.role,
4268
+ content: message.content
4269
+ },
4272
4270
  {
4273
4271
  role: "user",
4274
4272
  content: toolResults
@@ -4276,10 +4274,6 @@ async function handleAnthropicMessage(client, message, options) {
4276
4274
  ];
4277
4275
  }
4278
4276
  export {
4279
- handleAnthropicToolCalls,
4280
4277
  handleAnthropicMessage,
4281
- getAnthropicTools,
4282
- executeAnthropicToolCall,
4283
- convertMCPToolsToAnthropic,
4284
- convertMCPToolToAnthropic
4278
+ getAnthropicTools
4285
4279
  };
@@ -4,7 +4,6 @@
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 { MCPTool } from "../protocol/messages.js";
8
7
  import { type AIToolsOptions } from "./utils.js";
9
8
  import type { Schema, FunctionDeclaration, FunctionCall, Type } from "@google/genai";
10
9
  export type GoogleTool = FunctionDeclaration;
@@ -15,68 +14,6 @@ export type { Schema, Type };
15
14
  */
16
15
  export interface GoogleToolsOptions extends AIToolsOptions {
17
16
  }
18
- /**
19
- * Convert a single MCP tool to Google GenAI format
20
- *
21
- * @param mcpTool - The MCP tool definition
22
- * @param client - The MCP client instance (used for executing the tool)
23
- * @param options - Optional configuration including provider tokens
24
- * @returns Google GenAI compatible tool definition
25
- *
26
- * @example
27
- * ```typescript
28
- * const googleTool = await convertMCPToolToGoogle(mcpTool, client);
29
- * ```
30
- */
31
- export declare function convertMCPToolToGoogle(mcpTool: MCPTool, _client: MCPClient<any>, _options?: GoogleToolsOptions): Promise<GoogleTool>;
32
- /**
33
- * Convert all enabled MCP tools to Google GenAI format
34
- *
35
- * @param client - The MCP client instance (must be connected)
36
- * @param options - Optional configuration including provider tokens
37
- * @returns Array of Google GenAI compatible tool definitions
38
- *
39
- * @example
40
- * ```typescript
41
- * // Client-side usage
42
- * const tools = await convertMCPToolsToGoogle(mcpClient);
43
- *
44
- * // Server-side with provider tokens
45
- * const tools = await convertMCPToolsToGoogle(serverClient, {
46
- * providerTokens: { github: 'ghp_...', gmail: 'ya29...' }
47
- * });
48
- * ```
49
- */
50
- export declare function convertMCPToolsToGoogle(client: MCPClient<any>, options?: GoogleToolsOptions): Promise<GoogleTool[]>;
51
- /**
52
- * Execute a function call from Google GenAI
53
- *
54
- * Automatically extracts provider tokens from the request if not provided.
55
- *
56
- * @param client - The MCP client instance
57
- * @param functionCall - The function call from Google GenAI response
58
- * @param options - Optional configuration including provider tokens
59
- * @returns Tool execution result as JSON string
60
- *
61
- * @example
62
- * ```typescript
63
- * // Tokens are automatically extracted
64
- * const result = await executeGoogleFunctionCall(client, {
65
- * name: 'github_create_issue',
66
- * args: { owner: 'user', repo: 'repo', title: 'Bug' }
67
- * });
68
- * ```
69
- *
70
- * @example
71
- * ```typescript
72
- * // Or explicitly pass provider tokens
73
- * const result = await executeGoogleFunctionCall(client, {
74
- * name: 'github_create_issue',
75
- * args: { owner: 'user', repo: 'repo', title: 'Bug' }
76
- * }, { providerTokens });
77
- * ```
78
- */
79
- export declare function executeGoogleFunctionCall(client: MCPClient<any>, functionCall: GoogleFunctionCall, options?: GoogleToolsOptions): Promise<string>;
80
17
  /**
81
18
  * Execute multiple function calls from Google GenAI response
82
19
  *
@@ -1 +1 @@
1
- {"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../../src/ai/google.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EA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U,EAAE,CAAC,CAkBvB"}
package/dist/ai/google.js CHANGED
@@ -4271,25 +4271,6 @@ async function convertMCPToolToGoogle(mcpTool, _client, _options) {
4271
4271
  parameters
4272
4272
  };
4273
4273
  }
4274
- async function convertMCPToolsToGoogle(client, options) {
4275
- const mcpTools = client.getEnabledTools();
4276
- return await Promise.all(mcpTools.map((mcpTool) => convertMCPToolToGoogle(mcpTool, client, options)));
4277
- }
4278
- async function executeGoogleFunctionCall(client, functionCall, options) {
4279
- if (!functionCall?.name) {
4280
- throw new Error("Function call must have a name");
4281
- }
4282
- let providerTokens = options?.providerTokens;
4283
- if (!providerTokens) {
4284
- try {
4285
- providerTokens = await getProviderTokens();
4286
- } catch {}
4287
- }
4288
- const finalOptions = providerTokens ? { ...options, providerTokens } : options;
4289
- const args = functionCall.args || {};
4290
- const result = await executeToolWithToken(client, functionCall.name, args, finalOptions);
4291
- return JSON.stringify(result);
4292
- }
4293
4274
  async function executeGoogleFunctionCalls(client, functionCalls, options) {
4294
4275
  if (!functionCalls || functionCalls.length === 0) {
4295
4276
  return [];
@@ -4301,7 +4282,14 @@ async function executeGoogleFunctionCalls(client, functionCalls, options) {
4301
4282
  } catch {}
4302
4283
  }
4303
4284
  const finalOptions = providerTokens ? { ...options, providerTokens } : options;
4304
- const results = await Promise.all(functionCalls.map((call) => executeGoogleFunctionCall(client, call, finalOptions)));
4285
+ const results = await Promise.all(functionCalls.map(async (call) => {
4286
+ if (!call?.name) {
4287
+ throw new Error("Function call must have a name");
4288
+ }
4289
+ const args = call.args || {};
4290
+ const result = await executeToolWithToken(client, call.name, args, finalOptions);
4291
+ return JSON.stringify(result);
4292
+ }));
4305
4293
  return results;
4306
4294
  }
4307
4295
  async function getGoogleTools(client, options) {
@@ -4313,12 +4301,10 @@ async function getGoogleTools(client, options) {
4313
4301
  } catch {}
4314
4302
  }
4315
4303
  const finalOptions = providerTokens ? { ...options, providerTokens } : options;
4316
- return convertMCPToolsToGoogle(client, finalOptions);
4304
+ const mcpTools = client.getEnabledTools();
4305
+ return await Promise.all(mcpTools.map((mcpTool) => convertMCPToolToGoogle(mcpTool, client, finalOptions)));
4317
4306
  }
4318
4307
  export {
4319
4308
  getGoogleTools,
4320
- executeGoogleFunctionCalls,
4321
- executeGoogleFunctionCall,
4322
- convertMCPToolsToGoogle,
4323
- convertMCPToolToGoogle
4309
+ executeGoogleFunctionCalls
4324
4310
  };
@@ -3,75 +3,9 @@
3
3
  *
4
4
  * Unified interface for all AI provider integrations
5
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 "./anthropic.js";
11
- export * from "./google.js";
12
- export * from "./cloudflare.js";
13
- export * from "./langchain.js";
14
- export * from "./llamaindex.js";
15
- export * from "./mastra.js";
16
- export * from "./utils.js";
17
- /**
18
- * Supported AI provider names
19
- */
20
- export type AIProviderName = "vercel-ai" | "openai" | "anthropic" | "google" | "cloudflare" | "langchain" | "llamaindex" | "mastra";
21
- /**
22
- * Generic function to get AI tools for any supported provider
23
- *
24
- * This provides a unified interface for getting tools from any AI provider.
25
- * Use this when you want to dynamically switch between providers or support multiple providers.
26
- *
27
- * @param client - The MCP client instance
28
- * @param provider - The AI provider name
29
- * @param options - Optional configuration including provider tokens for server-side usage
30
- * @returns Tools in the format expected by the specified provider
31
- *
32
- * @example
33
- * ```typescript
34
- * // Dynamic provider selection
35
- * import { createMCPClient, githubIntegration } from 'integrate-sdk';
36
- * import { getAITools } from 'integrate-sdk/integrations';
37
- *
38
- * const client = createMCPClient({
39
- * integrations: [githubIntegration({ clientId: '...' })],
40
- * });
41
- *
42
- * // Choose provider at runtime
43
- * const provider = process.env.AI_PROVIDER || 'openai';
44
- * const tools = await getAITools(client, provider as any);
45
- * ```
46
- *
47
- * @example
48
- * ```typescript
49
- * // Server-side with provider tokens
50
- * import { createMCPServer, githubIntegration } from 'integrate-sdk/server';
51
- * import { getAITools } from 'integrate-sdk/integrations';
52
- *
53
- * const { client: serverClient } = createMCPServer({
54
- * integrations: [githubIntegration({
55
- * clientId: '...',
56
- * clientSecret: '...'
57
- * })],
58
- * });
59
- *
60
- * export async function POST(req: Request) {
61
- * const providerTokens = JSON.parse(req.headers.get('x-integrate-tokens') || '{}');
62
- *
63
- * // Support multiple providers
64
- * const tools = await getAITools(serverClient, 'anthropic', { providerTokens });
65
- * // ... use with Anthropic SDK
66
- * }
67
- * ```
68
- */
69
- export declare function getAITools(client: MCPClient<any>, provider: "vercel-ai", options?: AIToolsOptions): Promise<Record<string, any>>;
70
- export declare function getAITools(client: MCPClient<any>, provider: "openai", options?: AIToolsOptions): Promise<Array<any>>;
71
- export declare function getAITools(client: MCPClient<any>, provider: "anthropic", options?: AIToolsOptions): Promise<Array<any>>;
72
- export declare function getAITools(client: MCPClient<any>, provider: "google", options?: AIToolsOptions): Promise<Array<any>>;
73
- export declare function getAITools(client: MCPClient<any>, provider: "cloudflare", options?: AIToolsOptions): Promise<Record<string, any>>;
74
- export declare function getAITools(client: MCPClient<any>, provider: "langchain", options?: AIToolsOptions): Promise<Array<any>>;
75
- export declare function getAITools(client: MCPClient<any>, provider: "llamaindex", options?: AIToolsOptions): Promise<Array<any>>;
76
- export declare function getAITools(client: MCPClient<any>, provider: "mastra", options?: AIToolsOptions): Promise<Record<string, any>>;
6
+ export { getVercelAITools, type VercelAITool, type VercelAIToolsOptions } from "./vercel-ai.js";
7
+ export { getOpenAITools, handleOpenAIResponse, type OpenAITool, type OpenAIToolsOptions } from "./openai.js";
8
+ export { getAnthropicTools, handleAnthropicMessage, type AnthropicTool, type AnthropicToolsOptions, type AnthropicToolUseBlock, type AnthropicToolResultBlock } from "./anthropic.js";
9
+ export { getGoogleTools, executeGoogleFunctionCalls, type GoogleTool, type GoogleFunctionCall, type GoogleToolsOptions } from "./google.js";
10
+ export type { AIToolsOptions } from "./utils.js";
77
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d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