# Loctree

> Structural code intelligence for AI agents. Scan once, query everything — dead exports, circular imports, dependency graphs, and more. CLI + MCP server.

- **Type:** MCP server
- **Install:** `agentstack add mcp-loctree-loctree`
- **Verified:** Pending review
- **Seller:** [Loctree](https://agentstack.voostack.com/s/loctree)
- **Installs:** 0
- **Category:** [Integrations](https://agentstack.voostack.com/c/integrations)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [Loctree](https://github.com/Loctree)
- **Source:** https://github.com/Loctree/loctree
- **Website:** https://loct.io

## Install

```sh
agentstack add mcp-loctree-loctree
```

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

## About

loctree

  Scan once, query everything.
  AI-oriented static analysis for dead exports, circular imports, dependency graphs, and holographic context slices.

  
  
  
  
  

---

## Install

```bash
curl -fsSL https://loct.io/install.sh | sh   # CLI + loctree-mcp
cargo install --locked loctree loctree-mcp   # Cargo, reproducible
npm install -g loctree                       # CLI only; published targets follow the latest npm release
brew install loctree/cli/loct                 # CLI via Homebrew tap
brew install loctree/mcp/loctree-mcp          # MCP via Homebrew tap
```

Public install channels track the latest published release, which can lag behind
the workspace version on `main`. If you're validating a specific release, check
crates.io, npm, or GitHub Releases rather than assuming branch parity.

## Quick Start

Artifacts are stored in your OS cache dir by default (override via `LOCT_CACHE_DIR`).
`loct` is the canonical CLI command. `loctree` remains available as a quiet compatibility alias.

```bash
loct                              # Scan project, write cached artifacts
loct --for-ai                     # AI-optimized overview (health, hubs, quick wins)
loct slice src/App.tsx --consumers # Context: file + deps + consumers
loct find useAuth                  # Find symbol definitions
loct find 'Snapshot FileAnalysis'  # Cross-match: where terms meet
loct impact src/utils/api.ts       # What breaks if you change this?
loct health                        # Quick summary: cycles + dead + twins
loct dead --confidence high        # Unused exports
loct cycles                        # Circular imports
loct twins                         # Dead parrots + duplicates + barrel chaos
loct audit                         # Full codebase review
```

## What It Does

loctree captures your project's real dependency graph in a single scan, then answers structural questions instantly from the snapshot. Designed for AI agents that need focused context without reading every file.

**Core capabilities:**

- **Holographic Slice** - extract file + dependencies + consumers in one call
- **Cross-Match Search** - find where multiple terms co-occur (not flat grep)
- **Dead Export Detection** - find unused exports across JS/TS, Python, Rust, Go, Dart
- **Circular Import Detection** - Tarjan's SCC algorithm catches runtime bombs
- **Handler Tracing** - follow Tauri commands through the entire FE/BE pipeline
- **Impact Analysis** - see what breaks before you delete or refactor
- **jq Queries** - query snapshot data with jq syntax (`loct '.files | length'`)

## Why loctree

| | grep/rg | LSP | loctree |
|---|---------|-----|---------|
| Knows imports vs definitions | No | Per-file | Whole graph |
| Dead export detection | No | No | Yes (multi-lang) |
| Cross-file impact analysis | No | Limited | Full transitive |
| AI agent integration | No | No | MCP server + `--for-ai` |
| Speed on 1M LOC repo | Fast (text) | Slow (indexing) | **~3s** (structural) |
| Setup | None | Per-editor | One binary |

## MCP Server

loctree ships as an MCP server for seamless AI agent integration:

```bash
loctree-mcp    # Start via stdio (configure in your MCP client)
```

7 tools: `repo-view`, `slice`, `find`, `impact`, `focus`, `tree`, `follow`. Each tool accepts a `project` parameter — auto-scans on first use, caches snapshots in RAM. Project-agnostic: analyze any repo without configuration.

```json
{
  "mcpServers": {
    "loctree": {
      "command": "loctree-mcp",
      "args": []
    }
  }
}
```

Direct download users can also fetch signed release assets from the monorepo
GitHub release page, which mirrors both the CLI and `loctree-mcp` tarballs.

## Language Support

| Language | Dead Export Accuracy | Notes |
|----------|---------------------|-------|
| **Rust** | ~0% FP | Tested on rust-lang/rust (35K files) |
| **Go** | ~0% FP | Tested on golang/go (17K files) |
| **TypeScript/JavaScript** | ~10-20% FP | JSX/TSX, React patterns, Flow, WeakMap |
| **Python** | ~20% FP | Library mode, `__all__`, stdlib detection |
| **Svelte** |  results.sarif        # SARIF for GitHub/GitLab
loct findings | jq '.dead_exports.total'        # Check dead export count
loct findings --summary | jq '.health_score'    # Health summary JSON
```

## Crates

| Crate | Description |
|-------|-------------|
| [`loctree`](https://crates.io/crates/loctree) | Core analyzer + CLI (`loct`, `loctree`) |
| [`report-leptos`](https://crates.io/crates/report-leptos) | HTML report renderer (Leptos SSR) |
| [`loctree-mcp`](https://crates.io/crates/loctree-mcp) | MCP server for AI agents |

## Development

```bash
make precheck        # fmt + clippy + check (run before push)
make install         # Install loct, loctree, loctree-mcp
make test            # Run all workspace tests
make publish         # Cascade publish to crates.io
```

## Badge

```markdown
[](https://crates.io/crates/loctree)
```

## License

MIT OR Apache-2.0. See [LICENSE-MIT](LICENSE-MIT) and [LICENSE-APACHE](LICENSE-APACHE).

---

𝚅𝚒𝚋𝚎𝚌𝚛𝚊𝚏𝚝𝚎𝚍. with AI Agents ⓒ 2025-2026 Loctree Team

## Source & license

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

- **Author:** [Loctree](https://github.com/Loctree)
- **Source:** [Loctree/loctree](https://github.com/Loctree/loctree)
- **License:** MIT
- **Homepage:** https://loct.io

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: flagged — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-loctree-loctree
- Seller: https://agentstack.voostack.com/s/loctree
- 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%.
