Skip to content

Commit 6e14098

Browse files
Check tables mcp endpoints list for length (#1705)
Part of OPS-3176
1 parent d324a80 commit 6e14098

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { createAxiosHeaders } from '@openops/common';
22
import { AppSystemProp, system } from '@openops/server-shared';
3+
import { isEmpty } from '@openops/shared';
34
import { experimental_createMCPClient as createMCPClient, ToolSet } from 'ai';
45
import { openopsTables } from '../../openops-tables';
56
import { authenticateAdminUserInOpenOpsTables } from '../../openops-tables/auth-admin-tables';
67
import { MCPTool } from './types';
78

89
export async function getTablesTools(): Promise<MCPTool> {
910
const { token } = await authenticateAdminUserInOpenOpsTables();
10-
const mcpEndpoint = await openopsTables.getMcpEndpointList(token);
11-
if (!mcpEndpoint) {
11+
const mcpEndpoints = await openopsTables.getMcpEndpointList(token);
12+
if (isEmpty(mcpEndpoints)) {
1213
return {
1314
client: undefined,
1415
toolSet: {},
@@ -17,7 +18,7 @@ export async function getTablesTools(): Promise<MCPTool> {
1718

1819
const url =
1920
system.get(AppSystemProp.OPENOPS_TABLES_API_URL) +
20-
`/openops-tables/mcp/${mcpEndpoint[0].key}/sse`;
21+
`/openops-tables/mcp/${mcpEndpoints[0].key}/sse`;
2122

2223
const client = await createMCPClient({
2324
transport: {

0 commit comments

Comments
 (0)