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
//! # mcp-rtk
//!
//! A token-optimizing MCP proxy that sits between Claude and any upstream MCP
//! server, compressing tool responses to reduce token consumption by 60–90%.
//!
//! # Architecture
//!
//! ```text
//! Claude ←(stdio)→ mcp-rtk ←(stdio/subprocess)→ upstream MCP server
//! ```
//!
//! mcp-rtk is both an MCP **server** (for Claude) and an MCP **client** (for
//! upstream). It forwards `list_tools` and `call_tool` requests, applying JSON
//! compression filters on responses before returning them.
//!
//! # Modules
//!
//! * [`config`] — TOML configuration loading with per-tool filter rules and
//! external preset auto-discovery from `~/.local/share/mcp-rtk/presets/`.
//! * [`filter`] — The 8-stage filter pipeline and generic JSON compression
//! functions.
//! * [`hot_reload`] — File watcher that hot-reloads external presets and
//! atomically rebuilds the filter engine via [`arc_swap::ArcSwap`].
//! * [`proxy`] — [`ProxyServer`](proxy::ProxyServer) and
//! [`ProxyClient`](proxy::ProxyClient) implementing the MCP server/client
//! handlers.
//! * [`tracking`] — SQLite-backed token savings metrics.