1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! MCP command handler — serves the Model Context Protocol over stdio.
use crateCli;
use crateKoiClient;
use cli_token;
/// Serve MCP over stdio.
///
/// Resolves the daemon endpoint the same way client-mode commands do:
/// 1. An explicit `--endpoint` (with `--token`/`KOI_TOKEN`, never the breadcrumb
/// token — it would leak to a remote host).
/// 2. The breadcrumb file the local daemon writes (endpoint + its token).
///
/// The MCP server probes the daemon per-tool and returns an actionable error if
/// it is unreachable, so we still serve even when no daemon is up yet (the host
/// may start one, or the agent may just call read tools that report the outage).
pub async
/// Build the `KoiClient` for the MCP server from CLI flags / breadcrumb / env.