code-rag-golang
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.
README
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.
<!-- TODO: Add a GIF/screenshot of Web UI here -->
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: embeddedvis.js
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.