Tarun097/code-search-mcp
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.
A semantic code search MCP server that indexes code repositories using embeddings and provides intelligent search capabilities for Amazon Q CLI.
Code Search MCP Server
A semantic code search MCP server that indexes code repositories using embeddings and provides intelligent search capabilities for Amazon Q CLI.
Features
- Semantic Search: Find code by meaning, not just keywords
- Keyword Search: Traditional text-based search
- Multi-Repository Support: Index and search across multiple repositories
- Chunk-based Indexing: Intelligent code chunking for better context
- File Type Awareness: Supports 20+ programming languages
- Real-time Integration: Works seamlessly with Amazon Q CLI
Architecture
Code Repo → Indexer → ChromaDB → MCP Server → Amazon Q CLI
Quick Start
1. Setup Environment
# Clone and setup
git clone <repository-url>
cd code-search-mcp
# Run quick setup
./quick_start.sh
2. Index Your First Repository
# Activate environment
source venv/bin/activate
# Index a repository
python indexer.py --repo-path /path/to/your/repo --repo-name my-project
# Verify indexing
python indexer.py --list
3. Start MCP Server
If this is your first time or after cleanup:
# Run quick setup to create virtual environment and install dependencies
./quick_start.sh
To start the server:
# Start the server (recommended)
./start_server_simple.sh
# Alternative startup script
./start_server.sh
Manual startup (if needed):
# Activate environment and start manually
source venv/bin/activate
python mcp_server.py
4. Configure Amazon Q CLI
# Add MCP server to Q CLI
qchat mcp add --name code-search --command /path/to/code-search-mcp/venv/bin/python --args /path/to/code-search-mcp/mcp_server.py
# Verify configuration
qchat mcp list
Repository Management
Index a New Repository
python indexer.py --repo-path /path/to/repo --repo-name repo-name
Example:
python indexer.py --repo-path /home/user/projects/my-app --repo-name my-app
List Indexed Repositories
python indexer.py --list
View Repository Statistics
# All repositories
python indexer.py --stats
# Specific repository
python indexer.py --stats --filter-repo my-app
Test Search Functionality
# Test semantic search
python indexer.py --search "authentication logic"
# Test search in specific repository
python indexer.py --search "database connection" --filter-repo my-app
Supported File Types
The indexer automatically processes these file types:
Programming Languages:
- Python (
.py) - JavaScript/TypeScript (
.js,.ts) - Java (
.java) - C# (
.cs) - C/C++ (
.c,.cpp,.h) - Go (
.go) - Rust (
.rs) - PHP (
.php) - Ruby (
.rb) - Swift (
.swift) - Kotlin (
.kt) - Scala (
.scala)
Data & Config:
- JSON (
.json) - YAML (
.yaml,.yml) - XML (
.xml) - SQL (
.sql)
Documentation:
- Markdown (
.md) - HTML (
.html) - CSS (
.css) - Text (
.txt)
Usage with Amazon Q CLI
Once configured, you can ask Amazon Q CLI questions like:
Code Discovery
- "Find authentication logic in the my-app repository"
- "Show me database connection code"
- "Where is the user validation implemented?"
- "Find functions that handle file uploads"
API Documentation
- "What does the GetUserById API do?"
- "Show me all REST endpoints in the project"
- "Find error handling patterns"
Architecture Understanding
- "How is the application structured?"
- "Show me the service layer implementation"
- "Find dependency injection configuration"
MCP Tools Provided
| Tool | Description | Parameters |
|---|---|---|
search_code_semantic | AI-powered semantic search | query, repo_name, limit, min_similarity |
search_code_keyword | Traditional keyword search | query, repo_name, limit |
list_indexed_repos | List all indexed repositories | None |
repo_stats | Get repository statistics | repo_name (optional) |
Configuration Files
q-cli-config.json: Amazon Q CLI MCP configurationchroma_db/repo_metadata.json: Repository metadatarequirements.txt: Python dependencies
Troubleshooting
Starting After Git Clone or Cleanup
If you've just cloned the repository or cleaned up the environment:
-
Run quick setup:
./quick_start.sh -
Index your repositories:
source venv/bin/activate python indexer.py --repo-path /path/to/your/repo --repo-name repo-name -
Start the MCP server:
./start_server_simple.sh -
Configure Q CLI (if not done before):
qchat mcp add --name code-search --command $(pwd)/venv/bin/python --args $(pwd)/mcp_server.py
MCP Server Not Loading
- Check if the server is running:
ps aux | grep mcp_server - Verify Q CLI configuration:
qchat mcp list - Check server logs for errors
No Search Results
- Verify repository is indexed:
python indexer.py --list - Check repository path is correct
- Ensure files are in supported formats
Performance Issues
- Large repositories may take time to index
- Consider indexing only specific directories
- Monitor memory usage during indexing
Development
Project Structure
code-search-mcp/
├── indexer.py # Repository indexing logic
├── mcp_server.py # MCP server implementation
├── code_indexer.py # Core indexing classes
├── start_server.sh # Server startup script
├── quick_start.sh # Setup script
├── requirements.txt # Dependencies
├── chroma_db/ # Vector database
└── venv/ # Python virtual environment
Adding New File Types
Edit code_indexer.py and add new extensions to the SUPPORTED_EXTENSIONS list.
Customizing Chunk Size
Modify the chunk_size parameter in CodeIndexer class initialization.
License
This project is owned by Saviynt, Inc. All rights reserved.
Quick Reference
Essential Commands
# Setup (first time or after cleanup)
./quick_start.sh
# Index a repository
source venv/bin/activate
python indexer.py --repo-path /path/to/repo --repo-name repo-name
# List indexed repositories
python indexer.py --list
# Start MCP server
./start_server_simple.sh
# Configure Q CLI
qchat mcp add --name code-search --command $(pwd)/venv/bin/python --args $(pwd)/mcp_server.py
# Check Q CLI configuration
qchat mcp list
File Structure After Setup
code-search-mcp/
├── venv/ # Virtual environment (created by quick_start.sh)
├── chroma_db/ # Vector database (created when indexing)
├── mcp_server.py # Main MCP server
├── indexer.py # Repository indexer
├── start_server_simple.sh # Server startup script
└── README.md # This file
Support
For issues and questions:
- Check the troubleshooting section
- Review MCP server logs
- Verify Amazon Q CLI configuration
- Test indexer functionality independently