code-search-mcp

LLMTooling/code-search-mcp

3.3

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

Code Search MCP is a universal Model Context Protocol server designed for intelligent code search across multiple programming languages.

Tools
13
Resources
0
Prompts
0

Code Search MCP

Universal MCP server for intelligent code search across any programming language

Overview

Code Search MCP is a high-performance Model Context Protocol server that enables LLMs to intelligently search and analyze codebases across 12 programming languages with comprehensive AST search support for 15 languages. Built on our universal-ctags wrapper, ripgrep, and ast-grep, it provides fast symbol search, structural AST pattern matching, text search, file search, and dependency analysis with persistent caching for 80%+ faster startup times.

Core Features

FeatureDescriptionPerformance
Symbol SearchFind classes, functions, methods, and variables with intelligent filteringFast (indexed)
AST SearchStructural code search using Abstract Syntax Trees with metavariables and relational rulesFast
Text SearchRegex-powered code search using ripgrepVery Fast
File SearchLocate files by name, pattern, or extension with glob supportVery Fast
Stack DetectionAutomatically detect technology stacks and frameworks in projectsFast
Dependency AnalysisAnalyze project dependencies across multiple ecosystemsFast
Index CachingPersistent symbol indices with automatic invalidation80%+ faster startup

Language Support

Code Search MCP supports 12 programming languages with full symbol indexing and intelligent search capabilities.

LanguageSymbol SearchText SearchDependency Analysis
JavaScriptFullFullFull (npm)
TypeScriptFullFullFull (npm)
PythonFullFullFull (pip)
JavaFullFullFull (Maven/Gradle)
C#FullFullFull (NuGet)
GoFullLimitedFull (go.mod)
RustFullLimitedFull (Cargo)
C / C++FullLimitedLimited
PHPFullLimitedFull (Composer)
RubyFullLimitedFull (Bundler)
KotlinFullLimitedFull (Gradle)

MCP Tools

The server exposes the following tools through the Model Context Protocol interface.

ToolDescriptionKey Parameters
search_symbolsSearch for code symbols with filterspath, language, name, match, kinds, scope
search_textSearch code using regex patternspath, pattern, language, case_insensitive, literal, limit, paths
search_filesFind files by name, pattern, or extensionpath, pattern, name, extension, directory
detect_stacksDetect technology stacks in a directorypath, scan_mode (fast/thorough)
analyze_dependenciesAnalyze project dependenciespath, include_transitive, check_outdated
refresh_indexRebuild the symbol indexpath, force_rebuild
cache_statsView cache statisticspath (optional)
clear_cacheClear cached indicespath (optional)
search_ast_patternSearch using AST patterns with metavariablespath, language, pattern, paths, limit
search_ast_ruleSearch using complex AST rules with relational and composite operatorspath, language, rule, paths, limit, debug
check_ast_grepCheck ast-grep availability and versionNone

Search Capabilities

Search TypeMatch ModesFilter Options
Symbol Searchexact, prefix, substring, regexkind, scope (class/namespace/module), language
Text Searchregex, literallanguage, case sensitivity, result limit
File Searchglob patterns, wildcardsextension, directory, case sensitivity

AST Search

Search code using Abstract Syntax Tree analysis for structural pattern matching that goes beyond simple text search.

CapabilityDescriptionExample Pattern
MetavariablesCapture and match code elements$VAR (named), $$VAR (anonymous), $$$VAR (multiple)
Relational RulesContext-aware matchinginside, has, precedes, follows
Composite RulesLogical combinationsall (AND), any (OR), not (negation)
Kind MatchingMatch specific AST node typesfunction_declaration, class_declaration, etc.

AST Search Examples:

// Find async functions without await
{
  "rule": {
    "all": [
      { "pattern": "async function $NAME($$$) { $$$ }" },
      { "not": { "has": { "pattern": "await $$$", "stopBy": "end" } } }
    ]
  }
}

// Find React components using useEffect without dependencies
{
  "rule": {
    "all": [
      { "pattern": "useEffect($$$)" },
      { "not": { "pattern": "useEffect($CALLBACK, [$$$DEPS])" } }
    ]
  }
}

// Find functions with console.log inside
{
  "rule": {
    "pattern": "console.log($$$)",
    "inside": {
      "pattern": "function $NAME($$$) { $$$ }",
      "stopBy": "end"
    }
  }
}

Supported Languages (15 Total):

