Skip to main content

CLI reference

The graphlens command, provided by graphlens-cli. This page is the exhaustive flag reference; for a task-oriented tour see the CLI guide.

pip install "graphlens-cli[all]"
graphlens --help

The app runs no-args-is-help, so graphlens with no subcommand prints usage.


graphlens analyze

Parse a project and print statistics or serialize the graph.

graphlens analyze ROOT [OPTIONS]
Argument / OptionTypeDefaultDescription
ROOTpathProject root to analyse (must exist, be a directory)
--langstrautoAdapter(s) to use: auto | python | typescript | comma-separated
--format, -fstrtextOutput format: text (stats) or json (serialized graph)
--output, -opathWrite the serialized graph (JSON) to this path
--strictflagoffExit non-zero if the resolver status is not ok

graphlens query

Run a query against a saved graph.

graphlens query NODE --graph GRAPH [OPTIONS]
Argument / OptionTypeDefaultDescription
NODEstrNode id, qualified name, or short name
--graph, -gpathPath to a graph JSON file (from analyze --output) — required
--opstrcallerscallers | callees | references | neighbors
--depthint1Hop depth for the neighbors operation

graphlens visualize

Build an interactive HTML graph viewer.

graphlens visualize ROOT [OPTIONS]
Argument / OptionTypeDefaultDescription
ROOTpathProject root to analyse
--langstrautoAdapter(s) to use
--output, -opathgraph-<name>.htmlOutput HTML file
--no-openflagoffDo not open the browser automatically
--show-externalflagoffInclude stdlib/third-party external symbol nodes
--show-structureflagoffInclude CONTAINS/DECLARES structural edges
--max-nodesint1500Prune low-degree nodes above this count (min 1)

graphlens neo4j

Export the graph to a Neo4j database. Requires the neo4j extra (pip install "graphlens-cli[neo4j]").

graphlens neo4j ROOT [OPTIONS]
Argument / OptionTypeDefaultDescription
ROOTpathProject root to analyse
--langstrautoAdapter(s) to use
--uristrbolt://localhost:7687Neo4j Bolt URI
--userstrneo4jNeo4j username
--passwordstrpasswordNeo4j password
--wipe / --no-wipeflag--no-wipeWipe :Code nodes first
--batch-sizeint500Items per Cypher batch (min 1)

graphlens mcp

Serve a saved graph to agents over the Model Context Protocol. Requires the mcp extra (pip install "graphlens-cli[mcp]").

graphlens mcp --graph GRAPH
OptionTypeDefaultDescription
--graph, -gpathPath to a graph JSON file (from analyze --output) — required

Exposed MCP tools: stats, find, callers, callees, references, neighbors, boundaries, communicates_with. See the MCP server guide.