Skip to main content
Glama
loctree-mcp

loctree-mcp

Official

インストール

curl -fsSL https://loct.io/install.sh | sh   # One-liner (installs from crates.io)

またはCargo経由で直接インストール:

cargo install loctree        # CLI: loct, loctree
cargo install loctree-mcp    # MCP server for AI agents

Related MCP server: MCP Codebase Server

クイックスタート

アーティファクトはデフォルトでOSのキャッシュディレクトリに保存されます(LOCT_CACHE_DIRで上書き可能)。

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

機能

loctreeは、プロジェクトの実際の依存関係グラフを一度のスキャンでキャプチャし、そのスナップショットから構造的な質問に即座に回答します。すべてのファイルを読み込まずに、必要なコンテキストのみを抽出する必要があるAIエージェント向けに設計されています。

主な機能:

  • ホログラフィック・スライス - ファイル、依存関係、コンシューマーを1回の呼び出しで抽出

  • クロス・マッチ検索 - 複数の用語が共起する場所を検索(単純なgrepではありません)

  • デッドエクスポート検出 - JS/TS、Python、Rust、Go、Dart全体で未使用のエクスポートを特定

  • 循環インポート検出 - Tarjanの強連結成分分解アルゴリズムで実行時の問題を捕捉

  • ハンドラ追跡 - FE/BEパイプライン全体でTauriコマンドを追跡

  • 影響分析 - 削除やリファクタリングを行う前に、何が壊れるかを可視化

  • jqクエリ - jq構文を使用してスナップショットデータをクエリ可能 (loct '.files | length')

MCPサーバー

loctreeは、AIエージェントとのシームレスな統合のためにMCPサーバーとして提供されます:

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

ツール: repo-view, slice, find, impact, focus, tree。各ツールは project パラメータを受け取り、初回使用時に自動スキャンを行い、スナップショットをRAMにキャッシュします。

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

言語サポート

言語

デッドエクスポート精度

備考

Rust

~0% FP

rust-lang/rust (35Kファイル) でテスト済み

Go

~0% FP

golang/go (17Kファイル) でテスト済み

TypeScript/JavaScript

~10-20% FP

JSX/TSX, Reactパターン, Flow, WeakMap

Python

~20% FP

ライブラリモード, __all__, 標準ライブラリ検出

Svelte

<15% FP

テンプレート解析, .d.ts再エクスポート

Vue

~15% FP

SFCサポート, Composition & Options API

Dart/Flutter

完全対応

pubspec.yaml検出

Cargo.toml, tsconfig.json, pyproject.toml, pubspec.yaml, src-tauri/ からスタックを自動検出します。

ホログラフィック・スライス

任意のファイルの3層コンテキストを抽出:

loct slice src/App.tsx --consumers
Slice for: src/App.tsx

Core (1 files, 150 LOC):
  src/App.tsx (150 LOC, ts)

Deps (3 files, 420 LOC):
  [d1] src/hooks/useAuth.ts (80 LOC)
    [d2] src/contexts/AuthContext.tsx (200 LOC)
    [d2] src/utils/api.ts (140 LOC)

Consumers (2 files, 180 LOC):
  src/main.tsx (30 LOC)
  src/routes/index.tsx (150 LOC)

Total: 6 files, 750 LOC

クロス・マッチ検索

複数用語のクエリで、単純なOR検索ではなく、用語が交差する場所を表示:

loct find 'Snapshot FileAnalysis'
=== Cross-Match Files (9) ===
  src/snapshot.rs: Snapshot(6), FileAnalysis(4)
  src/slicer.rs: Snapshot(2), FileAnalysis(3)
  ...

=== Symbol Matches (222 in cross-match files) ===
  src/snapshot.rs:20 - Snapshot [struct]
  src/types.rs:15 - FileAnalysis [struct]
  ...

=== Parameter Matches (4 cross-matched) ===
  src/slicer.rs:45 - snapshot: &Snapshot in build_slice(analyses: &[FileAnalysis])

jqクエリ

スナップショットデータを直接クエリ:

loct '.dead_parrots'                           # Dead code findings
loct '.files | length'                         # Count files
loct '.edges[] | select(.from | contains("api"))' # Filter edges
loct '.summary.health_score'                   # Health score

CI統合

loct lint --fail --sarif > results.sarif    # SARIF for GitHub/GitLab
loct --findings | jq '.dead_parrots | length'  # Check dead code count
loct doctor && echo 'Clean'                 # Health gate

クレート

クレート

説明

loctree

コアアナライザー + CLI (loct, loctree)

report-leptos

HTMLレポートレンダラー (Leptos SSR)

loctree-mcp

AIエージェント用MCPサーバー

開発

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

バッジ

[![loctree](https://img.shields.io/badge/analyzed_with-loctree-a8a8a8?style=flat&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij48cmVjdCB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9IiMwMDAiLz48dGV4dCB4PSI4IiB5PSIxMiIgZm9udC1mYW1pbHk9Im1vbm9zcGFjZSIgZm9udC1zaXplPSIxMCIgZmlsbD0iI2E4YThhOCIgdGV4dC1hbmNob3I9Im1pZGRsZSI+TDwvdGV4dD48L3N2Zz4=)](https://crates.io/crates/loctree)

ライセンス

MIT OR Apache-2.0。 LICENSE-MIT および LICENSE-APACHE を参照してください。


VibeCrafted with AI Agents (c)2026 Loctree Team

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that indexes your codebase using tree-sitter AST parsing and gives AI tools instant access to structural intelligence like dependency graphs, call trees, and dead code detection from a local SQLite database.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    MCP server for semantic codebase navigation that builds an AST index of symbols, imports, and exports, providing AI agents with tools to search, explore, and understand code.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A local-first codebase intelligence layer for AI coding agents, providing a persistent, queryable model of a repository via an MCP server and CLI to enable structure queries instead of reading many files.
    Apache 2.0
  • A
    license
    B
    quality
    B
    maintenance
    Indexes a Python/JS/TS repository into a local SQLite knowledge graph so agents can trace callers, callees, imports, subclasses and covering tests, measure impact radius, rank diff risk, and summarize architecture without grepping files. Exposes these queries as MCP tools alongside an equivalent CLI, with no daemon, embeddings, or network access.
    10
    MIT