grepai-mcp-claude — Claude Code skill: semantic code search via MCP
Wires GrepAI into Claude over MCP so the agent searches code by meaning and walks the call graph.
npx skills add yoanbernabeu/grepai-skills --skill grepai-mcp-claude -a claude-codeWhat grepai-mcp-claude does
The skill walks through adding the GrepAI MCP server to Claude. Once connected, the agent gets five tools: grepai_search for semantic search, grepai_trace_callers and grepai_trace_callees for finding callers and callees, grepai_trace_graph for call graphs, and grepai_index_status for index health.
The fast route is one command: claude mcp add grepai -- grepai mcp-serve. For manual setup, add the server to ~/.claude/mcp.json on macOS and Linux, or %APPDATA%\Claude\mcp.json on Windows, with command and args keys. The cwd field matters when the project you want isn't the one you launched Claude from.
Four things have to be in place first: GrepAI installed, Ollama or another embedding provider running, the project indexed with grepai watch, and Claude itself. No index means empty search results; no Ollama means the server won't start, so check that first if the connection is refused. Tools return compact JSON by default to keep token usage down.
What it helps with
- find code by meaning instead of exact string matches
- see which functions call Login
- build a call graph around a symbol
- check whether the project index is current
- attach the GrepAI MCP server to Claude
Example prompts for the agent
- Search the codebase for authentication code
- What functions call Login?
- Is the code index up to date?
How to install grepai-mcp-claude
1Skills CLI (Vercel)
npx skills add yoanbernabeu/grepai-skills --skill grepai-mcp-claude -a claude-code2Manually: put the files in place
~/.claude/skills/grepai-mcp-claude/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/grepai-mcp-claude/
1Skills CLI (Vercel)
npx skills add yoanbernabeu/grepai-skills --skill grepai-mcp-claude -a codex2Manually: put the files in place
.agents/skills/grepai-mcp-claude/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add yoanbernabeu/grepai-skills --skill grepai-mcp-claude -a cursor2Manually: put the files in place
.cursor/skills/grepai-mcp-claude/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install yoanbernabeu/grepai-skills grepai-mcp-claude2Manually: put the files in place
.github/skills/grepai-mcp-claude/SKILL.md1Skills CLI (Vercel)
npx skills add yoanbernabeu/grepai-skills --skill grepai-mcp-claude -a gemini-cli2Platform CLI
gemini skills install https://github.com/yoanbernabeu/grepai-skills --path skills/integration/grepai-mcp-claudeManually: put the files in place
.devin/skills/grepai-mcp-claude/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add yoanbernabeu/grepai-skills --skill grepai-mcp-claude -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about grepai-mcp-claude
How do I install grepai-mcp-claude in Claude?
Add the skill first: npx skills add yoanbernabeu/grepai-skills --skill grepai-mcp-claude -a claude-code. Then register the MCP server with claude mcp add grepai -- grepai mcp-serve.
What does grepai-mcp-claude do?
It documents connecting GrepAI to Claude over MCP, giving the agent semantic code search, caller and callee tracing, and index status checks.
What do I need before setting it up?
GrepAI installed, Ollama or another embedding provider running, the project indexed with grepai watch, and Claude. If searches come back empty, verify the index exists and the working directory is right.
Source text
SKILL.md · MIT
---
name: grepai-mcp-claude
description: Integrate GrepAI with Claude Code via MCP. Use this skill to enable semantic code search in Claude Code.
---
# 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
1. GrepAI installed
2. Ollama running (or other embedding provider)
3. Project indexed (`grepai watch`)
4. Claude Code installed
## Quick Setup
One command to add GrepAI to Claude Code:
```bash
claude mcp add grepai -- grepai mcp-serve
```
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
```json
{
"mcpServers": {
"grepai": {
"command": "grepai",
"args": ["mcp-serve"]
}
}
}
```
### With Working Directory
If you want GrepAI to always use a specific project:
```json
{
"mcpServers": {
"grepai": {
"command": "grepai",
"args": ["mcp-serve"],
"cwd": "/path/to/your/project"
}
}
}
```
## Verifying Installation
### Check MCP Server
```bash
# Start MCP server manually to test
grepai mcp-serve
```
You should see:
```
GrepAI MCP Server started
Listening for requests...
```
### 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 | Description | Parameters |
|------|-------------|------------|
| `grepai_search` | Semantic code search | `query` (required), `limit`, `compact` |
| `grepai_trace_callers` | Find function callers | `symbol` (required), `compact` |
| `grepai_trace_callees` | Find function callees | `symbol` (required), `compact` |
| `grepai_trace_graph` | Build call graph | `symbol` (required), `depth` |
| `grepai_index_status` | Check index health | `verbose` (optional) |
## Tool Usage Examples
### Semantic Search
Claude request:
> "Find code related to user authentication"
Claude uses:
```json
{
"tool": "grepai_search",
"parameters": {
"query": "user authentication",
"limit": 5,
"compact": true
}
}
```
### Trace Analysis
Claude request:
> "What functions call the Login function?"
Claude uses:
```json
{
"tool": "grepai_trace_callers",
"parameters": {
"symbol": "Login",
"compact": true
}
}
```
### Index Status
Claude request:
> "Is the code index up to date?"
Claude uses:
```json
{
"tool": "grepai_index_status",
"parameters": {
"verbose": true
}
}
```
## Compact Mode
By default, MCP tools return compact JSON to minimize tokens:
```json
{
"q": "authentication",
"r": [
{"s": 0.92, "f": "src/auth/middleware.go", "l": "15-45"},
{"s": 0.85, "f": "src/auth/jwt.go", "l": "23-55"}
],
"t": 2
}
```
This reduces token usage by ~80% compared to full content.
## Working Directory
The MCP server uses the current working directory. Ensure:
1. GrepAI is initialized in your project
2. Index exists (run `grepai watch` first)
3. Start Claude Code from your project directory
### Option 1: Start Claude from Project Directory
```bash
cd /path/to/your/project
claude # Claude Code now uses this directory
```
### Option 2: Configure CWD in MCP Config
```json
{
"mcpServers": {
"grepai": {
"command": "grepai",
"args": ["mcp-serve"],
"cwd": "/path/to/your/project"
}
}
}
```
## Multiple Projects
For multiple projects, you can:
### Option 1: Multiple MCP Servers
```json
{
"mcpServers": {
"grepai-frontend": {
"command": "grepai",
"args": ["mcp-serve"],
"cwd": "/path/to/frontend"
},
"grepai-backend": {
"command": "grepai",
"args": ["mcp-serve"],
"cwd": "/path/to/backend"
}
}
}
```
### Option 2: Use Workspaces
```bash
grepai workspace create my-workspace
grepai workspace add my-workspace /path/to/frontend
grepai workspace add my-workspace /path/to/backend
```
```json
{
"mcpServers": {
"grepai": {
"command": "grepai",
"args": ["mcp-serve", "--workspace", "my-workspace"]
}
}
}
```
## Troubleshooting
### Tool Not Available
❌ **Problem:** Claude doesn't see GrepAI tools
✅ **Solutions:**
1. Restart Claude Code after config changes
2. Check MCP config syntax (valid JSON)
3. Verify `grepai` is in PATH
4. Test: `grepai mcp-serve` manually
### Search Returns No Results
❌ **Problem:** Searches return empty
✅ **Solutions:**
1. Ensure `grepai watch` has run
2. Check working directory has `.grepai/`
3. Verify index exists: `grepai status`
### Connection Refused
❌ **Problem:** MCP server won't start
✅ **Solutions:**
1. Check Ollama is running: `curl http://localhost:11434/api/tags`
2. Verify config: `cat .grepai/config.yaml`
3. Run `grepai mcp-serve` manually to see errors
### Wrong Project Indexed
❌ **Problem:** Results from wrong codebase
✅ **Solutions:**
1. Check `cwd` in MCP config
2. Start Claude from correct directory
3. Verify with `grepai_index_status` tool
## Best Practices
1. **Keep index updated:** Run `grepai watch --background`
2. **Use compact mode:** Reduces token usage
3. **Set working directory:** Explicit `cwd` in config
4. **Check status first:** Use `grepai_index_status`
5. **Restart after config:** Claude needs restart for MCP changes
## Removing Integration
To remove GrepAI from Claude Code:
```bash
claude mcp remove grepai
```
Or manually edit `~/.claude/mcp.json` and remove the grepai entry.
## Output Format
Successful MCP setup:
```
✅ GrepAI MCP Integration Configured
Claude Code: ~/.claude/mcp.json
Server: grepai mcp-serve
Status: Connected
Available tools:
- grepai_search (semantic code search)
- grepai_trace_callers (find callers)
- grepai_trace_callees (find callees)
- grepai_trace_graph (call graphs)
- grepai_index_status (index health)
Claude can now search your code semantically!
```
© yoanbernabeu · MIT · yoanbernabeu/grepai-skills