/** * This file is part of the NocoBase (R) project. * Copyright (c) 2020-2024 NocoBase Co., Ltd. * Authors: NocoBase Team. * * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. * For more information, please refer to: https://www.nocobase.com/agreement. */ import type { MultiServerMCPClient } from '@langchain/mcp-adapters'; import type { Context } from '@nocobase/actions'; import type { DynamicToolsProvider, Permission } from '../tools-manager/types'; export interface MCPManager extends MCPRegistration { init(): Promise; getMCP(name: string): Promise; listMCP(filter: MCPFilter): Promise; testConnection(options: MCPOptions, ctx?: Context): Promise; rebuildClient(): Promise; getClient(): MultiServerMCPClient | null; getMCPToolsProvider(): DynamicToolsProvider; listMCPTools(ctx?: Context): Promise>; updateMCPToolPermission(toolName: string, permission: Permission): Promise; clearUserContextCache(): Promise; } export interface MCPRegistration { registerMCP(registration: { [key: string | symbol]: MCPOptions; }): Promise; } export type MCPOptions = { transport: MCPTransport; command?: string; args?: string[]; env?: Record; url?: string; headers?: Record; restart?: Record; useUserContext?: boolean; }; export type MCPEntry = MCPOptions & { name: string; enabled: boolean; }; export type MCPFilter = { name?: string; enabled?: boolean; transport?: MCPTransport; useUserContext?: boolean; }; export type MCPTransport = 'stdio' | 'sse' | 'http'; export type MCPTestResult = { success: boolean; message?: string; error?: string; details?: string; toolsCount?: number; tools?: string[]; toolsTruncated?: boolean; }; export type MCPToolEntry = { name: string; title: string; description?: string; serverName: string; permission: Permission; };