A code map and memory for AI coding agents like Claude Code, served over MCP. Runs locally, no API key.
pip install knock-mcp==0.1.1 Copy PIP instructions
Stop paying your agent to re-read the same files every session. Knock first, then read only what matters.
Two real Claude Code sessions on Saleor, abridged: each side's median-cost run out of three. Results vary between runs and repositories; on a small, well-known repo the difference was within noise. Full numbers: docs/benchmark.md.
Every new chat with a coding agent starts with amnesia. To answer "where is X?" or "how do we deploy?" it greps, opens big files, reads them... and next session it does it all over again.
Median characters per task on the held-out benchmark (targeted-grep and grep-and-read baselines vs knock). Fewer characters ≠ an identical cut in your bill; see the FAQ.
You set knock up once, then you just keep using your AI agent as usual. The agent talks to knock in the background; you never have to run knock commands day to day.
claude mcp add knock -- uvx knock-mcp serve --repo . --toolset map This uses uv, which downloads and runs knock for you. No uv? Run pipx install knock-mcp (or pip install knock-mcp), then claude mcp add knock -- knock serve --repo . --toolset map.
--toolset map gives the agent three tools (map, open, remember) and is the setup measured in the results below. Leave it out to get the original eight tools.
That's the whole setup. The next time you open Claude Code in that project, knock reads the project and builds its notes automatically. This takes a few seconds for a small project and a minute or two for about 5,000 files; after that it only re-reads files that changed.
Ask your agent what you'd always ask. Here's what changes behind the scenes:
Nothing to maintain: when code changes, knock updates its notes, and flags anything that may be outdated.
Want knock to ignore some files? List them in a .knockignore file (same format as .gitignore).
Commit a .mcp.json file to your repo, and every teammate's Claude Code picks up knock automatically (each person needs knock installed):
{ "mcpServers": { "knock": { "command": "knock", "args": ["serve", "--repo", ".", "--toolset", "map"] } } } Each person's notes live on their own machine. Sharing findings across a team isn't supported yet (see Status below).
flowchart LR A["📁 Your repo
code · docs · configs · git log"] -->|"knock index
(only changed files)"| B["🗂️ Notes
file + lines + hash"] B --> C[("💾 SQLite
on your machine")] C -->|"map"| D["🤖 Your agent"] D -->|"open / Read
(verify the real lines)"| A D -->|"remember
(save what it learned)"| C Index: knock reads your repo without running anything in it. It writes short notes: what each module defines, what the docs say about setup and deployment, which tools and dependencies you use, why decisions were made, and which recent commits fixed bugs. Ask: your agent asks a question and gets a small, ranked answer with file:line pointers, instead of reading whole files. Verify: before editing, the agent reads just the lines it needs. The original files are always the source of truth. Remember: the agent saves what it learned. If those files change later, knock marks the note stale so nobody trusts outdated info. 🧰 What your agent gets With --toolset map (recommended):
On Flask, an agent is told: "sessions signed with an old key in SECRET_KEY_FALLBACKS are rejected after rotating SECRET_KEY".
{"category": "debugging", "content": "get_signing_serializer builds the key list as SECRET_KEY_FALLBACKS followed by SECRET_KEY; ordering was fixed in fb54159.", "sources": [{"path": "src/flask/sessions.py", "start_line": 317, "end_line": 335}]} The next session gets it instantly. If sessions.py changes, the note is flagged stale. 📊 Does it actually help? Measured with a reproducible benchmark: 12 engineering tasks per repo, covering architecture, finding a feature, deployment, bug investigation, design rationale and following conventions.
Held-out repo (full-stack-fastapi-template; knock was never tuned on it):
That's the goal, and the benchmark shows far less text reaching the agent. But your bill also includes system prompts, reasoning, and output, and prompt caching already discounts repeated input. Expect the biggest wins on exploration-heavy questions ("how does X work?", "where is Y?", "how do we deploy?"), and little on pure code-writing. Faster answers and memory across sessions are wins either way.
No. Indexing and search are fully deterministic and local. The only thing that uses an API is the optional benchmark.
Any agent that supports MCP over stdio. Verified: Claude Code (the session at the top of this page is a real recording of Claude using knock's tools) and the official MCP Python SDK client (all 8 tools, in the test suite). Cursor, Windsurf and others should work but are untested. Setup: docs/agents.md.
Every note is labelled with where it came from (extracted from docs, recorded by an agent, git history) and how fresh it is. Agents can mark a note as wrong, and it stays hidden until the source changes. The real file is always one get_source away.
No embeddings and no vector database. knock stores small structured facts that point back to exact lines, tracks when those lines change, and lets agents add what they learn. It's closer to a team wiki that maintains itself than to a search index.
knock is an early MVP (v0.1). What works today and what's next:
Issues and PRs are welcome. Start with CONTRIBUTING.md.
.venv/bin/pip install -e '.[dev]' && .venv/bin/pytest Deeper docs: Architecture · Security · Agents · Benchmark · Troubleshooting
All 2 files in this release have provenance metadata.
mcp model-context-protocol claude-code ai-agents code-map code-intelligence knowledge-base sqlite
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.
All 2 files in this release have been uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




