Structural code analysis tool powered by Tree-sitter AST parsing.
para-graph is a deterministic code analysis tool that extracts structural information from multi-language codebases and produces a knowledge graph in JSONL format.
It uses Tree-sitter for fast, accurate AST parsing β no compiler pipeline required. The output graph captures:
- Entities β classes, functions, interfaces, arrow functions, methods
- Relationships β imports, function calls, inheritance (future)
Part of the PARA Workspace ecosystem.
- Node.js >= 18.0.0
- TypeScript 5.x
- Tree-sitter (native bindings compiled automatically via
node-gyp-build)
- Multi-Language Support β TypeScript, TSX, Python π, Bash π, Go πΉ, PHP π
- Deterministic parsing β Tree-sitter AST & Pure SSEC Queries, no LLM heuristics
- JSONL output β one entity/relation per line, easy to stream and process
- Global Workspace Server β Serve multiple project graphs simultaneously via MCP
- Semantic Enrichment β Agent-driven context tagging (summary, complexity, domain concepts)
- Fast In-Memory Query Engine β Indexed lookups with LRU cache (Max=3 projects)
- Impact Analysis β BFS traversal to find all affected nodes when changing a code entity
- Context Bundle β Get source code, callers, callees, imports, and tests in one MCP call
- Agentic Edge Resolution β Inject missing relationships (e.g., dynamic Bash imports) directly via MCP
- MCP Auto-Setup β Manifest-declared
mcp:block enables automatic IDE configuration via./para mcp-setup
# Clone
git clone https://github.com/pageel/para-graph.git
cd para-graph
# Install
npm install
# Build
npm run build
# Scan any supported project
npx para-graph build /path/to/your/ts/project ./outputOr run directly without cloning:
npx para-graph build ./src ./output# Scan source code and export graph
para-graph build <target-dir> [output-dir] [--import]
# Start MCP server for AI Agent integration
para-graph serve <workspace-root>
# Show help
para-graph --help# Basic usage
para-graph build ./src # Output to ./output/
para-graph build ./src ./my-graph # Custom output directory
para-graph build ./src ./out --import # Preserve semantic data on re-scan| Argument | Required | Default | Description |
|---|---|---|---|
target-dir |
β | β | Directory containing supported source files |
output-dir |
β | ./output |
Where to write the graph output |
--import |
β | β | Load existing graph, preserve semantic enrichment data |
# Start MCP server (stdio transport)
para-graph serve /path/to/workspaceTo connect para-graph to an AI Agent editor (like Claude Desktop, Cursor, or Google Antigravity), you need to configure their respective MCP settings.
If you are using PARA Workspace v1.8.2+, you can automatically configure the MCP server in your IDE by running:
./para mcp-setupThis will safely detect your active IDE and inject the para-graph MCP server configuration.
If you prefer to configure the server manually:
Edit your claude_desktop_config.json (or mcp_config.json for Antigravity) and add the following:
{
"mcpServers": {
"para-graph": {
"command": "<ABSOLUTE_WORKSPACE_PATH>/cli/para",
"args": [
"graph",
"serve",
"<ABSOLUTE_WORKSPACE_PATH>"
]
}
}
}Note: Replace <ABSOLUTE_WORKSPACE_PATH> with the absolute path to your PARA Workspace root directory.
Go to Cursor Settings > Features > MCP Servers > Add New MCP Server:
- Name:
para-graph - Type:
command - Command:
<ABSOLUTE_WORKSPACE_PATH>/cli/para graph serve <ABSOLUTE_WORKSPACE_PATH>
Once connected, your AI Agent gains access to the following tools:
graph_query: Search entities by name or semantic type.graph_edges: Find function callers and imports.graph_enrich: Automatically save documentation and complexity data into the graph.graph_impact_analysis: Discover upstream/downstream impacted files when changing code.graph_context_bundle: Get the entire context of a code snippet in one call.
// Import as a library
import { CodeGraph } from 'para-graph';
// Import MCP server factory
import { createServer } from 'para-graph/mcp';Three files are generated in the output directory:
One code entity per line, sorted by file path:
{"id":"src/graph/code-graph.ts::CodeGraph","type":"class","name":"CodeGraph","filePath":"src/graph/code-graph.ts","startLine":10,"endLine":81,"exportType":"named","signature":"export class CodeGraph {"}One relationship per line, sorted by source file:
{"sourceId":"src/index.ts","targetId":"./parser/file-walker.js","relation":"IMPORTS_FROM","sourceFile":"src/index.ts","sourceLine":3}Summary statistics:
{
"version": "0.1.0",
"nodeCount": 31,
"edgeCount": 47,
"fileCount": 6,
"createdAt": "2026-04-21T03:35:33.508Z"
}| Type | Description |
|---|---|
file |
Source file |
class |
Class declaration |
function |
Function, method, or arrow function |
interface |
Interface declaration |
variable |
Variable declaration (future) |
| Relation | Description |
|---|---|
IMPORTS_FROM |
File imports from another module |
CALLS |
Function/method calls another function |
INHERITS |
Class extends another (future) |
IMPLEMENTS |
Class implements interface (future) |
src/
βββ cli.ts # Subcommand router (shebang entrypoint)
βββ commands/
β βββ build.ts # Build command β scan, parse, export graph
β βββ serve.ts # Serve command β MCP server lifecycle
βββ graph/
β βββ models.ts # GraphNode, GraphEdge type definitions
β βββ code-graph.ts # In-memory graph with dual indexing
β βββ jsonl-exporter.ts # Serialize graph β JSONL files
β βββ jsonl-importer.ts # Load graph from JSONL files
β βββ graph-store.ts # LRU cache manager for multi-project graphs
βββ mcp/
β βββ server.ts # MCP server factory (pure library export)
β βββ tools.ts # MCP tools: query, edges, enrich, impact_analysis, context_bundle, add_edges
β βββ resources.ts # MCP resources: JSONL file access
βββ parser/
β βββ registry.ts # Language Registry (lazy-loads parsers by extension)
β βββ tree-sitter-parser.ts # AST parsing and SSEC mapping engine
β βββ file-walker.ts # Recursive multi-language file scanner
βββ queries/
βββ typescript.scm # SSEC query patterns for TS/TSX
βββ python.scm # SSEC query patterns for Python
βββ go.scm # SSEC query patterns for Go
βββ php.scm # SSEC query patterns for PHP
βββ bash.scm # SSEC query patterns for Bash
Source files β File Walker β Registry Lookup β Tree-sitter Parser + SSEC Query β CodeGraph (in-memory) β JSONL Export
β
GraphStore (LRU)
β
MCP Server β AI Agent
# Install dependencies
npm install
# Run in development
npm run dev
# Build TypeScript
npm run build
# Run tests
npm run test| Component | Technology |
|---|---|
| Runtime | Node.js β₯ 18 |
| Language | TypeScript 5.x (strict mode) |
| AST Parser | tree-sitter + tree-sitter-typescript |
| Test Runner | Vitest |
| Dev Runner | tsx |
This tool bundles AI intelligence artifacts that enhance the PARA Workspace agent experience. When installed via ./para install-tool para-graph, these artifacts are automatically installed into your workspace's .agents/ directory:
| Type | Name | Version | Description & Usage |
|---|---|---|---|
| Workflow | /para-graph |
1.8.0 | Type @[/para-graph] to instruct the AI to re-scan and update the graph memory. |
| Skill | graph-enrichment |
1.0.0 | Loaded on-demand when the agent reads graph data. Guides the agent to semantically enrich graph nodes (add summaries, complexity scores). |
| Rule | graph-first-policy |
1.0.0 | Enforces graph-first development practices. The agent will proactively query the MCP server before making architecture decisions. |
Requires PARA Workspace v1.8.2+ for automatic MCP auto-setup detection.
| Phase | Description | Status |
|---|---|---|
| P1 | Structural Base (Tree-sitter AST) | β Done |
| P2 | Semantic Enrichment (Agent-Driven) | β Done |
| P3 | Storage & Query Engine | β Done |
| P4 | CLI Integration & NPM Package | β Done |
| P5 | Multi-language Support & Query Refactor | β Done |
| P6 | Impact & Context Queries | β Done |
| P7 | Agentic Bash Edge Resolution | β Done |
| P8 | Deep CALLS + Pattern Detection | π Planned |
| P9 | Documentation & Stable Release (v1.0.0) | π Planned |