« Back to Search  |  Reader Mode  |  Switch to Full Retro Site View Links: Stay in Reader  |  Retro Mode: ON  |  Original »
GitHub · Extracted in 826 ms

GitHub - hdimer/code-index: Semantic code search as an MCP server. Find code by meaning, not keywords. Local embeddings + Milvus Lite, no API keys.

Source: https://github.com/hdimer/code-index

Repository navigation

code-index
Public

About

Semantic code search as an MCP server. Find code by meaning, not keywords. Local embeddings + Milvus Lite, no API keys.

Topics

code-search mcp milvus model-context-protocol python semantic-search

Resources

Readme MIT license Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks Report repository
Branches

Tags
Go to Branches page Go to Tags page

Latest commit

 

History


3 Commits
View commit history for this file.

Folders and files

Name Name Last commit message Last commit date
tests tests    
.gitignore .gitignore    
LICENSE LICENSE    
README.md README.md    
chunker.py chunker.py    
conftest.py conftest.py    
gitignore_filter.py gitignore_filter.py    
indexer.py indexer.py    
requirements.txt requirements.txt    
server.py server.py    

Repository files navigation

code-index

Semantic code search as an MCP server. Point it at a project and an AI agent (or you) can find code by meaning , not just by keyword. "Where do we validate the auth token?" returns the right function even if it never uses the words "validate" or "auth."

Runs fully local: local embeddings, a local vector store, no API keys, nothing leaves your machine.

How it works

  • AST-aware chunking. Python is split along function and class boundaries via the ast module, so a match is a whole meaningful unit, not a random window. Everything else falls back to line-based chunks. (chunker.py)
  • Local embeddings. Uses FastEmbed with BAAI/bge-small-en-v1.5. No OpenAI key, no network calls.
  • Local vector store. Milvus Lite writes a single milvus.db file under the project's own .code-index/ directory.
  • Respects .gitignore. Build artifacts, node_modules, and vendored code are skipped via pathspec. (gitignore_filter.py)

MCP tools

Exposed over the Model Context Protocol (server.py):

Tool What it does
reindex(project_path) Full reindex: collect files, chunk, embed, store. Returns file/chunk counts and duration.
search_code(project_path, query, limit=10) Semantic search. Returns ranked chunks with file_path, line range, content, chunk_type, name, and score.
index_status(project_path) Reports whether an index exists and how stale it is (file count, chunk count, age, last indexed).

Setup

pip install -r requirements.txt

Register it as an MCP server with your client (e.g. Claude Code):

{
  "mcpServers": {
    "code-index": {
      "command": "python",
      "args": ["/path/to/code-index/server.py"]
    }
  }
}

Then, from your agent: reindex a project once, and search_code for the rest of the session. Re-run reindex when the tree has drifted (index_status tells you when it's stale).

Tests

python -m pytest

Covers the chunker, the .gitignore filter, the indexer, and the server tools.

Requirements

Python 3.10+. See requirements.txt (mcp, pymilvus[milvus_lite], fastembed, pathspec).

About

Semantic code search as an MCP server. Find code by meaning, not keywords. Local embeddings + Milvus Lite, no API keys.

Topics

code-search mcp milvus model-context-protocol python semantic-search

Resources

Readme MIT license Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks Report repository

Releases

Packages

Contributors

Languages