para-graph is a deterministic code analysis tool that extracts structural information from TypeScript 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.
- Deterministic parsing β Tree-sitter AST, no 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)
# Clone
git clone https://github.com/pageel/para-graph.git
cd para-graph
# Install
npm install
# Build
npm run build
# Scan any TypeScript 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 TypeScript 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/workspace// 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
β βββ resources.ts # MCP resources: JSONL file access
βββ parser/
β βββ tree-sitter-parser.ts # AST parsing and entity extraction
β βββ file-walker.ts # Recursive TypeScript file scanner
βββ queries/
βββ typescript.scm # Tree-sitter query patterns
TypeScript files β File Walker β Tree-sitter Parser β 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 |
| 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 | Documentation & Stable Release | π Planned |
