Logo de Ops Codegraph Tool

Ops Codegraph Tool

Organização
optave

Code intelligence CLI — function-level dependency graph across 34 languages, 34-tool MCP server for AI agents, complexity metrics, architecture boundary enforcement, CI quality gates, git diff impact with co-change analysis, hybrid semantic search. Fully local, zero API keys required.

Publicado poroptave
Repositórioops-codegraph-tool
IdiomaTypeScript
Forks
25
Estrelas
97
Ferramentas disponíveis
0
Tipo de transportestdio
LicençaApache-2.0
Links
  • Conecte ferramentas a fluxos de trabalho de IA

    Ops Codegraph Tool disponibiliza recursos MCP que podem ser usados por clientes e agentes de IA compatíveis.

  • 0 ferramentas disponíveis

    Confira abaixo as ações que podem ser chamadas, incluindo nomes e descrições quando fornecidos pelo servidor.

  • Configuração pronta para copiar

    Use os exemplos de instalação para configurar este servidor no seu cliente MCP preferido.

  • Indicadores da comunidade de código aberto

    97 estrelas e 25 forks no repositório vinculado.


The Problem

AI agents face an impossible trade-off. They either spend thousands of tokens reading files to understand a codebase's structure — blowing up their context window until quality degrades — or they assume how things work, and the assumptions are often wrong. Either way, things break. The larger the codebase, the worse it gets.

An agent modifies a function without knowing 9 files import it. It misreads what a helper does and builds logic on top of that misunderstanding. It leaves dead code behind after a refactor. The PR gets opened, and your reviewer — human or automated — flags the same structural issues again and again: "this breaks 14 callers," "that function already exists," "this export is now dead." If the reviewer catches it, that's multiple rounds of back-and-forth. If they don't, it can ship to production. Multiply that by every PR, every developer, every repo.

The information to prevent these issues exists — it's in the code itself. But without a structured map, agents lack the context to get it right consistently, reviewers waste cycles on preventable issues, and architecture degrades one unreviewed change at a time.

What Codegraph Does

Codegraph builds a function-level dependency graph of your entire codebase — every function, every caller, every dependency — and keeps it current with sub-second incremental rebuilds.

It parses your code with tree-sitter (native Rust or WASM), stores the graph in SQLite, and exposes it where it matters most:

  • MCP server — AI agents query the graph directly through 34 tools — one call instead of dozens of grep/find/cat invocations
  • CLI — developers and agents explore, query, and audit code from the terminal
  • CI gates — check and manifesto commands enforce quality thresholds with exit codes
  • Programmatic API — embed codegraph in your own tools via npm install

Instead of an agent editing code without structural context and letting reviewers catch the fallout, it knows "this function has 14 callers across 9 files" before it touches anything. Dead exports, circular dependencies, and boundary violations surface during development — not during review. The result: PRs that need fewer review rounds.

Free. Open source. Fully local. Zero network calls, zero telemetry. Your code stays on your machine. When you want deeper intelligence, bring your own LLM provider — your code only goes where you choose to send it.

Three commands to a queryable graph:

bash
npm install -g @optave/codegraph
cd your-project
codegraph build

No config files, no Docker, no JVM, no API keys, no accounts. Point your agent at the MCP server and it has structural awareness of your codebase.

Why it matters

Without codegraphWith codegraph
Code reviewReviewers flag broken callers, dead code, and boundary violations round after roundStructural issues are caught during development — PRs pass review with fewer rounds
AI agentsModify parseConfig() without knowing 9 files import it — reviewer catches itfn-impact parseConfig shows every caller before the edit — agent fixes it proactively
AI agentsLeave dead exports and duplicate helpers behind after refactorsDead code, cycles, and duplicates surface in real time via hooks and MCP queries
AI agentsProduce code that works but doesn't fit the codebase structurecontext <name> -T returns source, deps, callers, and tests — the agent writes code that fits
CI pipelinesCatch test failures but miss structural degradationcheck --staged fails the build when blast radius or complexity thresholds are exceeded
DevelopersInherit a codebase and grep for hours to understand what calls whatcontext handleAuth -T gives the same structured view agents use
ArchitectsDraw boundary rules that erode within weeksmanifesto and boundaries enforce architecture rules on every commit

Feature comparison

