Get the FREE Ultimate OpenClaw Setup Guide →

cocoindex-code

A super light-weight embedded code mcp (AST based) that just works - saves 70% token and improves speed for coding agent. 🌟 Star if you like it!

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio cocoindex-io-cocoindex-code cocoindex-code

How to use

The cocoindex-code MCP provides semantic code search capabilities by embedding the CocoIndex codebase indexing engine into an MCP server. It allows your coding agents (Claude Code, Codex, Cursor, OpenCode, etc.) to query code descriptions and intent rather than relying solely on exact text matches. The MCP can index a codebase locally and serve semantic search results or help locate implementations, usage patterns, or related code across multi-language projects. You can trigger the MCP by instructing your agent to use semantic search for code that matches a description or goal, and you can also let CocoIndex build and maintain the index in the background for up-to-date results. For persistent workflows, you can add guidance in your AGENTS.md or CLAUDE.md to explicitly call the cocoindex-code MCP when relevant code questions arise.

Typical workflows include: performing semantic searches for functions by description (e.g., finding where user session handling is implemented across files), exploring unfamiliar codebases by intent, and locating similar code patterns without knowing exact identifiers. You can explicitly request the agent to use the cocoindex-code MCP by saying things like: "Use the cocoindex-code MCP to find how user sessions are managed," and ensure the agent’s prompts reference the server for targeted semantic code search.

How to install

Prerequisites:

  • Python 3.8+ (pip3 available)
  • Optional: a Python virtual environment
  • Access to the internet to install Python packages

Installation steps:

  1. Create and activate a Python environment (optional but recommended):
python3 -m venv venv
source venv/bin/activate  # Linux/macOS
venv\Scripts\activate.bat # Windows
  1. Install the CocoIndex code MCP package:
pip3 install -U cocoindex-code
  1. Run or configure the MCP in your environment as needed. The package exposes the cocoindex-code entry point which can be invoked directly or via MPC tooling that supports the MCP configuration format. Ensure your environment has access to any required embeddings models and local indexing resources as described in the configuration notes.

Optional configuration tasks:

  • Set embedding model and indexing options via environment variables described in the Configuration section of the project README (e.g., COCOINDEX_CODE_ROOT_PATH, COCOINDEX_CODE_EMBEDDING_MODEL, COCOINDEX_CODE_BATCH_SIZE).
  • If you prefer containerized deployment or automated orchestration, reference your environment’s orchestration tooling to start the cocoindex-code process with the appropriate environment variables set.

Additional notes

Tips and notes:

  • The MCP indexes code locally using CocoIndex’s Rust-based indexing engine, which re-indexes only changed files for faster updates.
  • By default, a local embedding model is used (no API key required) but you can configure various providers (OpenAI, Azure, Gemini, Cohere, Mistral, Voyage, etc.) by setting COCOINDEX_CODE_EMBEDDING_MODEL and corresponding API keys.
  • If you run into indexing performance issues, tune COCOINDEX_CODE_BATCH_SIZE or adjust the embedding model to balance speed and accuracy.
  • For OpenCode users, the configuration example shows you can define the local command and optionally an index command to trigger initial indexing (e.g., cocoindex-code index).
  • Ensure environment variables are exported in your shell or defined in your deployment manifest so the MCP can access them on startup.

Related MCP Servers

Sponsor this space

Reach thousands of developers