codeindex-mcp

Public

Code Index MCP server for LM Studio

64 Downloads

README

codeindex-mcp

LM Studio Plugin
TypeScript
License

An LM Studio plugin that wraps the upstream Code Index MCP as a set of MCP tools.

Description

codeindex-mcp is an LM Studio plugin (TypeScript) that exposes the upstream Code Index MCP — a Python-based MCP server for intelligent code indexing, search, and analysis — as a set of MCP tools usable inside LM Studio.

Rather than reimplementing the indexing / search logic, this plugin ships a lightweight TypeScript wrapper (src/) that calls each upstream tool over MCP/stdio. The upstream Python repo is cloned at install time and left untouched, so it stays git pull-able for future updates.

Acknowledgments. This project is a port of johnhuang316/code-index-mcp. We are grateful to the original author, hoonowng (Element Labs Inc), for creating and open-sourcing the excellent Code Index MCP that this plugin builds on.

Features

  • Faithful wrapper: every upstream Code Index MCP tool is exposed (14 tools + the files://{file_path} resource) — nothing is dropped or reimplemented.
  • Git-pull friendly: the Python backend lives in CodeIndex/, untouched, so it can be updated with git pull.
  • Self-installing: installing the plugin from the LM Studio Hub automatically clones the upstream repo and sets up its Python environment (see Installation).
  • Configurable UI: per-chat Project Path / Result Limit, plus an optional global Python Executable override.

Architecture

codeindex-mcp/                 # This LM Studio plugin (TypeScript wrapper)
├── manifest.json              # Plugin metadata (kebab-case name: codeindex-mcp)
├── package.json               # Dependencies + "postinstall": node scripts/setup.cjs
├── src/
│   ├── index.ts               # Plugin entry point (exports toolsProvider + config schemas)
│   ├── toolsProvider.ts       # Each MCP tool = a thin wrapper around one upstream tool
│   ├── config.ts              # LM Studio config UI schema (per-chat & global)
│   └── core/
│       └── codeIndexClient.ts # Single long-lived MCP/stdio client to the Python backend
├── scripts/
│   └── setup.cjs              # postinstall: clone upstream + build venv + install deps
├── CodeIndex/                 # Upstream Code Index MCP (Python) — cloned at install time
├── skills/
│   └── codeindex-mcp.md       # Skill / guide for LLMs to use this plugin's tools
└── dist/                      # Compiled JavaScript (auto-generated by `npm run build`)

Installation

This plugin installs the upstream Code Index MCP automatically via the "postinstall": "node scripts/setup.cjs" entry point. When you install it from the LM Studio Hub or run npm install, scripts/setup.cjs runs:

  • Clones the upstream repo into CodeIndex/ (only if it is missing, so a later git pull inside CodeIndex/ keeps working).
  • Creates a Python virtual environment at CodeIndex/.venv.
  • Installs the upstream's Python dependencies from requirements.txt via PyPI (run after the venv is created). No wheels are bundled, so the plugin stays small enough for LM Studio Hub upload.

Then load it as an MCP server in LM Studio:

{
  "mcpServers": {
    "codeindex-mcp": {
      "command": "node",
      "args": ["/absolute/path/to/codeindex-mcp/dist/index.js"]
    }
  }
}

Tip: After install, open LM Studio, start a chat, and call set_project_path to point the backend at the repo you want to index (see Usage and the skill).

Development

Requires LM Studio (which bundles Node.js v22) plus TypeScript and zod.

# 1. Install dependencies
npm install

# 2. Type-check, lint, and build to dist/
npm run typecheck
npm run build

# 3. Develop with hot-reload in LM Studio
npm run dev        # == lms dev   (requires: lms server start)

Key commands (see package.json):

CommandDescription
npm run buildCompile TypeScript → dist/ (tsc).
npm run typecheckType-check only (tsc --noEmit).
npm run devHot-reload in LM Studio (lms dev).
node scripts/setup.cjsManually run the install/clone/env setup.

To publish to the LM Studio Hub: npm run typecheck && npm run build && lms push.

Re-cloning the upstream repo locally

If you cloned this plugin without running postinstall, clone the backend manually so the wrapper has something to call:

git clone https://github.com/johnhuang316/code-index-mcp CodeIndex

Usage

Each tool returns a readable string. A typical session:

  • set_project_path(path=...) — point at the repo (call this FIRST).
  • build_deep_index() — once, before deep analysis (get_file_summary, get_symbol_body).
  • find_files(pattern) / search_code_advanced(...) — locate files and code.
  • get_file_content / get_file_summary / get_symbol_body — read the code.
  • After edits, refresh_index() (shallow) or build_deep_index() (deep) to keep the index fresh.

See **[skills/codeindex-mcp.md](skills/codeindex-mcp.md for a full skill: every tool's definition, usage rules, worked scenarios (indexing, searching, analysis, refactoring), and a decision guide for small LLMs.

MCP Tools Summary

All 14 upstream tools are wrapped, plus the files://{file_path} resource (get_file_content).

Project / Lifecycle

ToolDescription
set_project_pathSet the base project path for indexing. Call this FIRST.
refresh_indexRebuild the shallow file index after changes / git operations.
build_deep_indexBuild the full symbol index for deep analysis (max_workers, timeout).
get_settings_infoView current project config and indexed state.

Search & Discovery

ToolDescription
find_filesLocate files using glob patterns (e.g. **/*.py).
search_code_advancedSmart search: literal / fuzzy / regex, file filtering, pagination.
get_file_summaryFile structure, functions/imports/complexity (needs deep index).

Code Intelligence / Reading

ToolDescription
get_file_contentRaw text content of a file (the files://{file_path} resource).
get_symbol_bodySource body of one symbol (function/method/class). Needs deep index.

Monitoring / Auto-refresh

ToolDescription
get_file_watcher_statusCheck file watcher status and statistics.
configure_file_watcherEnable/disable auto-refresh and configure settings.

System / Maintenance

ToolDescription
create_temp_directorySet up storage directory for index data.
check_temp_directoryVerify index storage location and permissions.
clear_settingsReset all cached (indexed) data and settings.
refresh_search_toolsRe-detect available search tools (ugrep/ripgrep/ag/grep).

License

This project is distributed under the MIT License, consistent with the upstream Code Index MCP it wraps.

MIT License

Copyright (c) 2025 Element Labs Inc
Copyright (c) 2025 codeindex-mcp contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

The software is provided "as is", without warranty of any kind, express or
implied, including but not limited to the warranties of MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR in connection with the software or the use or other DEALINGS in the
SOFTWARE.