Comparison last verified: August 2026 (full re-verification of every linked repo's live README + GitHub API on 2026-08-09). Full analysis: COMPETITIVE_ANALYSIS.md

Capabilitycodegraph (this repo)code-review-graphnarsil-mcpcodegraph (other)¹claude-contextGitNexus
GitHub stars
Languages3430+3220+ (34 named)²17³14
CLI toolYes (44 commands)YesPartial (config/serve only)⁴Yes— (MCP + library only)Yes
API functionality (embeddable library)Yes——YesYesPartial (HTTP API only)⁵
Dataflow + CFG + AST queryingYesCall graph onlyYes——PDG opt-in, TS/JS only
Interprocedural dataflow (cross-function)Yes⁶—Partial (taint-only)⁷——Partial (taint-only, opt-in)⁸
Hybrid search (BM25 + semantic)YesYesYes (local ONNX, no key needed)Keyword onlyYesYes
Git-aware (diff impact, co-change, branch diff)All 3Partial (co-change unreliable)⁹Partial (no co-change/branch-diff)——Partial (no co-change)
Dead code / role classificationYesYesYes———
Code health (complexity metrics)Yes (cognitive, cyclomatic, Halstead, MI)—Partial (cyclomatic + cognitive)¹⁰———
Incremental rebuildsO(changed)O(changed)**O(changed)**¹¹**O(changed)**¹²**O(changed)**¹³Partial (chunk cache-key)¹⁴
Architecture rules + CI gateYesPartial (risk-gate, no boundary rules)Partial (layer model, no CI gate)———
Security scanning (SAST / vuln detection)Intentionally out of scope¹⁵—Yes——Partial (opt-in taint, --pdg only)
Zero config, npm installYes— (pip)YesYesNo¹⁶Yes
Runtime dependencies (direct packages)¹⁷470¹⁸1023¹⁹36
Graph export (GraphML / Neo4j / DOT)YesYes²⁰Partial²¹———
Open source + commercial useYes (Apache-2.0)Yes (MIT)Yes (Apache-2.0/MIT)Yes (MIT)Yes (MIT)Non-commercial²²

¹ Unrelated tool sharing the name; focuses on AI token reduction via pre-indexed context, not structural analysis or CI gates. ² README says "20+ languages"; architecture docs list 34 across native + fallback grammar tiers. ³ Indexes 17 file extensions by default; AST-aware chunking covers ~10 — the rest fall back to plain text splitting. ⁴ narsil-mcp's CLI only manages config, lists tools, and serves the visualization frontend — no query commands; all graph queries require an MCP client. ⁵ GitNexus's local HTTP API (gitnexus serve, port 4747) only serves its own web UI — no importable library package. ⁶ Variable-level vertex model (arg_in/return_out/def_use) stitched across call edges — general-purpose, not just security, across all 34 languages. ⁷ trace_taint/get_typed_taint_flow cross function calls for security; general dataflow tools (get_data_flow, get_reaching_definitions) are per-function only. ⁸ Optional --pdg index (TS/JS only) adds taint source→sink tracking — security-scoped, not general cross-function flow. ⁹ Per its own README benchmark (2026-08-02), co-change eval returns 0 predicted files on every graded commit — "not yet a usable measurement." ¹⁰ get_complexity covers cyclomatic + cognitive complexity only — no Halstead metrics or maintainability index. ¹¹ Added Merkle-tree incremental indexing + watch mode (previously full re-index). ¹² OS-native file watcher reprocesses only changed files (debounced auto-sync); --force forces a full rebuild. ¹³ Merkle DAG + per-file MD5 hashing skips unchanged files, but each changed file still round-trips to the embedding provider + vector DB. ¹⁴ Cache-keyed, byte-budgeted chunk dispatch with incremental per-branch updates on checkout — finer than a full reprocess, but not per-file hashing. ¹⁵ Structural understanding, not vulnerability detection — use dedicated SAST tools (Semgrep, CodeQL, Snyk). ¹⁶ Requires an external Milvus vector DB + an embedding provider. A local keyless path exists (self-hosted Milvus + Ollama) but needs two running services; the managed path (Zilliz Cloud + OpenAI/VoyageAI/Gemini) trades that for cost. ¹⁷ Direct runtime deps declared in each project's own manifest (package.json/pyproject.toml), excluding dev/optional/transitive deps. ¹⁸ Single compiled binary — no separate packages to install. ¹⁹ mcp + core packages combined — plus the external vector DB + embedding provider noted above. ²⁰ Added GraphML, Neo4j Cypher, Obsidian vault, and SVG export. ²¹ Visualization frontend graph views, plus JSON-LD/N-Quads export for its Code Context Graph — but not GraphML or Neo4j specifically (a repo-wide code search found zero matches for either string); an internal DOT exporter exists (to_dot()) but isn't exposed via CLI or MCP. ²² PolyForm Noncommercial 1.0.0 license; separate commercial/enterprise licensing available.

What makes codegraph different

DifferentiatorIn practice
🤖AI-first architecture34-tool MCP server — agents query the graph directly instead of scraping the filesystem. One call replaces 20+ grep/find/cat invocations
🏷️Role classificationEvery symbol auto-tagged as entry/core/utility/adapter/dead/leaf — agents understand a symbol's architectural role without reading surrounding code
🔬Function-level, not just filesTraces handleAuth() → validateToken() → decryptJWT() and shows 14 callers across 9 files break if decryptJWT changes
⚡Always-fresh graphThree-tier change detection: journal (O(changed)) → mtime+size (O(n) stats) → hash (O(changed) reads). Sub-second rebuilds — agents work with current data
💥Git diff impactcodegraph diff-impact shows changed functions, their callers, and full blast radius — enriched with historically coupled files from git co-change analysis. Ships with a GitHub Actions workflow
🌐Multi-language, one graph34 languages in a single graph — JS/TS, Python, Go, Rust, Java, C#, PHP, Ruby, C/C++, Kotlin, Swift, Scala, Bash, HCL, Elixir, Lua, Dart, Zig, Haskell, OCaml, F#, Gleam, Clojure, Julia, R, Erlang, Solidity, Objective-C, CUDA, Groovy, Verilog — agents don't need per-language tools
🧠Hybrid searchBM25 keyword + semantic embeddings fused via RRF — hybrid (default), semantic, or keyword mode; multi-query via "auth; token; JWT"
🔬Dataflow + CFGTrack how data flows through and between functions — function-level edges (flows_to, returns, mutates), interprocedural variable-level edges (arg_in, return_out, def_use), and intraprocedural control flow graphs — all 34 languages
🔓Fully local, zero costNo API keys, no accounts, no network calls. Optionally bring your own LLM provider — your code only goes where you choose

🚀 Quick Start

bash
npm install -g @optave/codegraph
cd your-project
codegraph build        # → .codegraph/graph.db created

That's it. The graph is ready. Now connect your AI agent.

For AI agents (primary use case)

Connect directly via MCP — your agent gets 34 tools to query the graph:

bash
codegraph mcp          # 34-tool MCP server — AI queries the graph directly

Or add codegraph to your agent's instructions (e.g. CLAUDE.md):

markdown
Before modifying code, always:
1. `codegraph where <name>` — find where the symbol lives
2. `codegraph context <name> -T` — get full context (source, deps, callers)
3. `codegraph fn-impact <name> -T` — check blast radius before editing

After modifying code:
4. `codegraph diff-impact --staged -T` — verify impact before committing

Full agent setup: AI Agent Guide · CLAUDE.md template

For developers

The same graph is available via CLI:

bash
codegraph map          # see most-connected files
codegraph query myFunc # find any function, see callers & callees
codegraph deps src/index.ts  # file-level import/export map

Or install from source:

bash
git clone https://github.com/optave/ops-codegraph-tool.git
cd codegraph && npm install && npm link

Dev builds: Pre-release tarballs are attached to GitHub Releases. Install with npm install -g <path-to-tarball>. Note that npm install -g <tarball-url> does not work because npm cannot resolve optional platform-specific dependencies from a URL — download the .tgz first, then install from the local file.


✨ Features

FeatureDescription
🤖MCP server34-tool MCP server for AI assistants; single-repo by default, opt-in multi-repo
🎯Deep contextcontext gives agents source, deps, callers, signature, and tests for a function in one call; audit --quick gives structural summaries
🏷️Node role classificationEvery symbol auto-tagged as entry/core/utility/adapter/dead/leaf based on connectivity — agents instantly know architectural role
📦Batch queryingAccept a list of targets and return all results in one JSON payload — enables multi-agent parallel dispatch
💥Impact analysisTrace every file affected by a change (transitive)
🧬Function-level tracingCall chains, caller trees, function-level impact, and A→B pathfinding with qualified call resolution
📍Fast lookupwhere shows exactly where a symbol is defined and used — minimal, fast
🔍Symbol searchFind any function, class, or method by name — exact match priority, relevance scoring, --file and --kind filters
📁File dependenciesSee what a file imports and what imports it
📊Diff impactParse git diff, find overlapping functions, trace their callers
🔗Co-change analysisAnalyze git history for files that always change together — surfaces hidden coupling the static graph can't see; enriches diff-impact with historically coupled files
🗺️Module mapBird's-eye view of your most-connected files
🏗️Structure & hotspotsDirectory cohesion scores, fan-in/fan-out hotspot detection, module boundaries
🔄Cycle detectionFind circular dependencies at file or function level
📤ExportDOT, Mermaid, JSON, GraphML, GraphSON, and Neo4j CSV graph export
🧠Semantic searchEmbeddings-powered natural language search with multi-query RRF ranking
👀Watch modeIncrementally update the graph as files change
⚡Always freshThree-tier incremental detection — sub-second rebuilds even on large codebases
🔬Data flow analysisIntraprocedural parameter tracking, return consumers, argument flows, and mutation detection — all 34 languages
🧮Complexity metricsCognitive, cyclomatic, nesting depth, Halstead, and Maintainability Index per function
🏘️Community detectionLeiden clustering to discover natural module boundaries and architectural drift
📜Manifesto rule engineConfigurable pass/fail rules with warn/fail thresholds for CI gates via check (exit code 1 on fail)
👥CODEOWNERS integrationMap graph nodes to CODEOWNERS entries — see who owns each function, ownership boundaries in diff-impact
💾Graph snapshotssnapshot save/restore for instant DB backup and rollback — checkpoint before refactoring, restore without rebuilding
🔎Hybrid BM25 + semantic searchFTS5 keyword search + embedding-based semantic search fused via Reciprocal Rank Fusion — hybrid, semantic, or keyword modes
📄Pagination & NDJSON streamingUniversal --limit/--offset pagination on all MCP tools and CLI commands; --ndjson for newline-delimited JSON streaming
🔀Branch structural diffCompare code structure between two git refs — added/removed/changed symbols with transitive caller impact
🛡️Architecture boundariesUser-defined dependency rules between modules with onion architecture preset — violations flagged in manifesto and CI
✅CI validation predicatescheck command with configurable gates: complexity, blast radius, cycles, boundary violations — exit code 0/1 for CI
📋Composite auditSingle audit command combining explain + impact + health metrics per function — one call instead of 3-4
🚦Triage queuetriage merges connectivity, hotspots, roles, and complexity into a ranked audit priority queue
🔬Dataflow analysisTrack how data moves through and between functions — function-level (flows_to, returns, mutates) and interprocedural variable-level edges (arg_in, return_out, def_use) — all 34 languages, included by default, skip with --no-dataflow
🧩Control flow graphIntraprocedural CFG construction for all 34 languages — cfg command with text/DOT/Mermaid output, included by default, skip with --no-cfg
🔎AST node queryingStored queryable AST nodes (calls, new, string, regex, throw, await) — ast command with SQL GLOB pattern matching
🧬Expanded node/edge typesparameter, property, constant node kinds with parent_id for sub-declaration queries; contains, parameter_of, receiver edge kinds
📊Exports analysisexports <file> shows all exported symbols with per-symbol consumers, re-export detection, and counts
📈Interactive viewercodegraph plot generates an interactive HTML graph viewer with hierarchical/force/radial layouts, complexity overlays, and drill-down
🏷️Stable JSON schemanormalizeSymbol utility ensures consistent 7-field output (name, kind, file, line, endLine, role, fileHash) across all commands

See docs/examples for real-world CLI and MCP usage examples.

📦 Commands

Build & Watch

bash
codegraph build [dir]          # Parse and build the dependency graph
codegraph build --no-incremental  # Force full rebuild
codegraph build --dataflow     # Extract data flow edges (flows_to, returns, mutates)
codegraph build --engine wasm  # Force WASM engine (skip native)
codegraph watch [dir]          # Watch for changes, update graph incrementally

Query & Explore

bash
codegraph query <name>         # Find a symbol — shows callers and callees
codegraph deps <file>          # File imports/exports
codegraph map                  # Top 20 most-connected files
codegraph map -n 50 --no-tests # Top 50, excluding test files
codegraph where <name>         # Where is a symbol defined and used?
codegraph where --file src/db.js  # List symbols, imports, exports for a file
codegraph stats                # Graph health: nodes, edges, languages, quality score
codegraph roles                # Node role classification (entry, core, utility, adapter, dead, leaf)
codegraph roles --role dead -T # Find dead code (unreferenced, non-exported symbols)
codegraph roles --dynamic      # Show dynamic call sink edges (eval, computed-key, unresolved)
codegraph roles --role core --file src/  # Core symbols in src/
codegraph exports src/queries.js  # Per-symbol consumer analysis (who calls each export)
codegraph children <name>         # List parameters, properties, constants of a symbol

Deep Context (designed for AI agents)

bash
codegraph context <name>       # Full context: source, deps, callers, signature, tests
codegraph context <name> --depth 2 --no-tests  # Include callee source 2 levels deep
codegraph brief <file>            # Token-efficient file summary: symbols, roles, risk tiers
codegraph audit <file> --quick    # Structural summary: public API, internals, data flow
codegraph audit <function> --quick  # Function summary: signature, calls, callers, tests

Impact Analysis

bash
codegraph impact <file>        # Transitive reverse dependency trace
codegraph query <name>         # Function-level: callers, callees, call chain
codegraph query <name> --no-tests --depth 5
codegraph fn-impact <name>     # What functions break if this one changes
codegraph path <from> <to>            # Shortest path between two symbols (A calls...calls B)
codegraph path <from> <to> --reverse  # Follow edges backward
codegraph path <from> <to> --depth 5 --kinds calls,imports
codegraph diff-impact          # Impact of unstaged git changes
codegraph diff-impact --staged # Impact of staged changes
codegraph diff-impact HEAD~3   # Impact vs a specific ref
codegraph diff-impact main --format mermaid -T  # Mermaid flowchart of blast radius
codegraph branch-compare main feature-branch    # Structural diff between two refs
codegraph branch-compare main HEAD --no-tests   # Symbols added/removed/changed vs main
codegraph branch-compare v2.4.0 v2.5.0 --json   # JSON output for programmatic use
codegraph branch-compare main HEAD --format mermaid  # Mermaid diagram of structural changes

Co-Change Analysis

Analyze git history to find files that always change together — surfaces hidden coupling the static graph can't see. Requires a git repository.

bash
codegraph co-change --analyze          # Scan git history and populate co-change data
codegraph co-change src/queries.js     # Show co-change partners for a file
codegraph co-change                    # Show top co-changing file pairs globally
codegraph co-change --since 6m         # Limit to last 6 months of history
codegraph co-change --min-jaccard 0.5  # Only show strong coupling (Jaccard >= 0.5)
codegraph co-change --min-support 5    # Minimum co-commit count
codegraph co-change --full             # Include all details

Co-change data also enriches diff-impact — historically coupled files appear in a historicallyCoupled section alongside the static dependency analysis.

Structure & Hotspots

bash
codegraph structure            # Directory overview with cohesion scores
codegraph triage --level file  # Files with extreme fan-in, fan-out, or density
codegraph triage --level directory --sort coupling --no-tests

Code Health & Architecture

bash
codegraph complexity              # Per-function cognitive, cyclomatic, nesting, MI
codegraph complexity --health -T  # Full Halstead health view (volume, effort, bugs, MI)
codegraph complexity --sort mi -T # Sort by worst maintainability index
codegraph complexity --above-threshold -T  # Only functions exceeding warn thresholds
codegraph communities             # Leiden community detection — natural module boundaries
codegraph communities --drift -T  # Drift analysis only — split/merge candidates
codegraph communities --functions # Function-level community detection
codegraph check                   # Pass/fail rule engine (exit code 1 on fail)
codegraph check -T                # Exclude test files from rule evaluation

Dataflow, CFG & AST

bash
codegraph dataflow <name>             # Data flow edges for a function (flows_to, returns, mutates)
codegraph dataflow <name> --impact    # Transitive data-dependent blast radius
codegraph cfg <name>                  # Control flow graph (text format)
codegraph cfg <name> --format dot     # CFG as Graphviz DOT
codegraph cfg <name> --format mermaid # CFG as Mermaid diagram
codegraph ast                         # List all stored AST nodes
codegraph ast "handleAuth"            # Search AST nodes by pattern (GLOB)
codegraph ast -k call                 # Filter by kind: call, new, string, regex, throw, await
codegraph ast -k throw --file src/    # Combine kind and file filters

Note: Dataflow and CFG are included by default for all 34 languages. Use --no-dataflow / --no-cfg for faster builds.

Audit, Triage & Batch

Composite commands for risk-driven workflows and multi-agent dispatch.

bash
codegraph audit <file-or-function>    # Combined structural summary + impact + health in one report
codegraph audit <target> --quick      # Structural summary only (skip impact and health)
codegraph audit src/queries.js -T     # Audit all functions in a file
codegraph explain <target>            # Alias for audit — same output, easier to discover
codegraph triage                      # Ranked audit priority queue (connectivity + hotspots + roles)
codegraph triage -T --limit 20        # Top 20 riskiest functions, excluding tests
codegraph triage --level file -T      # File-level hotspot analysis
codegraph triage --level directory -T # Directory-level hotspot analysis
codegraph batch target1 target2 ...   # Batch query multiple targets in one call
codegraph batch --json targets.json   # Batch from a JSON file

CI Validation

codegraph check provides configurable pass/fail predicates for CI gates and state machines. Exit code 0 = pass, 1 = fail.

bash
codegraph check                             # Run manifesto rules on whole codebase
codegraph check --staged                    # Check staged changes (diff predicates)
codegraph check --staged --rules            # Run both diff predicates AND manifesto rules
codegraph check --staged --cycles           # Fail if staged changes introduce cycles
codegraph check --staged --blast-radius 50  # Fail if blast radius exceeds limit
codegraph check --staged --boundaries       # Fail on architecture boundary violations
codegraph check --staged --signatures       # Fail if an exported declaration's line was modified
codegraph check main                        # Check current branch vs main

CODEOWNERS

Map graph symbols to CODEOWNERS entries. Shows who owns each function and surfaces ownership boundaries.

bash
codegraph owners                   # Show ownership for all symbols
codegraph owners src/queries.js    # Ownership for symbols in a specific file
codegraph owners --boundary        # Show ownership boundaries between modules
codegraph owners --owner @backend  # Filter by owner

Ownership data also enriches diff-impact — affected owners and suggested reviewers appear alongside the static dependency analysis.

Snapshots

Lightweight SQLite DB backup and restore — checkpoint before refactoring, instantly rollback without rebuilding.

bash
codegraph snapshot save before-refactor   # Save a named snapshot
codegraph snapshot list                   # List all snapshots
codegraph snapshot restore before-refactor  # Restore a snapshot
codegraph snapshot delete before-refactor   # Delete a snapshot

Export & Visualization

bash
codegraph export -f dot        # Graphviz DOT format
codegraph export -f mermaid    # Mermaid diagram
codegraph export -f json       # JSON graph
codegraph export -f graphml    # GraphML (XML standard)
codegraph export -f graphson   # GraphSON (TinkerPop v3 / Gremlin)
codegraph export -f neo4j      # Neo4j CSV (bulk import, separate nodes/relationships files)
codegraph export --functions -o graph.dot  # Function-level, write to file
codegraph plot                 # Interactive HTML viewer with force/hierarchical/radial layouts
codegraph cycles               # Detect circular dependencies
codegraph cycles --functions   # Function-level cycles

Semantic Search

Local embeddings for every function, method, and class — search by natural language. Everything runs locally using @huggingface/transformers — no API keys needed. Prefer a remote or self-hosted model instead? Set embeddings.provider: "openai" and llm.baseUrl in your config to call any OpenAI-compatible /embeddings endpoint — see configuration.md.

bash
codegraph embed                # Build embeddings (default: nomic)
codegraph embed --model nomic-v1.5  # Use a different model
codegraph search "handle authentication"
codegraph search "parse config" --min-score 0.4 -n 10
codegraph search "parseConfig" --mode keyword   # BM25 keyword-only (exact names)
codegraph search "auth flow" --mode semantic    # Embedding-only (conceptual)
codegraph search "auth flow" --mode hybrid      # BM25 + semantic RRF fusion (default)
codegraph models               # List available models

Multi-query search

Separate queries with ; to search from multiple angles at once. Results are ranked using Reciprocal Rank Fusion (RRF) — items that rank highly across multiple queries rise to the top.

bash
codegraph search "auth middleware; JWT validation"
codegraph search "parse config; read settings; load env" -n 20
codegraph search "error handling; retry logic" --kind function
codegraph search "database connection; query builder" --rrf-k 30

A single trailing semicolon is ignored (falls back to single-query mode). The --rrf-k flag controls the RRF smoothing constant (default 60) — lower values give more weight to top-ranked results.

Available Models

Per-model retrieval quality (Hit@N) and timing are measured on every release — see EMBEDDING-BENCHMARKS.md.

FlagModelDimensionsSizeLicenseNotes
minilmall-MiniLM-L6-v2384~23 MBApache-2.0Fastest, good for quick iteration
jina-smalljina-embeddings-v2-small-en512~33 MBApache-2.0Better quality, still small
jina-basejina-embeddings-v2-base-en768~137 MBApache-2.0High quality, 8192 token context
jina-codejina-embeddings-v2-base-code768~137 MBApache-2.0Best for code search, trained on code+text
nomic (default)nomic-embed-text-v1768~137 MBApache-2.0Good quality, 8192 context
nomic-v1.5nomic-embed-text-v1.5768~137 MBApache-2.0Matryoshka MRL training (unused — codegraph stores full 768d); v1 scores higher on our benchmark
bge-largebge-large-en-v1.51024~335 MBMITBest general retrieval, top MTEB scores
mxbai-xsmallmxbai-embed-xsmall-v1384~50 MBApache-2.0Tiny + long context (4096)
mxbai-largemxbai-embed-large-v11024~400 MBApache-2.0Top MTEB BERT-large
bge-m3bge-m31024~600 MBMITMultilingual (100+ languages), 8192 context
modernbertmodernbert-embed-base768~150 MBApache-2.0ModernBERT architecture, 8192 ctx, English

The model used during embed is stored in the database, so search auto-detects it — no need to pass --model when searching.

Multi-Repo Registry

Manage a global registry of codegraph-enabled projects. The registry stores paths to your built graphs so the MCP server can query them when multi-repo mode is enabled.

bash
codegraph registry list        # List all registered repos
codegraph registry list --json # JSON output
codegraph registry add <dir>   # Register a project directory
codegraph registry add <dir> -n my-name  # Custom name
codegraph registry remove <name>  # Unregister

codegraph build auto-registers the project — no manual setup needed.

Configuration

Inspect and manage .codegraphrc.json settings.

bash
codegraph config                    # Show all config keys with values and sources
codegraph config --json             # JSON output of the merged config
codegraph config --init             # Scaffold a .codegraphrc.json with all sections pre-populated
codegraph config --edit             # Open .codegraphrc.json in $EDITOR
codegraph config --enable-global    # Opt this repo into user-level global config
codegraph config --disable-global   # Opt this repo out of user-level global config
codegraph config --list-global      # Show the contents of the global config file

A user-level config file at ~/.config/codegraph/config.json (XDG) or ~/.codegraph/config.json lets you set personal defaults once and apply them to opted-in repos. The merge order is: DEFAULTS → global (if consented) → project → env. Non-interactive contexts (CI, MCP) never apply the global config without explicit consent. See docs/guides/configuration.md for full details.

Common Flags

FlagDescription
-d, --db <path>Custom path to graph.db
-T, --no-testsExclude .test., .spec., __test__ files (available on most query commands including query, fn-impact, path, context, where, diff-impact, search, map, roles, co-change, deps, impact, complexity, communities, branch-compare, audit, triage, check, dataflow, cfg, ast, exports, children)
--depth <n>Transitive trace depth (default varies by command)
-j, --jsonOutput as JSON
-v, --verboseEnable debug output
--engine <engine>Parser engine: native, wasm, or auto (default: auto)
-k, --kind <kind>Filter by kind: function, method, class, interface, type, struct, enum, trait, record, module, parameter, property, constant
-f, --file <path>Scope to a specific file (fn, context, where)
--mode <mode>Search mode: hybrid (default), semantic, or keyword (search)
--ndjsonOutput as newline-delimited JSON (one object per line)
--tableOutput as auto-column aligned table
--csvOutput as CSV (RFC 4180, nested objects flattened)
--limit <n>Limit number of results
--offset <n>Skip first N results (pagination)
--rrf-k <n>RRF smoothing constant for multi-query search (default 60)
--user-config [path]Apply global user config for this run; optionally specify a custom path instead of the XDG default (~/.config/codegraph/config.json)
--no-user-configSkip global user config for this run (CI/non-interactive safe)

🌐 Language Support

LanguageExtensionsImportsExportsCall SitesHeritage¹Type Inference²Dataflow
JavaScript.js, .jsx, .mjs, .cjs✓✓✓✓✓✓
TypeScript.ts, .tsx, .mts, .cts✓✓✓✓✓✓
Python.py, .pyi✓✓✓✓✓✓
Go.go✓✓✓✓✓✓
Rust.rs✓✓✓✓✓✓
Java.java✓✓✓✓✓✓
C#.cs✓✓✓✓✓✓
PHP.php, .phtml✓✓✓✓✓✓
Ruby.rb, .rake, .gemspec✓✓✓✓—³✓
C.c, .h✓✓✓—⁴—⁴✓
C++.cpp, .hpp, .cc, .cxx✓✓✓✓—✓
Kotlin.kt, .kts✓✓✓✓—✓
Swift.swift✓✓✓✓—✓
Scala.scala, .sc✓✓✓✓—✓
Bash.sh, .bash✓✓✓—⁴—⁴✓
Elixir.ex, .exs✓✓✓——✓
Lua.lua✓✓✓——✓
Dart.dart✓✓✓✓—✓
Zig.zig✓✓✓——✓
Haskell.hs✓✓✓——✓
OCaml.ml, .mli✓✓✓——✓
F#.fs, .fsx, .fsi✓✓✓——✓
Gleam.gleam✓✓✓——✓
Clojure.clj, .cljs, .cljc✓✓✓——✓
Julia.jl✓✓✓——✓
R.r, .R✓✓✓——✓
Erlang.erl, .hrl✓✓✓——✓
Solidity.sol✓✓✓✓—✓
Objective-C.m✓✓✓✓—✓
CUDA.cu, .cuh✓✓✓✓—✓
Groovy.groovy, .gvy✓✓✓✓—✓
Verilog.v, .sv✓✓✓——✓
Terraform.tf, .hcl✓—³—³—³—³—³

¹ Heritage = extends, implements, include/extend (Ruby), trait impl (Rust), receiver methods (Go). ² Type Inference extracts a per-file type map from annotations (const x: Router, MyType x, x: MyType) and new expressions, enabling the edge resolver to connect x.method() → Type.method(). ³ Not applicable — Ruby is dynamically typed; Terraform/HCL is declarative (no functions, classes, or type system). ⁴ Not applicable — C and Bash have no class/inheritance system. All languages have full parity between the native Rust engine and the WASM fallback.

⚙️ How It Works

┌──────────┐    ┌───────────┐    ┌───────────┐    ┌──────────┐    ┌─────────┐
│  Source  │──▶│ tree-sitter│──▶│  Extract  │──▶│  Resolve │──▶│ SQLite  │
│  Files   │    │   Parse   │    │  Symbols  │    │  Imports │    │   DB    │
└──────────┘    └───────────┘    └───────────┘    └──────────┘    └─────────┘
                                                                       │
                                                                       ▼
                                                                 ┌─────────┐
                                                                 │  Query  │
                                                                 └─────────┘
  1. Parse — tree-sitter parses every source file into an AST (native Rust engine or WASM fallback)
  2. Extract — Functions, classes, methods, interfaces, imports, exports, call sites, parameters, properties, and constants are extracted
  3. Resolve — Imports are resolved to actual files (handles ESM conventions, tsconfig.json path aliases, baseUrl)
  4. Store — Everything goes into SQLite as nodes + edges with tree-sitter node boundaries, plus structural edges (contains, parameter_of, receiver)
  5. Analyze (opt-in) — Complexity metrics, control flow graphs (--cfg), dataflow edges (--dataflow), and AST node storage
  6. Query — All queries run locally against the SQLite DB — typically under 100ms

Incremental Rebuilds

The graph stays current without re-parsing your entire codebase. Three-tier change detection ensures rebuilds are proportional to what changed, not the size of the project:

  1. Tier 0 — Journal (O(changed)): If codegraph watch was running, a change journal records exactly which files were touched. The next build reads the journal and only processes those files — zero filesystem scanning
  2. Tier 1 — mtime+size (O(n) stats, O(changed) reads): No journal? Codegraph stats every file and compares mtime + size against stored values. Matching files are skipped without reading a single byte
  3. Tier 2 — Hash (O(changed) reads): Files that fail the mtime/size check are read and MD5-hashed. Only files whose hash actually changed get re-parsed and re-inserted

Result: change one file in a 3,000-file project and the rebuild completes in under a second. Put it in a commit hook, a file watcher, or let your AI agent trigger it.

What incremental rebuilds refresh — and what they don't

Incremental builds re-parse changed files and rebuild their edges, structure metrics, and role classifications. But some data is only fully refreshed on a full rebuild:

DataIncrementalFull rebuild
Symbols & edges for changed filesYesYes
Reverse-dependency cascade (importers of changed files)YesYes
AST nodes, complexity, CFG, dataflow for changed filesYesYes
Directory-level cohesion metricsPartial (skipped for ≤5 files)Yes
Advisory checks (orphaned embeddings, stale embeddings, unused exports)SkippedYes
Build metadata persistenceSkipped for ≤3 filesYes
Incremental drift detectionSkippedYes

When to run a full rebuild:

bash
codegraph build --no-incremental   # Force full rebuild
  • After large refactors (renames, moves, deleted files) — the reverse-dependency cascade handles most cases, but a full rebuild ensures nothing is stale
  • If you suspect stale analysis data — complexity or dataflow results for files you didn't directly edit won't update incrementally
  • If codegraph info nudges you — it flags when an interface gained its first instantiated implementor since the last full build, a narrow CHA/RTA dispatch-edge gap incremental rebuilds can't self-heal (see incremental-builds.md)
  • Periodically — if you rely heavily on complexity, dataflow, roles --role dead, or communities queries, run a full rebuild weekly or after major merges
  • After upgrading codegraph — engine, schema, or version changes trigger an automatic full rebuild, but if you skip versions you may want to force one

Codegraph auto-detects and forces a full rebuild when the engine, schema version, or codegraph version changes between builds. For everything else, incremental is the safe default — a full rebuild is a correctness guarantee, not a frequent necessity.

Detailed guide: See docs/guides/incremental-builds.md for a complete breakdown of what each build mode refreshes and recommended rebuild schedules.

Dual Engine

Codegraph ships with two parsing engines:

EngineHow it worksWhen it's used
Native (Rust)napi-rs addon built from crates/codegraph-core/ — parallel multi-core parsing via rayonAuto-selected when the prebuilt binary is available
WASMweb-tree-sitter with pre-built .wasm grammars in grammars/Fallback when the native addon isn't installed

Both engines produce identical output. Use --engine native|wasm|auto to control selection (default: auto).

On the native path, Rust handles the entire hot pipeline end-to-end:

PhaseWhat Rust does
ParseParallel multi-file tree-sitter parsing via rayon (3.5× faster than WASM)
ExtractSymbols, imports, calls, classes, type maps, AST nodes — all in one pass
AnalyzeComplexity (cognitive, cyclomatic, Halstead), CFG, and dataflow pre-computed per function during parse
ResolveImport resolution with 6-level priority system and confidence scoring
EdgesCall, receiver, extends, and implements edge inference
DB writesAll inserts (nodes, edges, AST nodes, complexity, CFG, dataflow) via rusqlite — better-sqlite3 is lazy-loaded only for the WASM fallback path

The Rust crate (crates/codegraph-core/) exposes a NativeDatabase napi-rs class that holds a persistent rusqlite::Connection for the full build lifecycle, eliminating JS↔SQLite round-trips on every operation.

Call Resolution

Calls are resolved with qualified resolution — method calls (obj.method()) are distinguished from standalone function calls, and built-in receivers (console, Math, JSON, Array, Promise, etc.) are filtered out automatically. Import scope is respected: a call to foo() only resolves to functions that are actually imported or defined in the same file, eliminating false positives from name collisions.

PrioritySourceConfidence
1Import-aware — import { foo } from './bar' → link to bar1.0
2Same-file — definitions in the current file1.0
3Same directory — definitions in sibling files (standalone calls only)0.7
4Same parent directory — definitions in sibling dirs (standalone calls only)0.5
5Method hierarchy — resolved through extends/implementsvaries

Method calls on unknown receivers skip global fallback entirely — stmt.run() will never resolve to a standalone run function in another file. Duplicate caller/callee edges are deduplicated automatically. Dynamic patterns like fn.call(), fn.apply(), fn.bind(), and obj["method"]() are also detected on a best-effort basis.

Codegraph also extracts symbols from common callback patterns: Commander .command().action() callbacks (as command:build), Express route handlers (as route:GET /api/users), and event emitter listeners (as event:data).

📊 Performance

Self-measured on every release via CI (build benchmarks | [embedding benchmarks](generated/benchmarks/EMBEDDING-BENCHMARKS.

Use o MCP de Ops Codegraph Tool com vários modelos de IA

O TypingMind conecta as ferramentas MCP no nível do espaço de trabalho. Assim, após conectar Ops Codegraph Tool, é possível usá-lo com diferentes modelos de IA no TypingMind, em vez de configurá-lo separadamente para cada modelo. Este MCP é executado localmente no seu dispositivo por meio do conector MCP do TypingMind.

Guia de configuração para usar o conector local

Use esta opção quando o servidor MCP precisar acessar arquivos locais, aplicativos ou recursos privados no seu computador.

1

Abra as configurações de MCP

No TypingMind, vá até Configurações, Configurações avançadas e depois Model Context Protocol e selecione Configurar conector.

  1. Abra o TypingMind no navegador.
  2. Clique no ícone de Ajustes.
  3. Acesse Configurações avançadas.
  4. Abra a seção Model Context Protocol.
  5. Clique em Configurar conector e selecione Este dispositivo.
Tela de configuração do conector MCP do TypingMind com a opção Este dispositivo selecionada
2

Execute o comando do conector

Selecione Este dispositivo, copie o comando do TypingMind e execute-o no Terminal. Mantenha o processo em execução enquanto usa o MCP.

  1. Copie o comando de configuração exibido pelo TypingMind.
  2. Abra o Terminal no macOS ou o Windows Terminal no Windows.
  3. Cole e execute o comando.
  4. Autorize a instalação do pacote se o Terminal pedir confirmação para continuar.
  5. Mantenha o processo em execução na janela do Terminal enquanto usa as ferramentas MCP.
3

Adicione Ops Codegraph Tool como servidor

Quando o status do conector for Pronto, clique em Editar e cole a configuração do servidor MCP.

  1. Aguarde até que o status do conector mostre Pronto.
  2. Clique em Editar.
  3. Cole a configuração do servidor MCP de Ops Codegraph Tool.
  4. Salve a lista de servidores.
  5. Atualize para confirmar se o conector ainda está pronto para uso.
Configurações de MCP do TypingMind mostrando um servidor ativo e o botão Editar
{
  "mcpServers": {
    "ops-codegraph-tool": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use a conexão com diferentes modelos

Salve a lista de servidores, abra Plugins, ative as ferramentas MCP de Ops Codegraph Tool, selecione qualquer modelo de IA compatível no TypingMind e use as ferramentas no chat ou atribua-as a um agente de IA.

  1. Abra a página Plugins no TypingMind.
  2. Ative as ferramentas MCP de Ops Codegraph Tool.
  3. Inicie um chat e escolha o modelo de IA que deseja usar.
  4. Use as ferramentas MCP no chat ou atribua-as a um agente de IA.
  5. Mude para outro modelo de IA sempre que necessário, sem reconectar o MCP.
Chat do TypingMind usando ferramentas MCP ativadas com um modelo de IA selecionado
Pode usar Ops Codegraph Tool para me ajudar nesta tarefa?
Ops Codegraph Tool
Claro. Já li.
Veja o que encontrei usando Ops Codegraph Tool.

Perguntas frequentes

Para que serve o servidor MCP Ops Codegraph Tool?

Ops Codegraph Tool é um servidor MCP que permite que aplicativos de IA compatíveis se conectem a ferramentas externas e informações de contexto. No TypingMind, basta adicionar esse servidor MCP uma vez para disponibilizar suas ferramentas no seu espaço de trabalho com IA.

Posso usar o MCP Ops Codegraph Tool com vários modelos de IA no TypingMind?

Sim. O TypingMind conecta as ferramentas MCP no nível do espaço de trabalho, permitindo usar Ops Codegraph Tool com diferentes modelos de IA, como Claude, ChatGPT, Gemini ou outros modelos configurados no TypingMind, sem configurar o servidor MCP separadamente para cada modelo.

Por que usar o MCP Ops Codegraph Tool com o TypingMind?

O TypingMind é uma das melhores interfaces de chat com LLMs porque reúne vários modelos de IA, prompts, plugins, agentes de IA, chaves de API e ferramentas MCP em um só espaço de trabalho. Com Ops Codegraph Tool conectado, é possível usar suas ferramentas MCP nos seus modelos preferidos e manter seu fluxo de trabalho de chat organizado no TypingMind.

Como conecto o MCP Ops Codegraph Tool ao TypingMind?

Ops Codegraph Tool funciona por meio do conector MCP local do TypingMind. Essa é a melhor opção quando o servidor MCP precisa acessar arquivos locais, apps de desktop, ferramentas de linha de comando ou recursos privados no seu computador.

Quais ferramentas o MCP Ops Codegraph Tool oferece no TypingMind?

Ops Codegraph Tool disponibiliza recursos MCP que podem ser ativados na página Plugins do TypingMind e usados no chat ou atribuídos a agentes de IA.

Preciso compartilhar minhas chaves de API com o TypingMind para usar o MCP Ops Codegraph Tool?

Não. O TypingMind prioriza o uso local e permite manter seus provedores de modelos, chaves de API, prompts e configuração MCP sob seu controle. Se Ops Codegraph Tool exigir autenticação, adicione os cabeçalhos, as configurações OAuth ou a configuração local exigidos por esse servidor MCP ao criar a conexão.

Servidores MCP relacionados

Ver todos

Crie seu próprio espaço de IA agora

Inscreva-se na nossa newsletter para receber novidades sobre recursos e futuros sorteios 👇