MCP server/ai-tools

Code RAG Golang MCP Server

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

★ 1nullptr-z/code-rag-golang ↗by nullptr-zupdated
Manual setup required. The maintainer's config contains paths only you know - edit the placeholders below before adding it to Claude Code.
1

Prepare the server locally

Run this once before adding it to Claude Code.

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

Register it in Claude Code

claude mcp add code-rag-golang -- crag mcp -d /absolute/path/.crag.db

Replace any placeholder paths in the command with the real path on your machine.

3

Make your agent remember this setup

code-rag-golang's config, env vars, and the gotchas you hit — recalled in every future Claude Code, Cursor, and Codex session.

npx conare@latest

Free · one command · indexes the sessions already on disk. Set up in the browser instead →

What it does

  • 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

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.

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.
Original README from nullptr-z/code-rag-golang

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

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.

Conare · memory for coding agents

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.

Set up free$npx conare@latest