/**
 * Local MCP (Model Context Protocol) Client Manager for stdio transport
 *
 * This module manages local MCP servers that run as child processes using stdio transport.
 * Local MCP servers are defined in mcp.json configuration file in the working directory.
 *
 * Tool naming follows the same convention as remote MCPs:
 * - Tools are prefixed with server name: `mcp__servername__toolname`
 * - This prevents conflicts with built-in tools and other MCP tools
 */
import type { MCPClientStatus } from "$/ai-utils";
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import type { DevToolsSys } from "../core";
import { type ChildProcess } from "child_process";
export interface MCPServerStdioDefinition {
    name: string;
    command: string;
    args?: string[];
    env?: Record<string, string>;
    envFile?: string;
}
export interface MCPConfig {
    mcpServers: Record<string, Omit<MCPServerStdioDefinition, "name">>;
}
export interface LocalMCPClient {
    client: Client | undefined;
    process: ChildProcess | undefined;
    status: MCPClientStatus;
    serverName: string;
    command: string;
    resources?: {
        uri: string;
        name?: string;
        description?: string;
        mimeType?: string;
    }[];
}
export interface LocalMCPClientManager {
    clients: LocalMCPClient[];
    listTools: () => {
        name: string;
        description?: string;
        inputSchema?: any;
        serverName: string;
    }[];
    callTool: (name: string, args?: any, signal?: AbortSignal) => Promise<{
        content: Array<{
            type: string;
            text?: string;
            data?: any;
        }>;
        isError?: boolean;
    }>;
    getResources: (serverName?: string) => Array<{
        uri: string;
        name?: string;
        description?: string;
        mimeType?: string;
        serverName: string;
        text?: string;
    }>;
    getStatus: () => Record<string, MCPClientStatus>;
    cleanup: () => Promise<void>;
}
/**
 * Create a local MCP client manager from server definitions
 */
export declare function createLocalMCPClientManager(servers: MCPServerStdioDefinition[], sys: DevToolsSys, workingDirectory: string, signal?: AbortSignal): Promise<LocalMCPClientManager>;
/**
 * Apply environment variable substitution to MCP server configuration
 * This is separated from loadMCPConfig to allow easy unit testing
 */
export declare function applyEnvSubstitution(serverConfig: Omit<MCPServerStdioDefinition, "name">, name: string, baseEnv: Record<string, string | undefined>, envFileVars: Record<string, string>): MCPServerStdioDefinition;
/**
 * Discover and load MCP configuration from working directory
 */
export declare function loadMCPConfig(sys: DevToolsSys, workingDirectory: string): Promise<MCPServerStdioDefinition[]>;
