IcyLoom
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@IcyLoomhow many tokens has the cache avoided this week?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
IcyLoom
One MCP server. One SQLite file. One ledger that tells you what it actually saved.
A local gateway that puts an LLM cache, a compressed context drawer and an MCP tool relay behind one MCP server, one configuration file and one SQLite database.
IcyLoom is a standalone project: no imports, links or paths to any other project. The code is written from scratch; the only files taken from elsewhere are data (normalisation rules, a tool registry), because the cache hash depends on them.
Cache | Every prompt normalised, hashed and stored. A hit is a zero-token answer. |
Context drawer | Sources filed, chunked, anchored, invariants checked — compressed on demand, opt-in. |
Tool relay | Downstream MCP servers, cached by canonical signature, deny by default. |
Registry |
|
Console | A hand-drawn web console on |
Privacy | Binds |
The numbers are real. A cache hit is counted as avoided, a miss is counted as paid with the upstream's own usage figures — never estimated. The 35 % threshold is read straight from the ledger.
Overview: the unified registry, five live KPIs, calls per bucket, latency, outcomes, models, upstreams.
Quick start
Three commands, and it works:
# 1. check that everything works, like a real client
.\.venv\Scripts\python.exe -m icyloom check
# 2. plug IcyLoom into your MCP client (writes the config on your machine)
.\.venv\Scripts\python.exe -m icyloom client --target cursor --install
# 3. read the config to paste (Claude Code, Claude Desktop, Cursor, Windsurf, Codex)
.\.venv\Scripts\python.exe -m icyloom client --target claudeicyloom check plays the role of the client: it starts the server, connects,
lists the 13 tools and calls them (ctx_store, ctx_search, ctx_verify,
cache, ledger, proxy_info). It tests the three transports (stdio,
streamable-HTTP, SSE) and prints 21/21 vérifications réussies when all is
well. If HTTP or SSE fails, the stack is not running (icyloom serve); the
stdio mode, on the other hand, is self-contained — it is the one Claude
Code and Cursor use.
For the HTTP gateway (your LLM client pointing base_url at IcyLoom)
and the web console:
.\.venv\Scripts\python.exe -m icyloom serve # 8150 / 8151 / 8152 / 8153D:\ICY-LOOM
icyloom.yaml single configuration (Pydantic)
data\ externalised data (JSON)
var\icyloom.db single SQLite database (WAL)
HTTP gateway :8150 MCP server (one build function)
/v1/chat/completions stdio dedicated process
/v1/messages streamable-HTTP :8151
/v1/models, /v1/embeddings SSE :8152
/{upstream}/v1/... 13 tools, one surface
cache -> routing -> upstream
admin API + dashboard :8153
gateway, MCP and admin all write to one database and one ledgerRelated MCP server: mcplex
Status (verified 2026-10-28)
This section is the honest summary. Details and raw numbers are in PROGRESS.md.
Area | Status |
Tool-result cache correctness (stale hits, replayed writes, cached errors, loop detection) | Verified. Synthetic harness: 0 stale hits out of 140 (before the fix: 425 out of 436). Real |
Test suite | All 131 tests pass |
Gateway latency | p50 13.5 ms (MISS) and 10.7 ms (HIT); p95 about 16 ms against a 200 ms budget |
Latency gain on a slow tool | One real |
Token savings on tool calls | Not delivered and not measured. A tool-cache hit is ledgered with 0 tokens saved |
Context compression | Opt-in, off by default. Large estimated token savings in a prototype, but answer quality is not proven (see Known limitations) |
The "50 percent tokens saved" printed by tests/proof_e2e.py is true by construction: that test sends every request twice. It is not a traffic figure and must not be quoted as one.
Getting started
cd D:\ICY-LOOM
.\.venv\Scripts\python.exe -m icyloom doctor # diagnostics
.\.venv\Scripts\python.exe -m icyloom serve # gateway + MCP + admin
.\.venv\Scripts\python.exe -m icyloom mcp --transport stdio # for an MCP client
.\.venv\Scripts\python.exe -m icyloom gateway # gateway only (8150)
.\.venv\Scripts\python.exe -m icyloom admin # admin API only (8153)An MCP client connects with a single entry, for example:
{ "mcpServers": { "icyloom": { "command": "D:\\ICY-LOOM\\.venv\\Scripts\\python.exe",
"args": ["-m", "icyloom", "mcp", "--transport", "stdio"] } } }An LLM client points its base_url at http://127.0.0.1:8150/v1.
The tool cache
IcyLoom relays calls to downstream MCP servers and can cache their results. The rules:
Deny by default. Only tools set to
truein a server'scache_toolsare ever replayed from the cache. There is no guessing from the tool name. A server withcache_enabled: trueand nocache_toolscaches nothing.State epoch per server. Any call that is not cacheable (a possible write) advances that server's epoch. The epoch is part of the cache key, so a read cached before a write is never served after it. The epoch also carries a boot token: the cache does not survive a relay restart, because the server may have changed while the relay was down.
Errors are never cached. A result flagged
is_erroris not stored.Schema-guided canonicalisation. A near-identical call is recognised only according to the tool's
inputSchema: integer, number and boolean parameters, and path-like string parameters. Without a schema, only an exactly identical call matches. Never: case changes, whitespace folding inside strings, reordering of lists. Schemas are loaded whenlist_toolsis called.The loop guard counts cache hits. A loop answered from the cache is still a loop: the 5th identical call within the window is blocked.
A batch stops at the first error. The remaining calls are reported as
skipped_after_error.
tool_proxy:
servers:
- name: fetch
command: uvx
args: ["mcp-server-fetch@2026.10.10"]
cache_enabled: true
ttl_seconds: 3600 # protects against changes made outside the relay
cache_tools:
fetch: true # explicit allowlist: nothing else is cachedThe TTL is the only protection against a downstream server whose state changes outside the relay. Choose it per server.
Loading tools fast
Two things make the relay quick to use, both verified by tools\proof_tools.py:
One live session per downstream server. The server process stays alive between calls instead of being respawned for every call. The session lives in its own thread and its own event loop, because the MCP SDK opens a stdio session inside an anyio task group that must be entered and left in the same task. Measured on a local server: the first call costs ~840 ms (process start), the next ones ~21 ms — 40× faster.
The tool catalogue is cached and searchable.
proxy_info(what="tools", server=…)lists the tools of a server and keeps the result (with theinputSchema) in memory;proxy_info(what="search", query=…)then finds a tool by name or description — "git" findsgit_log, "file" findsread_file. The catalogue is also loaded automatically on the first call to an unknown tool, because the schema is what makes the near-identical recognition possible.
.\.venv\Scripts\python.exe tools\proof_tools.py # 14 checks: near-hit, no false hit, reuse, searchThe schema-guided merge is deliberately conservative: limit: 10 and limit: "10" are one and the same call (the schema declares an integer), but " 8150 " and "8150" are not merged (a string is a value — the downstream tool answered "unknown port" for the padded one).
The console (dashboard)
A web console, served by the admin API, shows all metrics with matching charts:
http://127.0.0.1:8153/dashboard (alias: http://127.0.0.1:8153/).\.venv\Scripts\python.exe -m icyloom dashboard # URL + current state
.\.venv\Scripts\python.exe -m icyloom dashboard --serve # serve the consoleOne console, two consoles fused
The console is the merge of the IcyCache console and the Loom dash, rebuilt on the
unified registry v_token_ledger and drawn in the rough-sketch style (warm paper, brown
ink, hand-drawn strokes, hatched fills, stickers, doodles).
It is an application shell, not a long scrollable page: a side panel on the left switches the view, and the content area only ever renders the view you are on.
View | Fused from | Content |
Overview | IcyCache + Loom | 5 KPIs with sparklines, the unified registry card (tokens paid / avoided / baseline, latency avoided, 35 % threshold), calls per bucket, latency p50/p95, hit/miss donut, per-model breakdown, upstreams & clients |
Activity | IcyCache | 3D traffic mountain (day × hour, drag to rotate), topographic map with isolines, hourly traffic table, latest requests |
Economy | IcyCache + Loom | 14-day curve (paid vs avoided, hatched area, dashed average, circled record), gain gauge against the 35 % line, split of the baseline per domain, economy per day |
Cache | IcyCache | most reused entries (hatched pseudo-3D bars), searchable table of every stored prompt (hash, model, provider, hits) |
Context | Loom | sessions, sources, chunks, invariants, anchors, redactions, stored sources table, sources per session |
Tools | Loom | downstream MCP servers, calls per tool, tool cache (entries, bytes, latency avoided), per-tool breakdown |
Audit | Loom | live LLM journal and tool journal, both searchable |
Guide | IcyCache Help | request-path diagram, how to read the metrics, the 13 MCP tools, shortcuts & tips, live system state |
The side panel carries the eight views (each with its own live counter), the system
actions — Pause / Refresh / Export / Compact, which really act — and a live status card
(calls, hit rate, tokens avoided, gain, ledger rows, database size). A toolbar above the
content shows the current view, the LIVE state, the measured request rate and the event
count; the control bar holds the analysis window (1 h / 24 h / 7 d / 14 d — it really
changes the query), a Reconnect button and the live database pills.
Every button is wired to a real action: Pause freezes the figures (the polling stops, the
pill turns PAUSED), Refresh and Reconnect re-query the admin API, Export downloads the
exact JSON the page is drawing, Compact shrinks the layout for a laptop screen. Keyboard
shortcuts: 1…8 switch view, R refreshes, P pauses, E exports, C compacts.
The eight views: Activity (3D mountain + topo map), Economy (curve, gauge, split),
Cache (entries, ranking), Guide (path of a request). Context, Tools and Audit complete
the set — see docs/screenshots/.
Everything is computed in real time; no value is frozen in the page:
/api/dashboardis polled every 2 s; the server keeps the snapshot fresh in a background thread, so the answer is instant (≈ 10 ms) even on a busy base;requests/min is computed between two real samples and smoothed;
each value is interpolated toward its new target, so counters scroll instead of jumping;
the window and the pause button apply immediately;
every timestamp is UTC — one single clock, from the SQLite defaults to the charts.
The data comes from a single read-only route:
GET /api/dashboard -> { kpi, config, registry, surface, series, breakdown, tables, context, recent, db }registry is the unified v_token_ledger (cache + compression + tool tax, all in tokens),
surface is the day × hour traffic grid behind the 3D mountain and the map, series holds
the time series (per hour over 24 h, per day over 14 d). GET /api/gateway relays the
gateway's live state (circuits, upstreams) from port 8150 so the page stays on a single origin.
The console is self-contained: one HTML file, hand-written SVG charts and a hand-written
sketch engine (no rough.js, no framework), no external dependency, no CDN, no network call
except /api/dashboard. The tokens shown are the real tokens reported by the upstream.
Reference screenshots (1440 × 960) live in docs/screenshots/:
overview, activity, economy, cache, context, tools, audit, guide.
The logo is src/icyloom/static/logo.svg — the same file is
served by the console at http://127.0.0.1:8153/assets/logo.svg.
Demo data set (fake data, isolated stacks, ports 8150-8154):
.\.venv\Scripts\python.exe tools\seed_demo.py # continuous traffic, about 4 req/s
.\.venv\Scripts\python.exe tools\check_js.py # JavaScript syntax check of the consoleThe functional test campaign
Re-run on 2026-10-28 with the current code: 88/88 checks green (report in var\campaign-report.json).
A hermetic campaign that exercises every layer on an isolated stack (ports 8160-8164, temporary database), with entirely different inputs: 24 distinct prompts, 6 distinct documents, 3 distinct markers, 3 distinct tool calls:
.\.venv\Scripts\python.exe tools\campaign.py # report + var\campaign-report.jsonIt covers the cache (variants, anti-collision, key scope), the ledger (real tokens, gain), the context drawer (byte-exact, invariants, discriminating search, isolated sessions), the tool relay, the gateway formats (OpenAI, Anthropic, SSE streaming), MCP HTTP/SSE parity, the safeguards (confirmation, concurrency) and the consistency of the console with the database. Output: one verdict per check and a non-zero exit code at the first failure.
Two blocks play the role of an agent doing real work:
N, agentic work: the agent looks up its spec in the drawer, files a real document, asks 8 really different requests (plan, risks, test, talk, threat, rollback, measure, strategy), iterates one request ("v1" then "v2"), then calls 6 distinct downstream tools and closes with an invariants check.
O, anti-mixing: interleaved requests and tools, purge, replay.
To prove that a hit returns the right answer, the campaign uses tools/echo_upstream.py: the upstream returns the fingerprint of the request it received (echo:<sha256>). An answer served from the cache therefore carries the fingerprint of its own request, never another one's.
The 13 tools
Tool | Role | Destructive action |
|
|
|
| relay to downstream MCP servers, in a batch (stops at the first error) | none |
|
| none |
| purge the tool cache | yes, needs |
|
| none |
| re-reads the original bytes (byte-exact) | none |
| search the drawer | none |
| proof that no invariant was lost | none |
| loss and fidelity check | none |
|
| none |
|
|
|
|
|
|
|
| none |
Every tool carries ToolAnnotations (read-only, destructive, idempotent, open-world). A destructive action without confirm=true is refused with no side effect.
Capability map: tools and routes
(Capabilities from spec section 5. ✔ = covered and tested · ◐ = partly covered · ✘ = not implemented, announced)
Cache and network
# | Capability | Where |
A1 | OpenAI |
|
A2 | Anthropic |
|
A3 |
|
|
A4 | routing |
|
A5 | priority: URL prefix > header > body > default, plus |
|
A6 | canonical normalisation + hash |
|
A7 | LLM cache (TTL, LRU, cap) |
|
A8 | semantic cache (Qdrant) | ✘ opt-in, not implemented (config and cache key ready) |
A9 | real tokens (never estimated on the upstream side) |
|
A10 | prefix cache | ◐ |
A11 | tool relay (single + batch) |
|
A12 | tool cache: per-server TTL, deny-by-default allowlist, state epoch, no cached errors, schema-guided canonicalisation |
|
A13 | loop guard (counts cache hits) |
|
A14 | resilient pool: drain, recycle, retry |
|
A15 | circuit breaker with real re-arming |
|
A16 | WebSocket | ✘ not implemented |
A17 | REST API (health, status, metrics, cache-clear, tools, ledger...) |
|
A18 | HTML dashboard |
|
A19 | stdio / SSE / streamable-HTTP transports |
|
A20 | tool registry, assertion |
|
A21 | IcyCache's 11 tool-relay tools | merged into the 13 ( |
A22 | CLI |
|
A23 | cache warm-up ( | ✘ not implemented |
A24 | stdout = pure JSON-RPC, logs on stderr, UTF-8 forced |
|
Context
# | Capability | Where |
B1 | 17 context tools | merged into the 13 ( |
B2 | 3 profiles, |
|
B3 | invariants (numbers, paths, URLs, versions, fingerprints, ports, dates, constraints) |
|
B4 |
|
|
B5 | FTS5 drawer + search |
|
B6 | UUIDv7 sessions, TTL, isolation, purge |
|
B7 | cross-session transfer |
|
B8 | database / column encryption | ✘ not implemented |
B9 | secret redaction before storage |
|
B10 | fail-closed sandbox |
|
B11 | rate limiting |
|
B12 | JSONL audit + rotation |
|
B13 | auto-store of a tool output | ✘ not implemented (threshold exposed in the config) |
B14 | FAISS vector index | ✘ opt-in, not implemented |
B15 | admin CLI (health, stats, sessions, vacuum, purge) |
|
B16 | dashboard |
|
The ledger
A single ledger_entries table records everything that costs and everything that saves: LLM calls (real upstream tokens), cache hits, context compression, tool calls. The 35 % threshold is readable there continuously:
tokens saved / (tokens paid + tokens saved)The tokens of an LLM cache hit are the real tokens measured on the original call: they are never estimated. Compression tokens come from the local counter (tiktoken if available, otherwise an estimator), and the counter used is recorded in every entry.
Tool path: a tool-cache hit is ledgered with saved_latency_ms only; tool_tokens_saved is 0. The tool cache saves latency, not tokens.
Known limitations
No measured token savings on tool calls. See the Status section.
Compression quality is not proven. In a prototype run on a real model (carried over from earlier notes, details in
PROGRESS.md), estimated prompt tokens dropped by about 84 to 92 percent, but the model answered incorrectly: the anchor keeps only a header, the invariants and the first 800 characters, so a key line in the middle of a log was lost. Compression therefore stays opt-in; "strict" guarantees that the invariants are kept, not that the text the model sees is unchanged.The gateway cache uses one slot per key shared by JSON and streaming responses, so a streamed request can miss a hit created by the JSON one.
An upstream
ReadTimeoutduring streaming is not caught ingateway.py(around line 578) and can end a client run.The tool-cache epoch is verified on a synthetic server; a real server with both reads and writes has not been tested yet.
Downstream state that changes outside the relay is only covered by the TTL.
Design decisions
One MCP server, two HTTP processes.
mcp>=1.2,<2exposes one transport per instance: HTTP and SSE are therefore two instances built by the same function (build_server), which guarantees an identical tool surface. stdio stays a dedicated process.Own environment variables.
ICYLOOM_CONFIG,ICYLOOM_HOME,ICYLOOM_STATE_DIR. The historical names from other projects are not reused: the project is independent.Ports 8150-8153 strictly reserved, bound to
127.0.0.1; tests run on 8154-8159.One transaction per request. Cache, LLM journal and ledger are written in one transaction: three successive transactions cost about 20 ms per request, more than the gain from the cache.
Circuit breaker really re-armed: after
reset_secondsthe state becomes half-open and one probe is allowed.Upstream failover: a failing upstream no longer permanently excludes the others; the priority is never mutated during a call.
Compression off by default,
strictprofile, never lossy implicitly.Fail-closed sandbox: without an allowed directory, no command is run.
Tool cache: deny by default, with a per-server state epoch (see The tool cache).
No git repository for now: the licence is still undecided, so the project is not published. The safety net is a folder copy.
Cache hash compatibility
The normalisation engine follows the reference semantics (NFKD, lowercase, Aho-Corasick rules, number-words, diacritics, sentence punctuation). Operators are kept (12+2 is not 1+22), and volatile fields (stream, user, metadata) are excluded from the key.
Measured on the historical cache (read-only): 70 % of normalised texts coincide. The remaining 30 % were written by an earlier version of the engine that removed :, /, +, * and did not convert numbers to words. Those entries are already incompatible with the reference engine; honouring them would break compatibility with the current engine. tests/test_normalize.py measures this agreement and checks the equivalence between the fast engine and an independent naive implementation.
Tests
.\.venv\Scripts\python.exe -m pytest tests\ -q --ignore=tests\proof_e2e.py # 102 tests
.\.venv\Scripts\python.exe tests\proof_e2e.py # end-to-end proof
.\.venv\Scripts\python.exe tests\test_cache_correctness.py # stale-hit measurement (prints a report)
.\.venv\Scripts\python.exe tests\real_mcp_fetch.py # real MCP server; needs uvx and Internetproof_e2e.pystarts a fake upstream on 8154, launches the stack on 8150-8153, checks the 4 services, verifies the tool list over HTTP and SSE, then measures latency over 200 requests (direct / MISS / HIT) and the ledger gain. Its "50 %" gain is by construction (every request is sent twice).test_cache_correctness.pyruns a stateful fake tool server under interleaved reads and writes and compares every cached answer with the server's true state. Run it as a script to get the numbers, or through pytest for strict thresholds (zero stale hits).real_mcp_fetch.pydrives the realmcp-server-fetchthrough the relay: schema capture, MISS then HIT, integer canonicalisation, no merge across different URLs, a real error never replayed.Tests use a temporary database and never touch
var\icyloom.db. SetICYLOOM_TEST_PORTto run the suite while a stack occupies 8154.
Layout
D:\ICY-LOOM\
├── icyloom.yaml single configuration
├── pyproject.toml package (requires-python >=3.11,<3.14)
├── LICENSE MIT
├── README.md
├── PROGRESS.md what is proven, what is not, what is next
├── MERGE_PLAN.md the merge plan (IcyCache + Loom -> IcyLoom)
├── RESEARCH.md the research notes behind the choices
├── ICYLOOM_PROMPT.md the original brief
├── docs\
│ ├── logo.png the mark (source: src\icyloom\static\logo.svg)
│ └── screenshots\ the eight console views
├── data\
│ ├── normalization_rules.json 1122 rules (data)
│ └── tools_registry.json 100 anchors (data)
├── src\icyloom\
│ ├── cli.py doctor / paths / version / config / serve / ...
│ ├── config.py Pydantic models of the single configuration
│ ├── paths.py path resolution (no hard-coded path)
│ ├── logsetup.py logs on stderr, UTF-8 forced
│ ├── db.py single database: schema, WAL, additive migrations
│ ├── normalize.py normalisation + cache key
│ ├── cache.py LLM cache (TTL, LRU)
│ ├── upstream.py multi-upstream routing
│ ├── pool.py HTTP pool: drain -> recycle -> retry
│ ├── breaker.py circuit breaker with real re-arming
│ ├── gateway.py OpenAI/Anthropic HTTP gateway
│ ├── admin.py admin API + metrics + console + /assets/logo.svg
│ ├── dashboard.py metrics aggregate (read-only snapshot)
│ ├── static\ web console (HTML + SVG, self-contained) + logo.svg
│ ├── mcpserver.py single FastMCP instance + 13 tools
│ ├── toolproxy.py tool relay + cache (deny-by-default, epoch) + loop guard
│ ├── ledger.py single economic journal
│ ├── tokenizer.py local token counter (tiktoken or estimator)
│ ├── migrate.py additive migration (sources read-only)
│ ├── runner.py combined launcher
│ └── context\ drawer, anchors, invariants, verification, sandbox...
├── tools\
│ ├── seed_demo.py demo data set (real traffic, isolated stack)
│ ├── spread_demo.py deterministic time-spreading of the demo events
│ ├── campaign.py hermetic functional campaign (88 checks)
│ ├── check_js.py JavaScript syntax check of the console
│ ├── fake_mcp_server.py fake downstream MCP server (relay target)
│ ├── run_fake_upstream.py fake OpenAI/Anthropic upstream
│ └── proof_tools.py, report_live.py, report_tools.py, diag_norm.py, ...
└── tests\ test suite, end-to-end proof, correctness harness, real-server testProject map
Everything points at everything else:
Document | What it answers |
What IcyLoom is, how to run it, what it measures | |
What is proven, what is not, what is next | |
How IcyCache and Loom were merged into one project | |
The research behind the technical choices | |
The original brief this project answers | |
MIT | |
The mark (source: | |
The eight console views, 1440 × 960 |
The console is the living version of this README: it reads the same
v_token_ledger the ledger section describes, through the same
GET /api/dashboard route.
License
MIT — see LICENSE.
Copyright (c) 2026 Malik Belkacemi.
This server cannot be deployed
Maintenance
Related MCP Connectors
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
AI Reasoning Cache & Consensus Layer with 11 MCP tools via Streamable HTTP.
Private-by-default, local-first memory/context/task orchestrator for MCP apps and agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCPGate aggregates multiple MCP servers into a single unified endpoint, enabling centralized tool management with granular filtering, automatic namespacing, and observability. Features a real-time web dashboard and optional PostgreSQL-backed audit trails for monitoring and controlling AI tool access across local and remote deployments.4 npmApache 2.0
- AlicenseAqualityAmaintenanceSemantic tool-routing gateway for MCP servers that cuts 70-90% of context tokens, with RBAC, API-key auth, response caching, hot-reload config, and a real-time observability dashboard.313MIT
- AlicenseNot gradedqualityBmaintenanceSelf-hosted MCP gateway that applies deterministic, compiled policy to tool discovery, invocation, and outbound data flow, with no model in the enforcement path. Every decision emits a hash-chained receipt sealed with Ed25519 and verifiable using public keys only.Apache 2.0
- AlicenseNot gradedqualityCmaintenanceA local-first MCP server that reduces LLM token usage by intercepting, deduplicating, compressing, and optimizing MCP tool calls and responses.3 npmMIT