johnhuang316_code_index_mcp

johnhuang316_code_index_mcp

by johnhuang316
A Model Context Protocol server enabling large language models to index, search, and analyze code repositories with minimal setup.

Code Index MCP Server for LLMs

A Model Context Protocol (MCP) server designed to help large language models (LLMs) index, search, and analyze code repositories with minimal setup.

Features

  • Index and navigate project file structures
  • Search for specific patterns in code
  • Get detailed file summaries
  • Analyze code structure and complexity
  • Support for multiple programming languages
  • Persistent storage of project settings

Installation

This project uses uv for environment management and dependency installation.

  1. Ensure you have Python 3.10 or later installed.
  2. Install uv (recommended):

shell # Windows powershell -c "irm https://astral.sh/uv/install.ps1 | iex" # macOS/Linux curl -LsSf https://astral.sh/uv/install.sh | sh

  1. Clone the repository:

shell git clone https://github.com/your-username/code-index-mcp.git

Usage

Running the Server Directly

uv run run.py

UV will automatically handle all dependency installations based on the project's configuration.

Integrating with Claude Desktop

  1. Ensure UV is installed (see installation section above).
  2. Find or create the Claude Desktop configuration file:
  3. Windows: %APPDATA%\Claude\claude_desktop_config.json
  4. macOS/Linux: ~/Library/Application Support/Claude/claude_desktop_config.json
  5. Add the following configuration (replace with your actual path):

For Windows:

json { "mcpServers": { "code-indexer": { "command": "uv", "args": [ "--directory", "C:\\Users\\username\\path\\to\\code-index-mcp", "run", "run.py" ] } } }

For macOS/Linux:

json { "mcpServers": { "code-indexer": { "command": "uv", "args": [ "--directory", "/home/username/path/to/code-index-mcp", "run", "run.py" ] } } }

  1. Restart Claude Desktop to use Code Indexer for analyzing code projects.

Basic Workflow

  1. Set Project Path (required first step):
  2. Through Claude command: "I need to analyze a project, help me set up the project path."
  3. Provide the complete project directory path.
  4. Code Search:
  5. Search for specific keywords or patterns: "Search for 'function name' in the project."
  6. Filter by file type: "Search for 'import' in all .py files."
  7. File Analysis:
  8. Analyze specific files: "Analyze the file src/main.py."
  9. Get file summaries: "Give me a list of functions in utils/helpers.js."
  10. Project Navigation:
  11. View project structure: "Show me the structure of this project."
  12. Find files matching specific patterns: "Find all test_*.py files."

Technical Details

Persistent Storage

All index and settings data are stored in the .code_indexer folder within the project directory:

  • config.json: Project configuration information.
  • file_index.pickle: File index data.
  • content_cache.pickle: File content cache.

This ensures that the entire project doesn't need to be re-indexed each time it's used.

Dependency Management with UV

Code Index MCP uses UV for dependency management, which provides several advantages:

  • Automatic dependency resolution based on project requirements.
  • Faster package installation and environment setup.
  • Consistent dependency versions via the lock file.

Supported File Types

The following file types are currently supported for indexing and analysis:

  • Python (.py)
  • JavaScript/TypeScript (.js, .ts, .jsx, .tsx)
  • Java (.java)
  • C/C++ (.c, .cpp, .h, .hpp)
  • C# (.cs)
  • Go (.go)
  • Ruby (.rb)
  • PHP (.php)
  • Swift (.swift)
  • Kotlin (.kt)
  • Rust (.rs)
  • Scala (.scala)
  • Shell (.sh, .bash)
  • HTML/CSS (.html, .css, .scss)
  • Markdown (.md)
  • JSON (.json)
  • XML (.xml)
  • YAML (.yml, .yaml)

Security Considerations

  • File path validation prevents directory traversal attacks.
  • Absolute path access is not allowed.
  • Project path must be explicitly set, with no default value.
  • The .code_indexer folder includes a .gitignore file to prevent indexing data from being committed.

Contributing

Contributions via issues or pull requests to add new features or fix bugs are welcome.


For documentation in Chinese, please see README_zh.md.

Features & Capabilities

Categories
mcp_server model_context_protocol python claude code_analysis search api_integration uv dependency_management

Implementation Details

Stats

0 Views
0 Likes
4 GitHub Stars

Repository Info

johnhuang316 Organization

Similar Servers

continuedev_continue by continuedev
0
0
0