integrate-sdk 0.4.10 → 0.4.12
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/index.js
CHANGED
|
@@ -1967,16 +1967,13 @@ function createSimplePlugin(config) {
|
|
|
1967
1967
|
};
|
|
1968
1968
|
}
|
|
1969
1969
|
// src/integrations/vercel-ai.ts
|
|
1970
|
-
function convertMCPSchemaToParameters(inputSchema) {
|
|
1971
|
-
return inputSchema;
|
|
1972
|
-
}
|
|
1973
1970
|
function getProviderForTool(client, toolName) {
|
|
1974
1971
|
return client.getProviderForTool?.(toolName);
|
|
1975
1972
|
}
|
|
1976
1973
|
function convertMCPToolToVercelAI(mcpTool, client, options) {
|
|
1977
1974
|
return {
|
|
1978
1975
|
description: mcpTool.description || `Execute ${mcpTool.name}`,
|
|
1979
|
-
parameters:
|
|
1976
|
+
parameters: mcpTool.inputSchema,
|
|
1980
1977
|
execute: async (args) => {
|
|
1981
1978
|
if (options?.providerTokens) {
|
|
1982
1979
|
const provider = getProviderForTool(client, mcpTool.name);
|
|
@@ -2011,7 +2008,10 @@ function convertMCPToolsToVercelAI(client, options) {
|
|
|
2011
2008
|
}
|
|
2012
2009
|
return vercelTools;
|
|
2013
2010
|
}
|
|
2014
|
-
function getVercelAITools(client, options) {
|
|
2011
|
+
async function getVercelAITools(client, options) {
|
|
2012
|
+
if (!client.isConnected()) {
|
|
2013
|
+
await client.connect();
|
|
2014
|
+
}
|
|
2015
2015
|
return convertMCPToolsToVercelAI(client, options);
|
|
2016
2016
|
}
|
|
2017
2017
|
export {
|
package/dist/server.js
CHANGED
|
@@ -1875,7 +1875,12 @@ function createMCPServer(config) {
|
|
|
1875
1875
|
}
|
|
1876
1876
|
}
|
|
1877
1877
|
globalServerConfig = { providers };
|
|
1878
|
-
const
|
|
1878
|
+
const clientConfig = {
|
|
1879
|
+
...config,
|
|
1880
|
+
connectionMode: config.connectionMode || "lazy",
|
|
1881
|
+
singleton: config.singleton ?? true
|
|
1882
|
+
};
|
|
1883
|
+
const client = new MCPClient(clientConfig);
|
|
1879
1884
|
const { POST, GET } = createOAuthRouteHandlers({ providers });
|
|
1880
1885
|
return {
|
|
1881
1886
|
client,
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Vercel AI SDK Integration
|
|
3
3
|
*
|
|
4
|
-
* Helper functions to convert MCP tools to Vercel AI SDK format
|
|
4
|
+
* Helper functions to convert MCP tools to Vercel AI SDK v5 format
|
|
5
5
|
*/
|
|
6
6
|
import type { MCPClient } from "../client.js";
|
|
7
7
|
import type { MCPTool } from "../protocol/messages.js";
|
|
8
8
|
/**
|
|
9
|
-
* Tool definition
|
|
9
|
+
* Tool definition compatible with Vercel AI SDK v5
|
|
10
|
+
* This matches the CoreTool interface from 'ai' package v5
|
|
10
11
|
*/
|
|
11
12
|
export interface VercelAITool {
|
|
12
|
-
description
|
|
13
|
-
parameters:
|
|
14
|
-
execute: (args:
|
|
13
|
+
description?: string;
|
|
14
|
+
parameters: any;
|
|
15
|
+
execute: (args: any, options?: any) => Promise<any>;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* Options for converting MCP tools to Vercel AI SDK format
|
|
@@ -43,11 +44,11 @@ export interface VercelAIToolsOptions {
|
|
|
43
44
|
*/
|
|
44
45
|
export declare function convertMCPToolToVercelAI(mcpTool: MCPTool, client: MCPClient<any>, options?: VercelAIToolsOptions): VercelAITool;
|
|
45
46
|
/**
|
|
46
|
-
* Convert all enabled MCP tools to Vercel AI SDK format
|
|
47
|
+
* Convert all enabled MCP tools to Vercel AI SDK v5 format
|
|
47
48
|
*
|
|
48
49
|
* @param client - The MCP client instance (must be connected)
|
|
49
50
|
* @param options - Optional configuration including provider tokens for server-side usage
|
|
50
|
-
* @returns Object mapping tool names to Vercel AI SDK tool definitions
|
|
51
|
+
* @returns Object mapping tool names to Vercel AI SDK v5 tool definitions (compatible with CoreTool from 'ai' package v5)
|
|
51
52
|
*
|
|
52
53
|
* @example
|
|
53
54
|
* ```typescript
|
|
@@ -97,28 +98,29 @@ export declare function convertMCPToolToVercelAI(mcpTool: MCPTool, client: MCPCl
|
|
|
97
98
|
* }
|
|
98
99
|
* ```
|
|
99
100
|
*/
|
|
100
|
-
export declare function convertMCPToolsToVercelAI(client: MCPClient<any>, options?: VercelAIToolsOptions): Record<string,
|
|
101
|
+
export declare function convertMCPToolsToVercelAI(client: MCPClient<any>, options?: VercelAIToolsOptions): Record<string, any>;
|
|
101
102
|
/**
|
|
102
|
-
* Get tools in a format compatible with Vercel AI SDK's tools parameter
|
|
103
|
+
* Get tools in a format compatible with Vercel AI SDK v5's tools parameter
|
|
103
104
|
*
|
|
104
|
-
* This
|
|
105
|
+
* This returns the tools in the exact format expected by ai.generateText() and ai.streamText()
|
|
106
|
+
* Automatically connects the client if not already connected.
|
|
105
107
|
*
|
|
106
|
-
* @param client - The MCP client instance
|
|
108
|
+
* @param client - The MCP client instance
|
|
107
109
|
* @param options - Optional configuration including provider tokens for server-side usage
|
|
108
|
-
* @returns Tools object ready to pass to generateText({ tools: ... })
|
|
110
|
+
* @returns Tools object ready to pass to generateText({ tools: ... }) or streamText({ tools: ... })
|
|
109
111
|
*
|
|
110
112
|
* @example
|
|
111
113
|
* ```typescript
|
|
112
114
|
* // Client-side usage
|
|
113
|
-
* const tools = getVercelAITools(mcpClient);
|
|
115
|
+
* const tools = await getVercelAITools(mcpClient);
|
|
114
116
|
* ```
|
|
115
117
|
*
|
|
116
118
|
* @example
|
|
117
119
|
* ```typescript
|
|
118
120
|
* // Server-side usage with tokens from client
|
|
119
121
|
* const providerTokens = JSON.parse(req.headers.get('x-integrate-tokens') || '{}');
|
|
120
|
-
* const tools = getVercelAITools(serverClient, { providerTokens });
|
|
122
|
+
* const tools = await getVercelAITools(serverClient, { providerTokens });
|
|
121
123
|
* ```
|
|
122
124
|
*/
|
|
123
|
-
export declare function getVercelAITools(client: MCPClient<any>, options?: VercelAIToolsOptions): Record<string,
|
|
125
|
+
export declare function getVercelAITools(client: MCPClient<any>, options?: VercelAIToolsOptions): Promise<Record<string, any>>;
|
|
124
126
|
//# sourceMappingURL=vercel-ai.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel-ai.d.ts","sourceRoot":"","sources":["../../../src/integrations/vercel-ai.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEvD
|
|
1
|
+
{"version":3,"file":"vercel-ai.d.ts","sourceRoot":"","sources":["../../../src/integrations/vercel-ai.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEvD;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,GAAG,CAAC;IAChB,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACrD;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;AAYD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,YAAY,CAsCd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CASrB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,oBAAoB,gCAQ/B"}
|
package/dist/src/server.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ import type { MCPPlugin } from './plugins/types.js';
|
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
47
|
export declare function createMCPServer<TPlugins extends readonly MCPPlugin[]>(config: MCPClientConfig<TPlugins>): {
|
|
48
|
-
/** Server-side MCP client instance */
|
|
48
|
+
/** Server-side MCP client instance with auto-connection */
|
|
49
49
|
client: MCPClient<TPlugins>;
|
|
50
50
|
/** OAuth POST handler - export this from your route file */
|
|
51
51
|
POST: (req: any, context: {
|
package/dist/src/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAyCpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,eAAe,CAAC,QAAQ,SAAS,SAAS,SAAS,EAAE,EACnE,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,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