FAISS, call graph, AST, BM25 β 34 MCP tools for AI agents. 50-80% token reduction. Offline.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste into ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
mcp-name: io.github.ashlesh-t/cognirepo
Persistent memory and context for any AI tool. Not a chatbot β infrastructure.

lookup_symbol returns file:line very quickly β grep takes 2β8 seconds. On Python repos β₯ 15K LOC, CogniRepo cuts AI coding agent token usage by 50β80% compared to raw file reads β benchmarked on Flask, FastAPI, Celery, and Ansible (1,800+ files). Works with Claude Code, Cursor, and Gemini CLI. Fully offline. No API keys required for indexing or any of the 34 MCP tools.
Every AI conversation starts from zero. Claude, Cursor, Gemini β none of them remember what you fixed yesterday, which files relate to which features, or what decisions were made last sprint. CogniRepo fixes that.
It sits between your codebase and any AI tool, providing:
Every AI tool that connects gets the same accumulated project knowledge. Memory persists across sessions, across tools, across time.
Most effective on codebases β₯ 15K LOC. On small repos (< 10K LOC), native file reads are fast enough that the MCP tool schema overhead (~4,100 tokens for 34 tools) takes more than you save. Break-even is roughly 4 tool calls on a medium-sized repo.
CogniRepo vs. claude-context / similar tools:
| Feature | CogniRepo | claude-context / similar |
|---|---|---|
| Pure code retrieval | β (FAISS + graph + AST) | β Often faster on first use |
| Episodic memory (what happened last sprint) | β Persistent BM25 + vector | β |
| Cross-agent handoff (Claude β Gemini β Cursor) | β last_context.json shared | β |
| User behaviour profile (adapts depth/style) | β get_user_profile() | β |
| Error pattern avoidance (learns from past fails) | β record_error() | β |
| Architectural decision records | β record_decision() | β |
| Multi-repo org graph (microservices) | β CHILD_OF / CALLS_API edges | β |
Conclusion: prefer CogniRepo when you value institutional memory across sessions. Use simpler tools when you just need one-shot code retrieval on a small codebase.
Benchmarked across 6 real open-source repos (FastAPI, Flask, Celery, Ansible, Moby/Docker, Kubernetes) using 30 structured prompts tested against Claude, Gemini, and Cursor/Codex.
| Metric | Value | Notes |
|---|---|---|
| Token reduction β Python repos | 50β84% | FastAPI FA-2: 12 000 β 2 500 Β· FA-4: 2 000 β 450 Β· FL-4: 8 000 β 1 250 |
| Token reduction β average (all tested) | ~60% | Across FA/FL/CE/AN where both baselines were captured |
| Token reduction β complex dynamic codebases | 20β35% | Celery CE-4/CE-5; deep async/dynamic-dispatch patterns reduce gains |
| Symbol lookup latency | < 1 ms | vs. grep at 2β8 s on large repos |
| Accuracy vs. baseline | equal or better in 100% of tests | No regression observed; FA-2 accuracy improved Moderate β High |
| Cross-agent context handoff | β validated | CE-4: Claude primed index, Gemini CLI consumed it β 35% token saving, same accuracy |
| Dynamic dispatch coverage | honest gap | CE-3 (APScheduler beat dispatch) returned NA for both; CogniRepo does not fabricate call chains |
| Go/multi-language coverage | partial | Moby MO-2 showed 67% savings; MO-3-5 / K8-* incomplete pending Go grammar improvements |
Honest limits: CogniRepo adds the most value on Python repos with clear static structure. Dynamic dispatch patterns (Celery beat, plugin registries), deep Go codebases, and Ansible's 22-level variable precedence chains reduce retrieval confidence. The tool reports uncertainty rather than hallucinating call chains.
Indexed 4 real repos, measured with cognirepo index-repo + cognirepo benchmark --json. CPU-only, no GPU.
| Repo | Files | Lookup latency | Token reduction | context_relevance |
|---|---|---|---|---|
| flask | 83 | 0.005 ms | 97.7% | 21.8% |
| fastapi | 1,122 | 0.002 ms | 98.6% | 36.0% |
| celery | 416 | 0.003 ms | 99.1% | 39.8% |
| ansible | 1,813 | 0.018 ms | β | β |
Lookup latency < 0.1 ms on all repos. Precision@k re-validated after v1.1.3 benchmark fix β see docs/METRICS.md for full numbers and methodology.
Run cognirepo benchmark on your own codebase to reproduce. See docs/METRICS.md.

