/** * Bridges MCP tool discovery into the harness tool registry. * @module @anht3889/dsh-mcp-mgmt-bundle/manager/tools */ import type { Client } from '@modelcontextprotocol/sdk/client'; import type { McpToolInfo } from '@anht3889/dsh-mcp-mgmt-mcp/types'; /** Registration API consumed from the harness tool runtime. */ interface ToolRegistry { register(definition: ToolDefinition): () => void; } /** Context surface needed to expose MCP tools. */ export interface ToolContext { tools: ToolRegistry; } /** Options that identify an MCP server, select its tools, and bound each call. */ export interface SyncToolsOptions { serverName: string; toolCallTimeoutMs: number; /** Raw tool names to list without registering. */ disabledTools: readonly string[]; } /** One registered MCP tool's teardown, keyed by its public name. */ export type ToolDisposers = Map void>; /** The outcome of one tool-discovery pass. */ export interface SyncedTools { /** Disposers for the tools this pass registered, keyed by public name. */ disposers: ToolDisposers; /** Every tool the server listed, registered or not, in listing order. */ listed: McpToolInfo[]; } interface ToolDefinition { name: string; description: string; parameters: unknown; timeoutMs: number; output: { schema: object; render(args: unknown, value: unknown): Array<{ type: 'text'; text: string; }>; }; execute(args: unknown, exec: { signal: AbortSignal; }): Promise; } /** * Lists an MCP server's tools and registers the selected ones under public * names. A disabled tool is still reported, so the settings UI can offer it * without a reconnect. * * @param ctx - Harness context that owns the tool registry. * @param client - Connected MCP client used for discovery and invocation. * @param opts - Server namespace, disabled tool names, and per-tool timeout. * @returns Disposers for every registration created by this call, plus every * listed tool. */ export declare function syncTools(ctx: ToolContext, client: Client, opts: SyncToolsOptions): Promise; export {};