# Code Graph

> Pre-indexed code knowledge graph for Claude Code, Codex, OpenCode — fewer tokens, fewer tool calls, 100% local. Perfect for code exploration

- **Type:** MCP server
- **Install:** `agentstack add mcp-valarpirai-code-graph`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [valarpirai](https://agentstack.voostack.com/s/valarpirai)
- **Installs:** 0
- **Category:** [Integrations](https://agentstack.voostack.com/c/integrations)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [valarpirai](https://github.com/valarpirai)
- **Source:** https://github.com/valarpirai/code-graph

## Install

```sh
agentstack add mcp-valarpirai-code-graph
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Code Graph

Index a codebase from a GitHub URL or ZIP upload, build an RDF knowledge graph with Tree-sitter AST parsing, and explore it visually.

**Features:**
- AST parsing for Java, TypeScript, JavaScript, Go, Rust, Kotlin, Ruby, C, Python + markup types (XML, JSON, YAML, Markdown, HTML)
- OWL-based RDF knowledge graph (SPARQL-queryable, stored as Turtle)
- Graph visualization with Cytoscape.js (blast radius, execution flow, Louvain clustering)
- Auto-generated Markdown wiki from the graph
- Real-time indexing status via WebSocket

---

## Quick start (local)

Requires **uv** and **Node 22** (`nvm use 22`).

```bash
./dev.sh start    # backend :8000, frontend :5173
./dev.sh stop
./dev.sh status
./dev.sh logs
```

Open **http://localhost:5173**, paste a GitHub URL or upload a ZIP, and click Index.

---

## Quick start (Docker)

```bash
docker-compose up --build
```

- Backend: http://localhost:8000
- Frontend: http://localhost:80

Project data is persisted in `./data/`.

---

## Development

### Backend (Python 3.11+)

```bash
cd backend
uv sync
uv run pytest                            # full suite
uv run pytest tests/test_parsing/ -v    # single directory
uv run pytest -k "test_blast_radius"    # single test
uv run uvicorn app.main:app --reload    # dev server
```

### Frontend (Node 22)

```bash
cd frontend
npm install
npm run dev      # Vite dev server :5173
npm run test     # vitest run
npm run build    # production build
```

---

## Architecture

```
backend/app/
  parsing/        Tree-sitter AST parsers → ParsedFile dataclasses
  rdf/            RDFBuilder: ParsedFile list → rdflib Graph (graph.ttl)
  analysis/       Blast radius, execution flow, Louvain clustering
  wiki/           WikiGenerator: SPARQL queries → Jinja2 templates → .md files
  api/            FastAPI routers (projects, graph, analysis, wiki)
  storage/        ProjectStore: project metadata + disk layout

frontend/src/
  api/            API client + TypeScript types
  hooks/          React Query hooks (projects, graph, wiki, WebSocket)
  pages/          LandingPage, ProjectPage (Graph / Hierarchy / Wiki / Query tabs)
  components/     GraphView (Cytoscape.js), HierarchyView, WikiView, QueryPanel
```

Each indexed project is stored under `data/{project_id}/`:
- `project.json` — metadata
- `source/` — cloned/extracted source
- `graph.ttl` — RDF graph (Turtle)
- `wiki/` — generated Markdown pages

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [valarpirai](https://github.com/valarpirai)
- **Source:** [valarpirai/code-graph](https://github.com/valarpirai/code-graph)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** yes
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-valarpirai-code-graph
- Seller: https://agentstack.voostack.com/s/valarpirai
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
