# Specification: External MCP Server Support

## Overview
This feature adds support for integrating external Model Context Protocol (MCP) servers into Manual Slop. This allows agents to utilize tools from a wide ecosystem of MCP servers (like those for databases, APIs, or specialized utilities) alongside the application's native tools.

## Functional Requirements
- **Server Protocol Support:**
    - **Local Stdio:** Support for launching local subprocesses and communicating via JSON-RPC over stdio.
    - **Remote (SSE/WS):** Support for connecting to remote MCP servers via Server-Sent Events or WebSockets.
- **Flexible Configuration:**
    - The path to the MCP configuration file (e.g., `mcp_config.json`) must be configurable globally in `config.toml`.
    - Support for per-project overrides in `manual_slop.toml` to specify a project-specific MCP configuration.
- **Lifecycle Management:**
    - Provide a "Auto-start on Project Load" checkbox for each configured MCP server (or as a global/per-project default).
    - If enabled, the server starts automatically when the project is loaded.
    - If disabled, servers should be initialized on-demand or via a manual "Start" button in the GUI.
- **Tool Discovery & UI Integration:**
    - Automatically discover tools from configured servers using the MCP `listTools` capability.
    - Display discovered tools in a unified "External Tools" section within the **Operations** panel.
    - Ensure external tools are correctly mapped to agent tool declarations (Gemini, Anthropic, etc.).
- **Security & HITL:**
    - All tool calls from external MCP servers must adhere to the application's existing Human-in-the-Loop (HITL) approval mechanism.
    - Users must review and approve the parameters of any external tool call before execution.

## Non-Functional Requirements
- **Performance:** Asynchronous communication with MCP servers to avoid blocking the main GUI thread.
- **Robustness:** Gracefully handle server connection failures, timeouts, and process crashes.
- **Scalability:** Support for multiple external MCP servers simultaneously.

## Acceptance Criteria
- [ ] Users can specify an MCP config path in `config.toml` and `manual_slop.toml`.
- [ ] The GUI lists tools from configured external servers in a unified section.
- [ ] Selecting an external tool correctly generates a tool call for the AI.
- [ ] Approving an external tool call successfully executes it via the MCP bridge and returns the output to the AI.
- [ ] Local stdio servers and remote SSE/WS servers are both functional.

## Out of Scope
- Support for MCP Resources or Prompts (focusing strictly on Tools for this track).
- Managing installation of external MCP server dependencies (e.g., `npm install`, `pip install`).
