integrate-sdk 0.4.11 → 0.4.13
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
|
@@ -1970,10 +1970,35 @@ function createSimplePlugin(config) {
|
|
|
1970
1970
|
function getProviderForTool(client, toolName) {
|
|
1971
1971
|
return client.getProviderForTool?.(toolName);
|
|
1972
1972
|
}
|
|
1973
|
+
function normalizeSchema(schema) {
|
|
1974
|
+
if (!schema || typeof schema !== "object") {
|
|
1975
|
+
return {
|
|
1976
|
+
type: "object",
|
|
1977
|
+
properties: {},
|
|
1978
|
+
additionalProperties: false
|
|
1979
|
+
};
|
|
1980
|
+
}
|
|
1981
|
+
if (schema.type === "None" || schema.type === null || schema.type === undefined) {
|
|
1982
|
+
return {
|
|
1983
|
+
type: "object",
|
|
1984
|
+
properties: schema.properties || {},
|
|
1985
|
+
additionalProperties: schema.additionalProperties ?? false,
|
|
1986
|
+
required: schema.required || []
|
|
1987
|
+
};
|
|
1988
|
+
}
|
|
1989
|
+
if (schema.type !== "object") {
|
|
1990
|
+
return {
|
|
1991
|
+
type: "object",
|
|
1992
|
+
properties: {},
|
|
1993
|
+
additionalProperties: false
|
|
1994
|
+
};
|
|
1995
|
+
}
|
|
1996
|
+
return schema;
|
|
1997
|
+
}
|
|
1973
1998
|
function convertMCPToolToVercelAI(mcpTool, client, options) {
|
|
1974
1999
|
return {
|
|
1975
2000
|
description: mcpTool.description || `Execute ${mcpTool.name}`,
|
|
1976
|
-
parameters: mcpTool.inputSchema,
|
|
2001
|
+
parameters: normalizeSchema(mcpTool.inputSchema),
|
|
1977
2002
|
execute: async (args) => {
|
|
1978
2003
|
if (options?.providerTokens) {
|
|
1979
2004
|
const provider = getProviderForTool(client, mcpTool.name);
|
|
@@ -2008,7 +2033,10 @@ function convertMCPToolsToVercelAI(client, options) {
|
|
|
2008
2033
|
}
|
|
2009
2034
|
return vercelTools;
|
|
2010
2035
|
}
|
|
2011
|
-
function getVercelAITools(client, options) {
|
|
2036
|
+
async function getVercelAITools(client, options) {
|
|
2037
|
+
if (!client.isConnected()) {
|
|
2038
|
+
await client.connect();
|
|
2039
|
+
}
|
|
2012
2040
|
return convertMCPToolsToVercelAI(client, options);
|
|
2013
2041
|
}
|
|
2014
2042
|
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,
|
|
@@ -103,23 +103,24 @@ export declare function convertMCPToolsToVercelAI(client: MCPClient<any>, option
|
|
|
103
103
|
* Get tools in a format compatible with Vercel AI SDK v5's tools parameter
|
|
104
104
|
*
|
|
105
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.
|
|
106
107
|
*
|
|
107
|
-
* @param client - The MCP client instance
|
|
108
|
+
* @param client - The MCP client instance
|
|
108
109
|
* @param options - Optional configuration including provider tokens for server-side usage
|
|
109
110
|
* @returns Tools object ready to pass to generateText({ tools: ... }) or streamText({ tools: ... })
|
|
110
111
|
*
|
|
111
112
|
* @example
|
|
112
113
|
* ```typescript
|
|
113
114
|
* // Client-side usage
|
|
114
|
-
* const tools = getVercelAITools(mcpClient);
|
|
115
|
+
* const tools = await getVercelAITools(mcpClient);
|
|
115
116
|
* ```
|
|
116
117
|
*
|
|
117
118
|
* @example
|
|
118
119
|
* ```typescript
|
|
119
120
|
* // Server-side usage with tokens from client
|
|
120
121
|
* const providerTokens = JSON.parse(req.headers.get('x-integrate-tokens') || '{}');
|
|
121
|
-
* const tools = getVercelAITools(serverClient, { providerTokens });
|
|
122
|
+
* const tools = await getVercelAITools(serverClient, { providerTokens });
|
|
122
123
|
* ```
|
|
123
124
|
*/
|
|
124
|
-
export declare function getVercelAITools(client: MCPClient<any>, options?: VercelAIToolsOptions): Record<string, any
|
|
125
|
+
export declare function getVercelAITools(client: MCPClient<any>, options?: VercelAIToolsOptions): Promise<Record<string, any>>;
|
|
125
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;;;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;
|
|
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;AAgDD;;;;;;;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":"","s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