What ozgurcd/gograph does
ozgurcd/gograph analyzes Go repositories as structured graphs rather than treating them as collections of text files. It indexes syntax and can add type-checked call relationships through CHA/SSA analysis. Queries can cover symbols, callers and callees, interface implementations, struct field mutations, HTTP routes, static PostgreSQL queries, error origins, package coupling, and dependency paths.
The project combines a command-line interface with a built-in stdio MCP server. The CLI supports repository summaries, hotspot and coupling reports, blast-radius analysis, source extraction, targeted test selection, coverage-gap reports, API comparison, package-boundary checks, architecture policies, and Mermaid graph output. MCP exposes the repository query, analysis, and workflow capabilities as project tools, along with session lifecycle tools. A separate workspace mode can query multiple independently indexed repositories through a deterministic cross-repository overlay.
How it works
Run gograph build . to create the repository graph. Adding --precise enables type-checked CHA/SSA enrichment; --strict makes a precise build fail if it falls back. The CLI stores its normal graph under .gograph/graph.json and uses metadata to determine whether a rebuild is needed. Queries can target symbols by name or by selectors such as path/to/file.go:Name and file.go:Receiver.Method.
gograph mcp . starts the built-in stdio server without requiring a separate build command. It creates an in-memory graph on first use and incrementally reparses changed packages before answering queries. Starting it with --persist-refresh enables disk persistence for refreshes. The CLI can also inspect another commit, branch, or tag with --rev, and can emit structured JSON, file-only results, or Mermaid diagrams for supported analyses.
Test selection follows changed code through the graph and can produce runnable go test -run commands. Options support transitive selection, package narrowing, skipping tests that already passed on identical inputs, early stopping, and coverage reports. Security-flow analysis traces configured source-to-sink paths, while architecture commands evaluate import boundaries and policy thresholds.
Setup and configuration
Install with Homebrew:
brew install --cask ozgurcd/tap/gograph
Or install the command with Go:
go install github.com/ozgurcd/gograph/cmd/gograph@latest
Build and inspect a repository with:
gograph build . --precise
gograph stats
gograph doctor --json
Start the MCP transport from the repository directory with gograph mcp .. The Go toolchain is used for module and package-loading context. Offline operation can be configured with GOPROXY=off GOTOOLCHAIN=local. Build selection also supports tags, excluded directories, low-memory mode, and an explicit memory limit. Architecture gate thresholds are configured in .gograph.yml; security-flow sanitizer rules use gograph/flow.json.
Tools and capabilities
- Trace direct and transitive callers, callees, paths, and interface implementations.
- Identify changed-code test targets and untested production paths.
- Render graph slices as text, JSON, file lists, or Mermaid diagrams.
- Inspect repository hotspots, coupling, flows, and package relationships.
- Enforce package boundaries, complexity limits, instability limits, and other policy predicates.
- Compare exported API surfaces against a revision and analyze workspace-wide relationships.
Limitations and notes
Analysis is local: gograph does not run target code or transmit source or telemetry to hosted services. Precise analysis depends on the installed Go toolchain and the repository's build context. Files excluded from that context can still be printed with source queries but are not indexed. MCP refreshes are in memory by default, while persistence requires the explicit --persist-refresh option. Workspace member refresh and overlay publication are CLI mutations; the workspace MCP tools are read-only.
The CLI and MCP interfaces have different scopes. Process, host, artifact, build, validation, gate, snapshot, installation, startup, version, and help operations remain CLI-only, while repository analysis and workflow commands have MCP equivalents.