import type { MCPServerConfig } from "./types.js"; /** * On-disk cache of MCP tool definitions, so a cold start can answer * `tool_search` honestly before any server has finished connecting. * * With `backgroundMcpConnect` on (the desktop default) the first turns run * against an empty `DeferredToolCatalog`, and `tool_search` reports "the * catalog is empty — every catalog tool is already available" for capabilities * that genuinely exist. That is a wrong answer, not a slow one. * * Entries are keyed by server name plus a hash of the resolved server config, * so editing a server's command, URL, headers or env invalidates its cache * instead of serving tools that server no longer exposes. */ /** * Negotiated MCP protocol era for a server, using the SDK's own vocabulary: * `legacy` = the 2025 `initialize` handshake, `modern` = 2026-07-28+. Feeds the * connect-time `prior` hint that lets a later connect skip the discovery probe. */ export type ProtocolEra = "legacy" | "modern"; export interface CachedTool { name: string; description: string; rawInputSchema?: Record; } export interface CachedServerEntry { configHash: string; savedAt: number; protocolEra?: ProtocolEra; tools: CachedTool[]; } /** * Stable hash of everything that can change which tools a server exposes. * Key order is normalized so a reordered config file is not a cache miss. */ export declare function hashServerConfig(config: MCPServerConfig): string; /** * File-backed MCP tool catalog cache at `~/.gg/mcp-catalog.json`. Every read * re-reads the file so concurrent sidecars/windows see each other's writes; * writes are read-modify-write so two servers don't clobber one another. * Malformed files are treated as empty — a broken cache must never break a run. */ export declare class McpCatalogCache { private readonly filePath; /** Serializes read-modify-write cycles within one process. */ private writeQueue; constructor(filePath?: string); private readAll; private writeAll; /** * Cached tools for the given configs, skipping any server whose config hash * changed or whose entry has aged out. Servers with no usable entry are * simply absent from the result. */ entriesFor(configs: readonly MCPServerConfig[]): Promise>; /** Negotiated protocol era recorded for a server, if its config still matches. */ protocolEraFor(config: MCPServerConfig): Promise; /** Record a server's live tool list. Serialized against concurrent saves. */ save(config: MCPServerConfig, tools: readonly CachedTool[], protocolEra?: ProtocolEra): Promise; /** Drop a server's cached tools (removal, or a connect that found none). */ clear(name: string): Promise; } //# sourceMappingURL=catalog-cache.d.ts.map