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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! MCP HTTP server: axum app, routes, and `serve()`.
//!
//! # Transport
//!
//! Implements MCP Streamable HTTP transport (the standard as of late 2025 /
//! early 2026). A client sends `POST /mcp` with a JSON-RPC 2.0 body; the
//! server replies with a single JSON-RPC response (`application/json`).
//!
//! The optional `GET /mcp` passive event stream (server-pushed SSE) is not
//! implemented yet.
//! TODO(mcp-spec): implement SSE push if the live spec mandates it for
//! conformance.
//!
//! # Authentication
//!
//! All routes pass through the [`crate::mcp::auth::api_key_middleware`].
//! The middleware is a no-op when `QUELCH_MCP_API_KEY` is not set.
use Arc;
use ;
use crateCosmosBackend;
use crateSchemaCatalog;
use crateSearchToolConfig;
use crateSearchApiAdapter;
// ---------------------------------------------------------------------------
// Server state
// ---------------------------------------------------------------------------
/// Shared state injected into every request handler.
// ---------------------------------------------------------------------------
// Router
// ---------------------------------------------------------------------------
/// Build the axum `Router` for the MCP server.
///
/// Accepts `ServerState` as shared state; passes all routes through
/// `api_key_middleware`.
// ---------------------------------------------------------------------------
// Serve
// ---------------------------------------------------------------------------
/// Start the MCP HTTP server and block until it receives a shutdown signal
/// (SIGINT / Ctrl-C) or fails.
///
/// # Arguments
///
/// * `state` — pre-built `ServerState`.
/// * `bind_addr` — e.g. `"0.0.0.0:8080"`.
pub async