MCP Local Codebase Search MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
git clone https://github.com/demixid/MCP-Local-Codebase-Search
cd MCP-Local-Codebase-Search
pip install -r requirements.txt
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add local-codebase-search -- node "<FULL_PATH_TO_MCP_LOCAL_CODEBASE_SEARCH>/dist/index.js"

Replace <FULL_PATH_TO_MCP_LOCAL_CODEBASE_SEARCH>/dist/index.js with the actual folder you prepared in step 1.

README.md

An MCP server that indexes local Python projects into a SQLite database.

MCP Local Codebase Search

This project is a simple MCP (Model Context Protocol) server for local Python codebase search.

It provides tools to:

  • index Python files into a SQLite database,
  • search symbols (functions/classes),
  • find files importing specific modules,
  • read file contents.

Features

  • index_project()
    • Scans the current working directory and indexes .py files.
    • Stores symbol and dependency data in db/code_index.db.
  • find_symbol(name)
    • Searches function/class names using LIKE matching.
    • Returns symbol name, type, file path, and line number.
  • find_import(module)
    • Finds files that import a specific module.
  • read_file(path)
    • Reads and returns full file content with encoding fallback (utf8, latin-1).

Project Structure

  • server.py: MCP server entrypoint and tool definitions.
  • indexer.py: Indexing logic to SQLite.
  • parser.py: Symbol extraction (FunctionDef, ClassDef) using ast.
  • dependency.py: Import extraction using ast.
  • search.py: Search queries against the database.
  • db/: Index database location (code_index.db).

Prerequisites

  • Python 3.10+ (recommended)
  • pip

Installation

  1. Clone this repository.
  2. Go to the project folder.
  3. Create a virtual environment.
  4. Activate the virtual environment.
  5. Install dependencies.

Windows PowerShell example:

python -m venv venv
.\venv\Scripts\Activate.ps1
pip install -r requirements.txt

Run Locally

Start the MCP server:

python server.py

Available tools:

  • index_project
  • find_symbol
  • find_import
  • read_file

MCP Configuration

Add this to your MCP client configuration so it runs as an MCP server:

{
  "mcpServers": {
    "code-intelligence": {
      "command": "python",
      "args": [
        "path-to-your-server"
      ]
    }
  }
}

Recommended Usage Flow

  1. Run index_project once to build the initial index.
  2. Use find_symbol to locate functions/classes.
  3. Use find_import to trace module usage.
  4. Re-run index_project after major code changes.

Notes

  • Non-Python files are not indexed.
  • Ignored directories during indexing: .git, node_modules, __pycache__, dist, build.
  • The index database is local and should not be committed (already covered by .gitignore).

Tools (4)

index_projectScans the current working directory and indexes .py files into a SQLite database.
find_symbolSearches for function or class names using LIKE matching.
find_importFinds files that import a specific module.
read_fileReads and returns the full content of a file.

Configuration

claude_desktop_config.json
{"mcpServers": {"code-intelligence": {"command": "python", "args": ["path-to-your-server"]}}}

Try it

Index my current Python project to update the codebase database.
Find the definition of the 'User' class in my project.
Which files in my project are importing the 'requests' module?
Read the contents of the file located at src/utils.py.

Frequently Asked Questions

What are the key features of MCP Local Codebase Search?

Indexes local Python files into a SQLite database. Performs symbol searches for functions and classes. Tracks module dependencies to find file imports. Reads file contents with encoding fallback support.

What can I use MCP Local Codebase Search for?

Quickly locating class or function definitions in large Python projects. Tracing module dependencies to understand how code is structured. Navigating through project files using natural language queries. Maintaining an up-to-date index of code symbols for faster development.

How do I install MCP Local Codebase Search?

Install MCP Local Codebase Search by running: git clone https://github.com/demixid/MCP-Local-Codebase-Search && cd MCP-Local-Codebase-Search && pip install -r requirements.txt

What MCP clients work with MCP Local Codebase Search?

MCP Local Codebase Search works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep MCP Local Codebase Search docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare