Files
IdeA/crates/infrastructure/src/orchestrator/mcp/mod.rs
Blomios 37e72747d3 feat(agent): orchestration v3 — surface MCP model-agnostic (M0→M4) — §14.3
Expose l'orchestration IdeA comme serveur MCP par-dessus le même
OrchestratorService::dispatch, avec repli fichier .ideai/requests pour les
CLI sans MCP. v3 réduite à la surface MCP : la messagerie inter-agents et la
corrélation requête↔réponse étaient déjà résolues par §17 (send_blocking).

- M0 capacité MCP sur le profil (McpCapability/McpConfigStrategy/McpTransport)
- M1 injection conf MCP au LaunchAgent + prose adaptée selon la surface
- M2 serveur/adapter MCP (JSON-RPC 2.0 maison ; outils idea_*) + ListAgents
- M3 câblage par projet (registre mcp_servers jumeau du watcher)
- M4 observabilité UI : OrchestratorRequestProcessed.source = file|mcp + badge

Trois portes d'entrée (fichier, MCP, UI) → un seul dispatch ; aucun nouveau
port applicatif ; MCP confiné à l'adapter infra. Tous lots verts (cycle §3).
Cadrage : .ideai/briefs/orchestration-v3-cadrage.md ; ARCHITECTURE.md §14.3.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 12:53:31 +02:00

42 lines
2.1 KiB
Rust

//! IdeA **MCP server** — a driving adapter that exposes the orchestration of IdeA
//! as Model-Context-Protocol tools (cadrage `orchestration-v3`, lot **M2**).
//!
//! This adapter is the **pair of the filesystem watcher**
//! ([`super::FsOrchestratorWatcher`]): a second, substitutable entry door onto the
//! exact same [`application::OrchestratorService::dispatch`]. An MCP-capable CLI
//! (Claude, Codex, Gemini…) calls a typed `idea_*` tool instead of dropping a JSON
//! file under `.ideai/requests`; the resulting [`domain::OrchestratorCommand`] and
//! its [`application::OrchestratorOutcome`] are identical. The server **invents no
//! semantics** and **never re-routes** a reply (Décision 2 + principe directeur).
//!
//! ## Spike S-MCP — what is confined here
//!
//! Everything MCP/JSON-RPC/transport lives in this module and **nowhere else**;
//! the domain and application layers never see it:
//! - [`jsonrpc`] — a hand-rolled JSON-RPC 2.0 message model + a [`jsonrpc::Transport`]
//! seam (no MCP crate; chosen for zero-network testability — see its docs),
//! - [`transport`] — the `stdio` default transport + an in-memory scriptable
//! transport for tests (a `socket` transport is a documented TODO),
//! - [`tools`] — the tool catalogue and the tool → `OrchestratorCommand` mapping
//! (reusing [`domain::OrchestratorRequest::validate`] as the one validator),
//! - [`server`] — [`McpServer`], the request loop over the transport.
//!
//! ## Testability
//!
//! [`McpServer::handle_raw`] turns one raw JSON-RPC message into its response with
//! no I/O, and [`transport::MemoryTransport`] scripts a whole session in memory, so
//! the agent of Test can cover the adapter **entirely off-network** (no socket, no
//! child process).
pub mod jsonrpc;
pub mod server;
pub mod tools;
pub mod transport;
pub use jsonrpc::{
JsonRpcError, JsonRpcRequest, JsonRpcResponse, Transport, TransportError, JSONRPC_VERSION,
};
pub use server::McpServer;
pub use tools::{catalogue, map_tool_call, tool_returns_reply, ToolDef, ToolMapError};
pub use transport::{MemoryTransport, StdioTransport};