Skip to content

Commit 9127a62

Browse files
Use ai-sdk/mcp package for new mint doc endpoint (#1749)
Fixes OPS-2911
1 parent 984b9ab commit 9127a62

7 files changed

Lines changed: 121 additions & 26 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ ARG VARIANT=1.1.12-20-bullseye
22
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:${VARIANT}
33

44
RUN <<-```
5-
npm install -g nx cross-env@7.0.3 mint-mcp
6-
npx -y mint-mcp add docs.openops.com
5+
npm install -g nx cross-env@7.0.3
76
apt-get update && apt-get install -y --no-install-recommends \
87
git \
98
locales \

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ RUN <<-```
1111
set -ex
1212
apk add --no-cache openssh-client python3 g++ git musl libcap-dev nginx gettext wget py3-setuptools make bash findutils
1313
yarn config set python /usr/bin/python3
14-
npm install -g node-gyp npm@9.3.1 cross-env@7.0.3 mint-mcp
15-
npx -y mint-mcp add docs.openops.com && test -e /root/.mcp/docs.openops.com
1614
```
1715

1816
WORKDIR /root/.mcp/superset

THIRD_PARTY_LICENSES.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16345,11 +16345,13 @@ The following npm packages may be included in this product:
1634516345
- @ai-sdk/google@2.0.38
1634616346
- @ai-sdk/google@2.0.43
1634716347
- @ai-sdk/groq@2.0.7
16348+
- @ai-sdk/mcp@0.0.11
1634816349
- @ai-sdk/mistral@2.0.4
1634916350
- @ai-sdk/openai-compatible@1.0.7
1635016351
- @ai-sdk/openai@2.0.68
1635116352
- @ai-sdk/perplexity@2.0.3
1635216353
- @ai-sdk/provider-utils@3.0.17
16354+
- @ai-sdk/provider-utils@3.0.18
1635316355
- @ai-sdk/provider-utils@3.0.2
1635416356
- @ai-sdk/provider-utils@3.0.3
1635516357
- @ai-sdk/provider-utils@3.0.5
@@ -21837,6 +21839,36 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
2183721839

2183821840
-----------
2183921841

21842+
The following npm package may be included in this product:
21843+
21844+
- pkce-challenge@5.0.1
21845+
21846+
This package contains the following license:
21847+
21848+
MIT License
21849+
21850+
Copyright (c) 2019
21851+
21852+
Permission is hereby granted, free of charge, to any person obtaining a copy
21853+
of this software and associated documentation files (the "Software"), to deal
21854+
in the Software without restriction, including without limitation the rights
21855+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21856+
copies of the Software, and to permit persons to whom the Software is
21857+
furnished to do so, subject to the following conditions:
21858+
21859+
The above copyright notice and this permission notice shall be included in all
21860+
copies or substantial portions of the Software.
21861+
21862+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21863+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21864+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21865+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21866+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21867+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21868+
SOFTWARE.
21869+
21870+
-----------
21871+
2184021872
The following npm packages may be included in this product:
2184121873

2184221874
- cose-base@1.0.3

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: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,56 @@
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+
14+
type MCPHttpTransport = {
15+
type: 'http';
16+
url: string;
17+
};
18+
719
export async function getDocsTools(): Promise<MCPTool> {
8-
const mcpServerPath = system.get<string>(AppSystemProp.DOCS_MCP_SERVER_PATH);
9-
if (!mcpServerPath) {
20+
const mcpServerUrl = system.get<string>(AppSystemProp.DOCS_MCP_SERVER_PATH);
21+
if (!mcpServerUrl) {
1022
return {
1123
client: undefined,
1224
toolSet: {},
1325
};
1426
}
1527

1628
logger.debug('Creating MCP client for docs', {
17-
serverPath: mcpServerPath,
29+
serverPath: mcpServerUrl,
1830
});
1931

2032
const client = await createMCPClient({
21-
transport: new StdioMCPTransport({
22-
command: 'node',
23-
args: [mcpServerPath],
24-
}),
33+
transport: {
34+
type: 'http',
35+
url: mcpServerUrl,
36+
} as MCPHttpTransport,
2537
});
2638

2739
const tools = await client.tools();
28-
const searchTool = tools['search'];
40+
const toolsObject = tools instanceof Map ? Object.fromEntries(tools) : tools;
41+
42+
const searchToolName = Object.keys(toolsObject).find((name) =>
43+
name.toLowerCase().includes('search'),
44+
);
45+
const searchTool = searchToolName
46+
? (toolsObject[searchToolName] as MCPSearchTool)
47+
: undefined;
48+
49+
if (!searchTool?.execute) {
50+
logger.error('Docs MCP search tool not available', {
51+
availableTools: Object.keys(toolsObject),
52+
});
53+
}
2954

3055
const toolSet = {
3156
OpenOps_Documentation: tool({
@@ -41,25 +66,21 @@ Use this tool to find accurate, verified information before answering OpenOps-sp
4166
query: z.string().describe('The search query'),
4267
}),
4368
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-
}
69+
if (!searchTool?.execute) {
70+
return { success: false, error: 'search tool not available' };
71+
}
5172

52-
const result = await searchTool.execute(
73+
try {
74+
return await searchTool.execute(
5375
{ query },
5476
{ toolCallId: '', messages: [] },
5577
);
56-
return result;
5778
} catch (error) {
5879
logger.error('OpenOps Documentation MCP client error:', { error });
59-
return Promise.resolve({
80+
return {
6081
success: false,
6182
error: error instanceof Error ? error.message : String(error),
62-
});
83+
};
6384
}
6485
},
6586
}),

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)