mcpField
S
Semantic Cache MCP

Semantic Cache MCP

Local
github.com/CoderDaytonDeveloper Tools3Updated 5d ago

About Semantic Cache MCP

Semantic Cache MCP is a local file cache for coding agents that reduces repeat-read output by returning unchanged status or diffs. It also provides file search and editing tools through MCP, with data stored in SQLite.

Key features

  1. 01Hash-based repeat reads
  2. 02Changed-line diffs
  3. 03grep, BM25 search, and glob
  4. 04Atomic edits with dry_run
  5. 05Token-budgeted batch reads

Use cases

  1. 01Avoid resending unchanged files
  2. 02Review only lines changed since a read
  3. 03Search and edit files from a coding agent

MCP support

It runs as an MCP server and exposes file reading, searching, and editing tools to MCP clients. A shared local daemon can serve clients on the same machine.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"coderdayton-semantic-cache": {
"command": "uvx",
"args": [
"semantic-cache-mcp"
]
}
}
}
Run commanduvx semantic-cache-mcp

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
pypisemantic-cache-mcp0.7.0

Tools

14

Saved tool list · updated 5d ago

ParameterTypeRequiredDescription
pathstringYesFile path (absolute, or relative to the project root). Use an absolute path for files outside the project root.
limitanyNoNumber of lines to return starting at `offset`.
offsetanyNo1-based first line for a ranged read; omit or pass 0 to start from the first line.
outlinebooleanNoReturn the file's definitions and their line numbers instead of its text. Cannot be combined with `offset`/`limit`.
max_sizeintegerNoByte threshold above which a map of the file is returned instead of its text; read exact lines with `offset`/`limit`.
known_hashanyNoThe `content_hash` from your last read of this file — or the `coverage_token` from your last ranged read of it — passed back to get `"unchanged"` instead of the content re-sent. Omit only on a first read, or when you no longer hold what it vouches for.
line_numbersbooleanNoPrefix each line of a ranged read with its number. Costs about 17% more tokens; the range is in `lines` either way. Requires `offset` or `limit`.

Details

From the project README

Semantic Cache MCP Logo

Semantic Cache MCP

Stop paying for the same file twice.
An MCP file cache for AI coding agents: a re-read costs ~40 tokens instead of the whole file.

PyPI version PyPI downloads Python 3.12+ License: MIT

Semantic Cache MCP on Glama   Support on Ko-fi


Coding agents read the same files over and over: before an edit, after an edit, after every context compaction. A built-in Read sends the whole file each time. Semantic Cache MCP knows what your agent already holds. Measured on one 7,891-token file:

ReadBuilt-in ReadSemantic Cache MCP
First read7,891 tokensfull file, plus a hash
Re-read, file unchanged7,891 tokens77 tokens
Re-read after a one-line edit7,891 tokens137 tokens (a diff)

Across a 48-file project it saves 98.7% of re-read tokens, and an unchanged read takes 0.17 ms. It also gives your agent grep, BM25 search and glob over the cache, atomic edits with dry_run, and token-budgeted batch reads. Three runtime dependencies, no API keys, no GPU.

Quick start

You need uv. In Claude Code:

claude mcp add semantic-cache --scope user -- uvx semantic-cache-mcp

Any other client (Cursor, Claude Desktop, and others that take mcpServers JSON):

{
  "mcpServers": {
    "semantic-cache": {
      "command": "uvx",
      "args": ["semantic-cache-mcp"]
    }
  }
}

Configs for VS Code, Codex and OpenCode, and how to turn off the built-in file tools so the agent uses the cache: docs/clients.md.

How it works

Every file the server sends comes with a content_hash. The agent passes it back as known_hash on the next read:

flowchart LR
    R["read(path, known_hash)"] --> M{"hash matches<br/>the file now?"}
    M -- yes --> U["unchanged<br/>~40 tokens"]
    M -- "no, older version" --> D["diff of changed lines"]
    M -- "no hash" --> F["full file + content_hash"]
  • No stale content. Every read checks the file on disk first. unchanged only answers when the hash matches the current bytes.
  • Forgetting is safe. After a compaction, the agent reads without the hash and gets the full file back.
  • Large files become maps. A file over max_size returns an outline of its definitions, not a blind cut.
  • Everything stays local. The cache is a SQLite file. One background daemon serves every client on your machine.

Tools

read · batch_read · read_image · write · edit · batch_edit · edit_preview · delete · warm · grep · search · glob · stats · clear

Parameters and examples: docs/tools.md.

FAQ

Is the search "semantic" in the embeddings sense? No. search is BM25 keyword ranking and grep is exact. No model to download, no GPU, no API key.

Does it send my code anywhere? No. The only network request is a one-time download of the o200k tokenizer file, checked against a SHA-256 hash.

Does it work on Windows? Yes. CI runs on Linux and macOS.

Documentation

GuideCovers
ClientsSetup for each client, turning off built-in file tools
ToolsEvery tool, with parameters and examples
Environment VariablesEvery setting, with defaults
PerformanceBenchmarks and methodology
ArchitectureStorage, algorithms, the shared daemon
SecurityThreat model, size limits, path handling
TroubleshootingCommon issues, debug logging
Advanced UsagePython API

Contributing

git clone https://github.com/CoderDayton/semantic-cache-mcp.git
cd semantic-cache-mcp
uv sync --extra dev
uv run pytest

See CONTRIBUTING.md. Issues and pull requests are welcome.

License

MIT.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.