1# mcp
2
3The estate's MCP layer over [`rmcp`](https://github.com/modelcontextprotocol/rust-sdk).
4A project depends on this crate and never names `rmcp`, so the SDK's version,
5fork and features are decided in one place, `../Cargo.toml`.
6
7## Serving a command enum
8
9A project that already takes commands as a serde enum gets an MCP server with
10no code per command:
11
12```rust
13/// Commands the daemon takes.
14#[derive(Deserialize, JsonSchema)]
15#[serde(tag = "type", rename_all = "snake_case")]
16enum Command {
17    /// Focus the column to the left.
18    FocusLeft,
19    /// Resize the focused column.
20    Resize {
21        /// Width delta in pixels.
22        delta: i32,
23    },
24}
25
26CommandServer::new(identity, "type", |command: Command| async move {
27    send_to_daemon(command).await // Result<serde_json::Value, String>
28})?
29.without(&["subscribe"]) // commands that are not one call, one answer
30.serve_stdio()
31.await?;
32```
33
34Each variant is a tool named by its tag value. Its doc comment is the
35description, and its fields, with their doc comments, are the arguments. A
36variant added to the enum is a tool the next time the server starts.
37
38| File | What it holds |
39|---|---|
40| `src/reflect.rs` | A tagged enum's JSON Schema read as a list of tools, and a call turned back into a command. No `rmcp` types. |
41| `src/server.rs` | `CommandServer`: those tools served over stdio. The only file that touches `rmcp`. |