cognirepo ask):
ANTHROPIC_API_KEY, GEMINI_API_KEY, OPENAI_API_KEY, or GROK_API_KEY.
Indexing, memory, summarization, and all MCP tools work fully offline.That's it. cognirepo setup handles the rest β it installs optional extras (languages,
security, providers) via pipx inject automatically when you enable them in the wizard.
Why pipx? It creates an isolated venv for cognirepo automatically so
fastembedand all deps install cleanly. Thecognirepocommand is then globally available in every directory β no per-repo venv needed.Arch Linux / Debian 12+ / Ubuntu 24.04+: Do NOT
pip installinto system Python. These distros enforce PEP 668 and block system-wide pip installs. Use pipx.
Note: CPU-only embeddings are the default (fastembed/ONNX, no PyTorch/CUDA required). For GPU:
pipx inject cognirepo 'cognirepo[gpu]'then install torch separately.
First-time setup:
cognirepo init+cognirepo index-repo .must complete before MCP tools (context_pack,lookup_symbol,who_calls, etc.) return data.
Run cognirepo init inside your project β it asks if you want to configure Claude and
automatically writes .claude/CLAUDE.md and .claude/settings.json with the correct
project-locked connector.
Each project gets its own isolated connector named cognirepo-<project>:
The --project-dir flag locks the MCP server to that project's .cognirepo/ directory.
When Claude has multiple projects open simultaneously, each connector reads only its own
memories β never mixing data across projects or teams.
All 34 tools are available to Claude, Cursor, and any MCP-compatible client.
| Tool | Description | When to use |
|---|---|---|
context_pack(query, max_tokens=2000) | Token-budget code + memory context | Every session β FIRST call before any file read |
lookup_symbol(name) | O(1) symbol lookup β file + line | Before grepping for a function |
who_calls(function_name) | Trace callers + dynamic dispatch fallback | Impact analysis, refactoring |
search_token(word) | Word-level reverse index across names, docs, comments | Finding where a concept lives |
retrieve_memory(query, top_k=5) | Semantic similarity search over stored memories | Before answering β pull past context |
search_docs(query) | Full-text search in all .md files | Documentation lookups |
semantic_search_code(query, language=None) | Vector search over code symbols only | Code-specific semantic queries |
subgraph(entity, depth=2) | Local knowledge graph neighbourhood | Understand symbol relationships |
graph_stats() | Node/edge count and graph health | Check if graph has data |
episodic_search(query, limit=10) | BM25 keyword search in event history | Find past decisions or incidents |
dependency_graph(module, direction="both") | Import/dependency relationships | Module coupling analysis |
explain_change(target, since="7d") | What changed in a file/function + git cross-ref | Understanding recent changes |
architecture_overview(scope="root") | Pre-computed LLM architectural summaries | Big-picture questions |
| Tool | Description | When to use |
|---|---|---|
get_user_profile() | User's interaction style: depth pref, question types, vocabulary | Call at session start β calibrates Claude's response style |
get_session_history(limit=10) | Recent conversation exchanges across sessions | Resuming context from prior sessions |
record_user_preference(key, value, context="") | Store a style or format preference | When user corrects interpretation or states a preference |
| Tool | Description | When to use |
|---|---|---|
get_error_patterns(min_count=1) | Recurring errors with prevention hints | Before proposing a fix β check if it has failed before |
record_error(error_type, message, file_path, query_context) | Log an error for future avoidance | After any error Claude or user encounters |
| Tool | Description | When to use |
|---|---|---|
get_agent_bootstrap() | Single-call session start: brief + last context + profile + errors (~300 tokens vs ~900) | Preferred first call β replaces the 4-call sequence |
get_session_brief() | Architecture + hot symbols + index health | First call when you need granular parts separately |
get_last_context() | Most recent context_pack snapshot from prior session | Resume where previous agent left off |
| Tool | Description | When to use |
|---|---|---|
store_memory(text, source="") | Persist a memory to the FAISS index | After solving bugs, recording decisions |
log_episode(event, metadata={}) | Append event to episodic journal | Track milestones, incidents, deployments |
record_decision(summary, rationale="") | Record architectural decision to episodic memory | When making non-obvious design choices |
supersede_learning(old_memory_id, new_text) | Deprecate and replace an outdated memory in one call | When a past decision or fact has changed |
| Tool | Description | When to use |
|---|---|---|
org_search(query) | Search memories across all org repos | Multi-repo context queries |
org_wide_search(query) | Search across every project in the org | Broadest cross-repo sweep |
org_dependencies(depth=2) | Bidirectional inter-repo dependency graph | "What does this service depend on?" |
cross_repo_search(query, scope="project") | Project-scoped or org-scoped search | Finding shared components |
cross_repo_traverse(symbol, direction="both") | Traverse org graph from a repo or symbol | Tracing bugs across service boundaries |
find_symbol_path(from_symbol, to_symbol) | Shortest call-graph path between two symbols, across services | Tracing a request flow end-to-end |
get_service_endpoints(repo_path) | HTTP endpoint registry for a service | Listing a microservice's API surface |
list_org_context() | Org metadata + sibling repos | Understanding repo relationships |
link_repos(src_repo, dst_repo, relationship) | Record cross-repo dependency | When you discover one repo imports another |
The knowledge graph is significantly richer than a simple call graph.
| Type | Description |
|---|---|
FILE | Every indexed source file |
FUNCTION | Function and method definitions with docstrings |
CLASS | Class definitions with base classes |
CONCEPT | Semantic concepts extracted from docstrings and identifiers |
QUERY | Recorded query nodes (for retrieval scoring) |
SESSION | Conversation session nodes |
ERROR | Recurring error pattern nodes |
MEMORY | Cross-agent memory nodes (synced from Claude/Gemini) |
| Type | Direction | Description |
|---|---|---|
DEFINED_IN | symbol β file | Symbol lives in this file |
CALLS / CALLED_BY | bidirectional | Function call relationships with purpose labels |
IMPORTS | file β file | Python import dependencies |
INHERITS | class β parent | Inheritance hierarchy |
CO_OCCURS | file β file | Files edited together (behavioural co-edit signal) |
RELATES_TO | concept β symbol | Semantic concept linkage |
QUERIED_WITH | query β symbol | Retrieval tracking for scoring |
IMPORTS and INHERITS edges are built automatically during index-repo from Python AST.
Use subgraph("MyClass", depth=2) or dependency_graph("mymodule") to query them.
CogniRepo tracks how you interact across sessions and builds a profile that Claude uses to calibrate its responses β without you having to repeat preferences every session.
concise / medium / detailedwhy, what, how, fix, explain, where, refactor, addClaude receives framing_hints at session start and adjusts response length, code density,
and terminology accordingly. The profile accumulates over time β more accurate the more you use it.
CogniRepo logs every error that occurs during sessions β whether it's a Python exception, a failed build step, or a tool call that went wrong. Errors are stored with:
Returns:
| Error class | Prevention hint |
|---|---|
NameError | Undefined variable β check imports and scope before use |
ImportError | Import failed β verify package is installed and module path is correct |
AttributeError | Object missing attribute β check type, None-guard, or spelling |
TypeError | Wrong type β validate inputs at function boundary |
KeyError | Missing dict key β use .get() with default or check existence first |
IndexError | List out of range β guard with len() check before access |
OSError | File/IO error β always guard file ops with try/except OSError |
SyntaxError | Syntax error β run a linter before committing |
Timeout | Timeout β add explicit timeout parameter and retry logic |
AssertionError | Assertion failed β review invariants; do not use assert in prod |
Every cognirepo ask exchange is persisted to .cognirepo/sessions/.
Sessions are indexed by UUID and retrievable via:
Each entry returns: session ID, created timestamp, message count, model used, and the last user/assistant exchange for quick context scan.
cognirepo init automatically prompts to run cognirepo summarize after the first index.
This produces a 3-level LLM summary of the entire codebase:
Summaries are stored in .cognirepo/index/summaries.json and served via the
architecture_overview MCP tool β zero token cost for Claude to understand the big picture.
cognirepo ask automatically picks the right model for each query:
| Tier | Score | Default model | Use case |
|---|---|---|---|
| QUICK | β€2 | local resolver | Single-token / trivial β zero API, fastest path |
| STANDARD | β€4 | Haiku | Quick lookup, factual, single symbol |
| COMPLEX | β€9 | Sonnet | Moderate reasoning |
| EXPERT | >9 | Opus | Cross-file, architectural, ambiguous β full context, best model |
Provider fallback chain: Grok β Gemini β Anthropic β OpenAI.
All errors are logged to .cognirepo/errors/<date>.log β no raw tracebacks shown to users.
| Language | Extensions | Install |
|---|---|---|
| Python | .py | built-in |
| JavaScript / TypeScript | .js .ts .jsx .tsx | cognirepo[languages] |
| Java | .java | cognirepo[languages] |
| Go | .go | cognirepo[languages] |
| Rust | .rs | cognirepo[languages] |
| C / C++ | .c .cpp .h | cognirepo[languages] |
Full details and roadmap: docs/LANGUAGES.md
Everything under .cognirepo/ is .gitignored by default β never committed.
Fernet encryption is opt-in at storage.encrypt: true in config.json.
Priorities drawn from the v0.3.0 benchmark findings and community feedback. Now at v2.0.0 β some items below have since landed; each is annotated where that's the case.
go.mod scanning) and Go symbol/class indexing (tree-sitter function_declaration/type_spec) are implemented. Go-aware who_calls/CALLS edges are still missing β _extract_calls() (intelligence/indexer/ast_indexer.py) only walks Python's stdlib ast, not tree-sitter nodes, so Moby/Kubernetes call-graph tests (MO-3-5, K8-*) remain unblocked-but-incomplete for this specific edge type.cognirepo ask β done: multi-model orchestrator (QUICK/STANDARD/COMPLEX/EXPERT tiers) is implemented and wired as a real CLI command (_cmd_ask_local, interface/cli/main.py). Streaming REPL mode (see Longer-term) is not yet built.cognirepo watch) debounces writes (config.json β indexing.debounce_ms, default 500ms) and batches indexer/graph saves; tests/test_watcher_debounce.py covers this including flush-on-shutdown.context_pack before every file read adds latency under memory pressure. A --fast mode that skips the tool-first gate for files under 50 lines is not yet implemented.register, entry_points, and __init_subclass__ patterns and annotates them as DYNAMIC_DISPATCH nodes in the graph.core/_bm25.py is used by intelligence/retrieval/hybrid.py as the circuit-breaker fallback ranker (and by episodic search) when embeddings are unavailable, but it isn't yet the primary ranking signal for symbol-name partial-match recall (e.g. HttpClient matching http_client) in the normal (embeddings-available) retrieval path.cognirepo prime exists but is not run automatically on init; will make it opt-in default.cognirepo ask streaming REPL β full interactive session with tier routing, session persistence, and sub-agent delegation._TS_FUNCTION_TYPES/_TS_CLASS_TYPES mappings and call-extraction rules per language.lookup_symbol, context_pack, and who_calls directly in the editor sidebar without requiring an MCP-capable host.| Document | Description |
|---|---|
| docs/ARCHITECTURE.md | System design, component responsibilities, data flow |
| docs/architecture/SPECIFICATION.md | Technical spec, complexity signals, storage layout |
| docs/USAGE.md | Complete CLI, MCP, and Docker reference |
| docs/METRICS.md | Quantitative benchmarks: token reduction, lookup speedup, recall |
| CONTRIBUTING.md | How to add adapters, tools, and language support |
| SECURITY.md | Vulnerability reporting, data handling, trust model |
| docs/LANGUAGES.md | Language support details and roadmap |
CogniRepo is licensed under the MIT License.
See LICENSE for full details.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/cognirepo)<a href="https://allmcps.com/mcp/cognirepo"><img src="https://allmcps.com/api/badge/cognirepo?style=directory" alt="CogniRepo on AllMCPs" /></a>