GrepAI MCP Integration with Claude Code
This skill covers integrating GrepAI with Claude Code using the Model Context Protocol (MCP).
When to Use This Skill
- Setting up GrepAI in Claude Code
- Enabling semantic search for AI coding assistant
- Configuring MCP server for Claude
- Troubleshooting Claude Code integration
What is MCP?
Model Context Protocol (MCP) allows AI assistants to use external tools. GrepAI provides an MCP server that gives Claude Code:
- Semantic code search
- Call graph analysis
- Index status monitoring
Prerequisites
- GrepAI installed
- Ollama running (or other embedding provider)
- Project indexed (
grepai watch) - Claude Code installed
Quick Setup
One command to add GrepAI to Claude Code:
That's it! Claude Code can now use GrepAI tools.
Manual Configuration
If you prefer manual setup, add to Claude Code's MCP config:
Location
- macOS/Linux:
~/.claude/mcp.json - Windows:
%APPDATA%\Claude\mcp.json
Configuration
With Working Directory
If you want GrepAI to always use a specific project:
Verifying Installation
Check MCP Server
You should see:
In Claude Code
Ask Claude:
"Search the codebase for authentication code"
Claude should use the grepai_search tool.
Available Tools
Once connected, Claude Code has access to these tools:
Tool Usage Examples
Semantic Search
Claude request:
"Find code related to user authentication"
Claude uses:
Trace Analysis
Claude request:
"What functions call the Login function?"
Claude uses:
Index Status
Claude request:
"Is the code index up to date?"
Claude uses:
Compact Mode
By default, MCP tools return compact JSON to minimize tokens:
This reduces token usage by ~80% compared to full content.
Working Directory
The MCP server uses the current working directory. Ensure:
- GrepAI is initialized in your project
- Index exists (run
grepai watchfirst) - Start Claude Code from your project directory
Option 1: Start Claude from Project Directory
Option 2: Configure CWD in MCP Config
Multiple Projects
For multiple projects, you can:
Option 1: Multiple MCP Servers
Option 2: Use Workspaces
Troubleshooting
Tool Not Available
❌ Problem: Claude doesn't see GrepAI tools
✅ Solutions:
- Restart Claude Code after config changes
- Check MCP config syntax (valid JSON)
- Verify
grepaiis in PATH - Test:
grepai mcp-servemanually
Search Returns No Results
❌ Problem: Searches return empty
✅ Solutions:
- Ensure
grepai watchhas run - Check working directory has
.grepai/ - Verify index exists:
grepai status
Connection Refused
❌ Problem: MCP server won't start
✅ Solutions:
- Check Ollama is running:
curl http://localhost:11434/api/tags - Verify config:
cat .grepai/config.yaml - Run
grepai mcp-servemanually to see errors
Wrong Project Indexed
❌ Problem: Results from wrong codebase
✅ Solutions:
- Check
cwdin MCP config - Start Claude from correct directory
- Verify with
grepai_index_statustool
Best Practices
- Keep index updated: Run
grepai watch --background - Use compact mode: Reduces token usage
- Set working directory: Explicit
cwdin config - Check status first: Use
grepai_index_status - Restart after config: Claude needs restart for MCP changes
Removing Integration
To remove GrepAI from Claude Code:
Or manually edit ~/.claude/mcp.json and remove the grepai entry.
Output Format
Successful MCP setup:


