From d454d5a27d1d0c046888cf2449c70e9fa2cc1656 Mon Sep 17 00:00:00 2001 From: Vaayne Date: Wed, 24 Dec 2025 12:20:39 +0800 Subject: [PATCH] feat(mcp): add hub server type definitions - Add 'hub' to BuiltinMCPServerNames enum as '@cherry/hub' - Create GeneratedTool, SearchQuery, ExecInput, ExecOutput types - Add ExecutionContext and ConsoleMethods interfaces Amp-Thread-ID: https://ampcode.com/threads/T-019b4e7d-86a3-770d-82f8-9e646e7e597e Co-authored-by: Amp --- src/main/mcpServers/hub/types.ts | 58 ++++++++++++++++++++++++++++++++ src/renderer/src/types/index.ts | 3 +- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 src/main/mcpServers/hub/types.ts diff --git a/src/main/mcpServers/hub/types.ts b/src/main/mcpServers/hub/types.ts new file mode 100644 index 0000000000..5513e31857 --- /dev/null +++ b/src/main/mcpServers/hub/types.ts @@ -0,0 +1,58 @@ +import type { MCPServer, MCPTool } from '@types' + +export interface GeneratedTool { + serverId: string + serverName: string + toolName: string + toolId: string + functionName: string + jsCode: string + fn: (params: unknown) => Promise + signature: string + returns: string + description?: string +} + +export interface SearchQuery { + query: string + limit?: number +} + +export interface SearchResult { + tools: string + total: number +} + +export interface ExecInput { + code: string +} + +export interface ExecOutput { + result: unknown + logs?: string[] + error?: string +} + +export interface ToolRegistryOptions { + ttl?: number +} + +export interface MCPToolWithServer extends MCPTool { + server: MCPServer +} + +export interface ExecutionContext { + __callTool: (toolId: string, params: unknown) => Promise + parallel: (...promises: Promise[]) => Promise + settle: (...promises: Promise[]) => Promise[]> + console: ConsoleMethods + [functionName: string]: unknown +} + +export interface ConsoleMethods { + log: (...args: unknown[]) => void + warn: (...args: unknown[]) => void + error: (...args: unknown[]) => void + info: (...args: unknown[]) => void + debug: (...args: unknown[]) => void +} diff --git a/src/renderer/src/types/index.ts b/src/renderer/src/types/index.ts index 126c97686e..d02c3c2c0a 100644 --- a/src/renderer/src/types/index.ts +++ b/src/renderer/src/types/index.ts @@ -754,7 +754,8 @@ export const BuiltinMCPServerNames = { python: '@cherry/python', didiMCP: '@cherry/didi-mcp', browser: '@cherry/browser', - nowledgeMem: '@cherry/nowledge-mem' + nowledgeMem: '@cherry/nowledge-mem', + hub: '@cherry/hub' } as const export type BuiltinMCPServerName = (typeof BuiltinMCPServerNames)[keyof typeof BuiltinMCPServerNames]