Code RAG Golang MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
git clone https://github.com/zheng/crag.git
cd crag
go install ./cmd/crag
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add code-rag-golang -- node "<FULL_PATH_TO_CODE_RAG_GOLANG>/dist/index.js"

Replace <FULL_PATH_TO_CODE_RAG_GOLANG>/dist/index.js with the actual folder you prepared in step 1.

README.md

Build precise call graphs via static analysis for AI-assisted Go development.

crag - Call Graph for AI-Assisted Go Development

AI modifies a function but misses 5 callers that also need updating. crag fixes this — it builds precise call graphs via static analysis, so AI knows exactly what's affected before making changes.

How It Works

crag analyze .          # Build call graph using SSA + VTA static analysis
                        # → Stored in SQLite, fast to query

AI: "Modify ProcessRequest"
 → crag automatically finds all 5 callers
 → AI updates them together, nothing missed

Install

git clone https://github.com/zheng/crag.git
cd crag
go install ./cmd/crag

Quick Start

# 1. Analyze your Go project
crag analyze . -o .crag.db

# 2. Configure MCP for your AI editor (Cursor / Claude Code)
# Add to .cursor/mcp.json or claude_desktop_config.json:
{
  "mcpServers": {
    "crag": {
      "command": "crag",
      "args": ["mcp", "-d", "/absolute/path/.crag.db"]
    }
  }
}
# 3. Keep it updated (pick one)
crag watch . -d .crag.db          # Auto-update on file changes
# or: add `crag analyze . -i` to .git/hooks/post-commit

That's it. Your AI editor can now query call graphs directly.

What AI Can Do With crag

After MCP setup, just ask naturally:

  • "Where is HandleRequest called?" → upstream callers
  • "If I change BuildSSA, what's affected?" → impact analysis
  • "Find all functions containing Auth" → search

CLI Usage

crag impact "HandleRequest" -d .crag.db    # Impact analysis (callers + callees)
crag upstream "db.Query" -d .crag.db       # Who calls this? (recursive)
crag downstream "Process" -d .crag.db      # What does this call?
crag search "Handler" -d .crag.db          # Search functions by name
crag risk -d .crag.db                      # Show high-risk functions
crag implements -d .crag.db                # Interface implementations
crag view -d .crag.db                      # Web UI visualization
crag export -d .crag.db -o crag.md         # Export as Markdown (RAG context)

Why crag?

Text search (grep) IDE (gopls) crag
Interface calls miss partial VTA precise resolution
Persisted & queryable no no SQLite
AI integration manual copy no MCP native
Incremental update n/a n/a Git-aware
Zero CGO n/a n/a Pure Go SQLite

Tech

  • Analysis: Go SSA + VTA (Variable Type Analysis) via golang.org/x/tools
  • Storage: modernc.org/sqlite (pure Go, single binary)
  • CLI: cobra · Web UI: embedded vis.js

License

MIT

Tools (6)

impactPerform impact analysis to find callers and callees of a function.
upstreamFind recursive upstream callers of a function.
downstreamFind what a specific function calls.
searchSearch for functions by name.
riskShow high-risk functions in the codebase.
implementsList interface implementations.

Configuration

claude_desktop_config.json
{"mcpServers": {"crag": {"command": "crag", "args": ["mcp", "-d", "/absolute/path/.crag.db"]}}}

Try it

Where is the HandleRequest function called in this project?
If I modify the BuildSSA function, what other parts of the code are affected?
Find all functions in the codebase that contain the word 'Auth'.
List all high-risk functions identified by the static analysis.
Show me all implementations of the current interface.

Frequently Asked Questions

What are the key features of Code RAG Golang?

Builds precise call graphs using SSA and VTA static analysis. Persists analysis data in a queryable SQLite database. Provides impact analysis to identify affected callers before code changes. Supports incremental updates via file watching or git hooks. Exports call graph data as Markdown for RAG context.

What can I use Code RAG Golang for?

Ensuring AI refactoring tools update all callers when a function signature changes. Performing impact analysis to understand the scope of a proposed code change. Searching for specific function implementations across a large Go codebase. Identifying high-risk areas of the code that require extra testing.

How do I install Code RAG Golang?

Install Code RAG Golang by running: git clone https://github.com/zheng/crag.git && cd crag && go install ./cmd/crag

What MCP clients work with Code RAG Golang?

Code RAG Golang works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Code RAG Golang docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare