codelore-mcp

codelore-mcp

Turn any code repository into a searchable Obsidian vault — then let Claude Code navigate it as a set of MCP tools.

Category
访问服务器

README

codelore

Turn any code repository into a searchable Obsidian vault — then let Claude Code navigate it as a set of MCP tools.

codelore runs a two-phase pipeline:

  1. Summarise — calls claude --print once per file and directory to produce structured markdown documentation
  2. Index — chunks every file at the function/class level, generates developer questions for each chunk, and stores them in a ChromaDB vector index

The result is an Obsidian vault of linked markdown notes and a semantic search index that Claude Code can query as native tools.


How it works

your-repo/
    src/auth/middleware.py   →  AI summary + import graph
    src/db/pool.py           →  AI summary + import graph
    ...
           ↓  codelore ingest
your-repo_vault/
    INDEX.md                 overview + wikilinks to all modules
    src/auth/middleware.md   structured summary of every function
    src/db/pool.md           ...
your-repo_chroma/            ChromaDB: chunks indexed by developer questions

Claude Code reads INDEX.md → directory notes → file notes via the explore_repo tool, and answers "how does X work?" questions via search_code which hits the semantic index.


Prerequisites


Install

pip install codelore

Or from source:

git clone https://github.com/yourname/codelore
pip install -e codelore

Quick start

# 1. Ingest a local repo (or pass a GitHub URL)
codelore ingest /path/to/your-repo

# Preview cost before running on a large repo
codelore ingest /path/to/your-repo --dry-run

# Re-use cached summaries from a previous run (skips claude calls)
codelore ingest /path/to/your-repo   # prompted automatically if cache exists

# 2. Query from the terminal
codelore query "how does authentication work?" \
  --chroma /path/to/your-repo_chroma

# 3. Print MCP setup instructions
codelore init --vault /path/to/your-repo_vault \
              --chroma /path/to/your-repo_chroma \
              --repo /path/to/your-repo

CLI reference

codelore ingest <repo>

Flag Description
--vault PATH Override vault output directory (default: <name>_vault/)
--explanations PATH Load a pre-generated _explanations.json instead of calling Claude
--dry-run Print file count and estimated Claude calls without running
--no-llm Write structural vault (file tree + imports) without any Claude calls

codelore query <question>

Flag Description
--chroma PATH ChromaDB directory (or set CODELORE_CHROMA_PATH)
--vault PATH Vault directory for summary snippets (or set CODELORE_VAULT_ROOT)
-n N Number of results (default: 5)

codelore init

Prints step-by-step setup instructions and a ready-to-paste MCP config block.

Flag Description
--vault PATH Pre-fill vault path in the generated config
--chroma PATH Pre-fill ChromaDB path in the generated config
--repo PATH Pre-fill repo root path in the generated config

MCP server setup (Claude Code)

After ingesting, add codelore as an MCP server so Claude Code can call it as tools.

Add to .claude/settings.json (project) or ~/.claude/settings.json (global):

{
  "mcpServers": {
    "codelore": {
      "command": "codelore-mcp",
      "env": {
        "CODELORE_VAULT_ROOT": "/path/to/your-repo_vault",
        "CODELORE_CHROMA_PATH": "/path/to/your-repo_chroma",
        "CODELORE_REPO_ROOT": "/path/to/your-repo"
      }
    }
  }
}

codelore init will generate this block with your actual paths filled in.

Available MCP tools

Tool Triggers on
search_code "how does X work?", "where is Y defined?"
explore_repo "explain this codebase", "give me an overview"
find_todos "what's left to implement?", "show open tasks"
read_vault_node "show me the summary for src/auth"
read_guidelines architectural guidelines doc (optional)
estimate_cost "how many claude calls would this take?"
ingest_repo "ingest this repo"
rebuild_vault rebuild vault from saved explanations
sync_vault incremental re-index after code changes

Supported languages

Language Extensions Chunking
Python .py AST (function + class level)
JavaScript / TypeScript .js .jsx .ts .tsx .mjs tree-sitter
Go .go tree-sitter
Java .java tree-sitter
Kotlin .kt tree-sitter
Scala .scala tree-sitter
C# .cs tree-sitter
Haskell .hs .lhs tree-sitter
Elixir .ex .exs tree-sitter
Lua .lua tree-sitter
Shell .sh .bash tree-sitter
Dart .dart whole-file
R .r .R whole-file

Non-code files (.md, .json, .yaml, .toml, .sql, .proto, .graphql) are also indexed for context.


Incremental re-indexing

After code changes, sync only the modified files instead of re-running the full pipeline:

# via MCP tool (in Claude Code):
"sync the vault for /path/to/repo"   →  calls sync_vault(dry_run=True) first

# or directly:
sync_vault(repo_path="/path/to/repo", explanations_json_path="..._explanations.json", dry_run=True)
sync_vault(repo_path="/path/to/repo", explanations_json_path="..._explanations.json", dry_run=False)

Requires the repo to be a git repository (uses git diff against the SHA saved during ingestion).


Architecture

codelore/
  main.py          CLI entry point (ingest / query / init subcommands)
  ingest.py        build file/directory graph, write vault markdown
  explain.py       collect files, call Claude CLI for summaries
  llm.py           Claude CLI wrapper, prompt templates
  nodes.py         FileNode / DirectoryNode / IndexNode → markdown
  generate_questions.py  chunk-level question generation + ChromaDB indexing
  parsers/         language-specific import graph + chunk extraction
    _treesitter.py shared tree-sitter helper
    python.py      stdlib ast
    javascript.py  tree-sitter-javascript / tree-sitter-typescript
    go.py          tree-sitter-go
    jvm.py         tree-sitter-java / tree-sitter-kotlin / tree-sitter-scala
    csharp.py      tree-sitter-c-sharp
    haskell.py     tree-sitter-haskell
    elixir.py      tree-sitter-elixir
    lua.py         tree-sitter-lua
    shell.py       tree-sitter-bash
    ...
  query/
    retrieval.py   search_chunks, bfs_vault, grep_todos, git_file_log
mcp_server.py      FastMCP server exposing 9 tools

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选