LanguageFile Extensions
Bash.sh, .bash
C.c, .h
C++.cpp, .cc, .cxx, .hpp, .hxx
C#.cs
CSS.css
Go.go
HTML.html, .htm
Java.java
JavaScript.js, .jsx, .mjs
JSON.json
Kotlin.kt, .kts
Python.py
Rust.rs
Scala.scala
Swift.swift
TypeScript.ts, .tsx
YAML.yml, .yaml

All AST language packages are bundled with the server - no additional installation required!

Tech Stack Detection

Automatically identify technologies, frameworks, and tools used in your projects with intelligent file-based detection.

CategoryTechnologies DetectedDetection Method
LanguagesJavaScript, TypeScript, Python, Java, C#, Go, Rust, C/C++, PHP, Ruby, Kotlin, SwiftFile extensions & patterns
Build ToolsWebpack, Vite, Rollup, Parcel, Gradle, Maven, Make, CMake, MSBuildConfig files
Package Managersnpm, Yarn, pnpm, pip, Poetry, Cargo, Go modules, NuGet, Composer, BundlerLock files & manifests
FrameworksReact, Vue, Angular, Next.js, Svelte, Django, Flask, FastAPI, Spring Boot, .NET CoreDependencies & configs
TestingJest, Mocha, Vitest, Pytest, JUnit, NUnit, Go Test, Cargo TestConfig files & dependencies
DatabasesPostgreSQL, MySQL, MongoDB, Redis, SQLite, Prisma, TypeORM, SequelizeConfig files & dependencies
DevOpsDocker, Kubernetes, GitHub Actions, GitLab CI, CircleCI, Jenkins, TerraformConfig files & manifests
Code QualityESLint, Prettier, Black, Pylint, Flake8, RuboCop, Clippy, TSLintConfig files

Scan Modes: Fast (config files only) • Thorough (includes dependency analysis)

Performance

The persistent caching system delivers dramatic performance improvements for repeated searches.

RepositoryCold StartCached StartImprovement
Express.js (8,234 symbols)2,453ms127ms19.3x faster
Lodash (12,456 symbols)1,876ms89ms21.1x faster
Large Codebase (5,000 symbols)3,124ms145ms21.5x faster

Average improvement: 94.5% time saved

Installation

Prerequisites

Install the required dependencies:

# Install universal-ctags (required for symbol search)
# macOS
brew install universal-ctags

# Ubuntu/Debian
sudo apt-get install universal-ctags

# Windows (via Chocolatey)
choco install universal-ctags

# Install ripgrep (required for text search)
# macOS
brew install ripgrep

# Ubuntu/Debian
sudo apt-get install ripgrep

# Windows (via Chocolatey)
choco install ripgrep

# ast-grep is bundled with the MCP server - no separate installation needed!

Install the MCP Server

# Clone the repository
git clone https://github.com/GhostTypes/code-search-mcp.git
cd code-search-mcp

# Install dependencies
npm install

# Build the project
npm run build

Configuration

Security Model

All tools accept absolute path parameters and validate them against allowed workspaces configured at startup.

Add to your MCP settings file (e.g., claude_desktop_config.json):

{
  "mcpServers": {
    "code-search": {
      "command": "node",
      "args": [
        "/path/to/code-search-mcp/dist/index.js",
        "--allowed-workspace", "/path/to/your/project1",
        "--allowed-workspace", "/path/to/your/project2"
      ]
    }
  }
}

Configuration Options

OptionDescription
--allowed-workspace <path>Whitelist a directory for search operations. Can be specified multiple times. If omitted, all paths are allowed (use with caution)
-w <path>Short alias for --allowed-workspace

Development

# Clone the repository
git clone https://github.com/GhostTypes/code-search-mcp.git
cd code-search-mcp

# Install dependencies
npm install

# Build the project
npm run build

# Run tests
npm test

# Run integration tests
npm run test:integration

Architecture

The server is built with a modular architecture for maintainability and extensibility.

ComponentResponsibility
MCP ServerProtocol handling, tool routing, and path validation
Symbol IndexerUniversal-ctags integration and indexing
Symbol Search ServiceSymbol query processing and filtering
Text Search ServiceRipgrep integration for text search
File Search ServiceFast file finding with glob patterns
Stack Detection EngineTechnology stack identification
Dependency AnalyzerMulti-ecosystem dependency analysis
Cache ManagerIndex persistence and invalidation
AST Search ServiceStructural code search using ast-grep

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

License

MIT License - see for details

Acknowledgments

ToolPurpose
universal-ctagsSymbol indexing
ripgrepText search
ast-grepAST-based structural search
MCP SDKProtocol implementation