mcp-code-search-server

fx-an/mcp-code-search-server

3.1

If you are the rightful owner of mcp-code-search-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

An MCP Server, which helps the LLM find the location of relevant code within files and supports returning the complete function definitions.

mcp-code-search-server is a server based on the Model Context Protocol (MCP) designed to provide code search functionality for large language models (LLM). It helps LLMs accurately locate identifiers (such as variables, functions, classes) within a codebase and returns their complete definitions, not just the reference locations. By obtaining the full code definitions and their context, it aids LLMs in better understanding the internal logic, data flow, and dependencies of the code.

Features

  • Code Search: Efficiently searches for identifiers in the codebase using ripgrep.
  • Multi-language Support: Supports code parsing for JavaScript/TypeScript, Java, and Python.
  • Complete Definition Extraction: Automatically identifies and extracts complete definitions of variables, functions, and classes.
  • Multi-encoding Support: Automatically detects and handles files with different encodings (UTF-8, GBK, Big5, etc.).
  • Intelligent Filtering: Provides default configurations to exclude common non-code directories and file types.

Usages

usage with command line

bash
npx mcp-code-search-server

usage with debug mode

bash
# 构建项目
npm run build

# 运行调试器
npm run debug

# 或者一步执行
npm run build-debug

usage with llm tool integration

{
  "mcp": {
    "servers": {
      "code-search": {
        "command": "npx",
        "args": [
            "-y",
            "mcp-code-search-server"
        ]
      }
    }
  }
}