Skip to content

Commit 4284c4a

Browse files
Use ai-sdk/mcp package for new mint mcp endpoint
1 parent e9b82a8 commit 4284c4a

4 files changed

Lines changed: 81 additions & 22 deletions

File tree

package-lock.json

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"@ai-sdk/google": "2.0.38",
4141
"@ai-sdk/google-vertex": "^3.0.80",
4242
"@ai-sdk/groq": "2.0.7",
43+
"@ai-sdk/mcp": "0.0.11",
4344
"@ai-sdk/mistral": "2.0.4",
4445
"@ai-sdk/openai": "2.0.68",
4546
"@ai-sdk/perplexity": "2.0.3",

packages/server/api/src/app/ai/mcp/docs-tools.ts

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,49 @@
1+
import { experimental_createMCPClient as createMCPClient } from '@ai-sdk/mcp';
12
import { AppSystemProp, logger, system } from '@openops/server-shared';
2-
import { experimental_createMCPClient as createMCPClient, tool } from 'ai';
3-
import { Experimental_StdioMCPTransport as StdioMCPTransport } from 'ai/mcp-stdio';
3+
import { tool } from 'ai';
44
import { z } from 'zod';
55
import { MCPTool } from './types';
66

7+
type MCPSearchTool = {
8+
execute: (
9+
args: { query: string },
10+
options: { toolCallId: string; messages: unknown[] },
11+
) => Promise<unknown>;
12+
};
13+
714
export async function getDocsTools(): Promise<MCPTool> {
8-
const mcpServerPath = system.get<string>(AppSystemProp.DOCS_MCP_SERVER_PATH);
9-
if (!mcpServerPath) {
15+
const mcpServerUrl = system.get<string>(AppSystemProp.DOCS_MCP_SERVER_PATH);
16+
if (!mcpServerUrl) {
1017
return {
1118
client: undefined,
1219
toolSet: {},
1320
};
1421
}
1522

1623
logger.debug('Creating MCP client for docs', {
17-
serverPath: mcpServerPath,
24+
serverPath: mcpServerUrl,
1825
});
1926

2027
const client = await createMCPClient({
21-
transport: new StdioMCPTransport({
22-
command: 'node',
23-
args: [mcpServerPath],
24-
}),
28+
transport: {
29+
type: 'http',
30+
url: mcpServerUrl,
31+
} as Parameters<typeof createMCPClient>[0]['transport'],
2532
});
2633

2734
const tools = await client.tools();
28-
const searchTool = tools['search'];
35+
const toolEntries =
36+
tools instanceof Map ? Array.from(tools.entries()) : Object.entries(tools);
37+
38+
const searchTool = toolEntries.find(([name]) =>
39+
name.toLowerCase().includes('search'),
40+
)?.[1] as MCPSearchTool | undefined;
41+
42+
if (!searchTool?.execute) {
43+
logger.error('Docs MCP search tool not available', {
44+
availableTools: toolEntries.map(([name]) => name),
45+
});
46+
}
2947

3048
const toolSet = {
3149
OpenOps_Documentation: tool({
@@ -41,25 +59,21 @@ Use this tool to find accurate, verified information before answering OpenOps-sp
4159
query: z.string().describe('The search query'),
4260
}),
4361
execute: async ({ query }) => {
44-
try {
45-
if (!searchTool || typeof searchTool.execute !== 'function') {
46-
return await Promise.resolve({
47-
success: false,
48-
error: 'search tool not available',
49-
});
50-
}
62+
if (!searchTool?.execute) {
63+
return { success: false, error: 'search tool not available' };
64+
}
5165

52-
const result = await searchTool.execute(
66+
try {
67+
return await searchTool.execute(
5368
{ query },
5469
{ toolCallId: '', messages: [] },
5570
);
56-
return result;
5771
} catch (error) {
5872
logger.error('OpenOps Documentation MCP client error:', { error });
59-
return Promise.resolve({
73+
return {
6074
success: false,
6175
error: error instanceof Error ? error.message : String(error),
62-
});
76+
};
6377
}
6478
},
6579
}),

packages/server/shared/src/lib/system/system.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const systemPropDefaultValues: Partial<Record<SystemProp, string>> = {
8787
[AppSystemProp.AI_PROMPTS_LOCATION]:
8888
'https://raw.githubusercontent.com/openops-cloud/openops/main/ai-prompts',
8989
[AppSystemProp.SUPERSET_MCP_SERVER_PATH]: '/root/.mcp/superset',
90-
[AppSystemProp.DOCS_MCP_SERVER_PATH]: '/root/.mcp/docs.openops.com',
90+
[AppSystemProp.DOCS_MCP_SERVER_PATH]: 'https://docs.openops.com/mcp',
9191
[AppSystemProp.LOAD_EXPERIMENTAL_MCP_TOOLS]: 'false',
9292
[SharedSystemProp.AWS_ENABLE_IMPLICIT_ROLE]: 'false',
9393
[AppSystemProp.OPENOPS_MCP_SERVER_PATH]: '/root/.mcp/openops-mcp',

0 commit comments

Comments
 (0)