Files
IdeA/crates/infrastructure/src/orchestrator/mcp/mod.rs
Blomios ef84d5cc49 feat(backend): MCP d'édition de templates (#81)
Ajoute le MCP dédié à l'édition de templates : catalogue et classification
des templates (mcp/templates.rs infrastructure + app-tauri), use cases et
provider (application/template), enforcement de la policy des tools (mod.rs,
server.rs, tools.rs), avec la parité côté chemin OpenAI-compatible
(openai_tools.rs x2).

Lots B1 (catalogue/classification), B2 (use cases/provider) et B3
(enforcement policy) livrés en un seul commit cohérent.

QA vert (seul l'échec de bind loopback #80, connu et non-régression, écarté).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-20 18:45:02 +02:00

48 lines
2.3 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 policy;
pub mod server;
pub mod templates;
pub mod tickets;
pub mod tools;
pub mod transport;
pub use jsonrpc::{
JsonRpcError, JsonRpcRequest, JsonRpcResponse, Transport, TransportError, JSONRPC_VERSION,
};
pub use policy::ToolPolicyRegistry;
pub use server::McpServer;
pub use templates::{TemplateToolError, TemplateToolProvider};
pub use tickets::{TicketToolError, TicketToolProvider};
pub use tools::{catalogue, map_tool_call, tool_returns_reply, ToolDef, ToolMapError};
pub use transport::{MemoryTransport, StdioTransport};