# Implementation Plan: External MCP Server Support

## Phase 1: Configuration & Data Modeling [checkpoint: 4ba1bd9]
- [x] Task: Define the schema for external MCP server configuration. [1c863f0]
    - [x] Update `src/models.py` to include `MCPServerConfig` and `MCPConfiguration` classes.
    - [x] Implement logic to load `mcp_config.json` from global and project-specific paths.
- [x] Task: Integrate configuration loading into `AppController`. [c09e0f5]
    - [x] Ensure the MCP config path is correctly resolved from `config.toml` and `manual_slop.toml`.
- [x] Task: Write unit tests for configuration loading and validation. [c09e0f5]
- [x] Task: Conductor - User Manual Verification 'Phase 1: Configuration & Data Modeling' [4ba1bd9]

## Phase 2: MCP Client Extension [checkpoint: 828fadf]
- [x] Task: Implement `ExternalMCPManager` in `src/mcp_client.py`. [828fadf]
    - [x] Add support for managing multiple MCP server sessions.
    - [x] Implement the `StdioMCPClient` for local subprocess communication.
    - [x] Implement the `RemoteMCPClient` for SSE/WebSocket communication (stub).
- [x] Task: Update Tool Discovery. [828fadf]
    - [x] Implement `list_external_tools()` to aggregate tools from all active external servers.
- [x] Task: Update Tool Dispatch. [828fadf]
    - [x] Modify `mcp_client.dispatch()` and `mcp_client.async_dispatch()` to route tool calls to either native tools or the appropriate external server.
- [x] Task: Write integration tests for stdio and remote MCP client communication (using mock servers). [828fadf]
- [x] Task: Conductor - User Manual Verification 'Phase 2: MCP Client Extension' [828fadf]

## Phase 3: GUI Integration & Lifecycle [checkpoint: 3b2588a]
- [x] Task: Update the **Operations** panel in `src/gui_2.py`. [3b2588a]
    - [x] Create a new "External Tools" section.
    - [x] List discovered tools from active external servers.
    - [x] Add a "Refresh External MCPs" button to reload configuration and rediscover tools.
- [x] Task: Implement Lifecycle Management. [3b2588a]
    - [x] Add the "Auto-start on Project Load" logic to start servers when a project is initialized.
    - [x] Add status indicators (e.g., color-coded dots) for each external server in the GUI.
- [x] Task: Write visual regression tests or simulation scripts to verify the updated Operations panel. [3b2588a]
- [x] Task: Conductor - User Manual Verification 'Phase 3: GUI Integration & Lifecycle' [3b2588a]

## Phase 4: Agent Integration & HITL [checkpoint: f4c5a0b]
- [x] Task: Update AI tool declarations. [f4c5a0b]
    - [x] Ensure `ai_client.py` includes external tools in the tool definitions sent to Gemini/Anthropic.
- [x] Task: Verify HITL Approval Flow. [f4c5a0b]
    - [x] Ensure that calling an external tool correctly triggers the `ConfirmDialog` modal.
    - [x] Verify that approved external tool results are correctly returned to the AI.
- [x] Task: Perform a final end-to-end verification with a real external MCP server. [f4c5a0b]
- [x] Task: Conductor - User Manual Verification 'Phase 4: Agent Integration & HITL' [f4c5a0b]
