astra-mcp
Astraは、AIエージェント向けのローカルコードインテリジェンスサービスです。Pythonコードを構造化されたNetworkXグラフと検索可能なローカルコードチャンクインデックスに解析します。同じエンジンは、astra CLIと公式MCP Python SDKの両方から利用できます。
アーキテクチャ
星座マークは、Astraがコードベース全体で発見する関係性を表しています。そのパイプラインには4つの段階があります。Pythonファイルを実行せずに解析し、構造グラフを構築し、コードチャンクをインデックス化し、グラフ展開を伴うセマンティックマッチを取得します。
コンポーネント | 役割 | 出力 |
ASTおよびテキストパーサー | Pythonの宣言、docstring、シンボル、呼び出しを読み取り、その他のUTF-8テキストファイルをファイルレベルのチャンクとしてインデックス化します。 | コードチャンクと参照 |
構造グラフ | モジュール、宣言、呼び出し元の間の有向NetworkX関係を構築します。 |
|
ベクターインデックス | 検索可能なチャンクをローカルに保存し、オプションでSentence TransformersとChromaによる高速化を提供します。 |
|
デュアルインターフェース | 同じエンジンをターミナルユーザーとMCPホストの両方が利用できるようにします。 |
|
MCPサーフェスは4つのツールを公開しています: astra_index_repo、astra_semantic_search、astra_get_callers、astra_hybrid_context。
Related MCP server: mcp-intelligence-context
インストール
Python 3.10以上が必要です。以下のいずれかのインストール方法を選択してください。
GitHubから直接インストール
これはAstraを使用するための最も簡単なオプションです。現在のフォルダにチェックアウトを置かずに、astra および astra-mcp コマンドをインストールします:
python -m pip install "git+https://github.com/nimelkot/astra.git"分離されたコマンドラインインストールには、pipx を使用します:
pipx install "git+https://github.com/nimelkot/astra.git"開発用にクローン
Astraを編集したり、テストを実行したりする場合は、このオプションを使用します。クローンしたリポジトリのルート、つまり pyproject.toml を含むディレクトリから編集可能インストールを実行します:
git clone https://github.com/nimelkot/astra.git
cd astra
Get-ChildItem pyproject.toml
python -m venv .venv
.venv\Scripts\Activate.ps1
python -m pip install -e ".[dev]"Get-ChildItem pyproject.toml でファイルが見つからない場合は、まだAstraリポジトリのルートにいません。分析したいフォルダはどこにあってもかまいません。Astraのチェックアウト内にある必要はありません。
クイックスタート
まずプロジェクトをインデックス化します。サンプルのパスを、Astraに分析させたいフォルダに置き換えてください:
astra index C:\Users\YourName\Downloads\my-projectこのコマンドは、ネストされたフォルダを再帰的にスキャンしてUTF-8テキストファイルを探しますが、それらをインポートしたり実行したりすることはありません。有効なPythonファイルにはASTレベルの宣言と呼び出し関係が付与され、その他のテキストベースのソース、設定、マークアップ、ドキュメントファイルには検索可能なファイルレベルのチャンクが付与されます。バイナリファイル、2 MBを超えるファイル、および .git、.venv、node_modules、.astra_vectors などの生成物または依存関係ディレクトリはスキップされます。
| ASTおよびテキストパーサー | Pythonの宣言、docstring、シンボル、呼び出しを読み取り、その他のUTF-8テキストファイルをファイルレベルのチャンクとしてインデックス化します。 | コードチャンクと参照 |
my-project/
├── .astra_graph.json # structural modules, declarations, and call relationships
└── .astra_vectors/ # local searchable code chunksソースコードを変更した後は、astra index を再度実行してください。インデックス化により、そのターゲットディレクトリの以前のグラフとチャンクインデックスが置き換えられます。
CLI
セマンティック検索
概念、動作、シンボル名、またはdocstringテキストで検索します:
astra search "authentication token validation" --path C:\Users\YourName\Downloads\my-project --limit 8結果テーブルには、マッチスコア、宣言の種類、ファイルパス、シンボル、ソース行が表示されます。インデックス化されたチャンクにクエリと共通する用語がない場合、検索結果は空になります。
構造的な呼び出し元
ターゲット関数を呼び出す関数を検索します:
astra query callers calculate_total --path C:\Users\YourName\Downloads\my-projectcallers クエリは保存されたASTグラフを使用し、一致する呼び出し元ノードをJSONとして報告します。現在のCLI構造クエリタイプは callers です。
検索動作
デフォルトのインデックスは決定的で、ローカルの語彙マッチングを使用してオフラインで動作します。Sentence TransformersとChromaベクター検索を有効にするには、インデックス化と検索の前にこれを設定します:
$env:ASTRA_ENABLE_EMBEDDINGS = "1"
astra index C:\Users\YourName\Downloads\my-project
astra search "rate limiting and retries" --path C:\Users\YourName\Downloads\my-project埋め込み対応の初回実行時には、all-MiniLM-L6-v2 モデルがダウンロードされる場合があります。モデルへのアクセスやベクターストアが利用できない場合、Astraはローカル検索実装にフォールバックします。
インデックスの可視化
インデックス化後、ターゲットフォルダ用のローカルHTMLレポートを生成します:
astra visualize C:\Users\YourName\Downloads\my-projectこれにより、.astra_visualization.html がターゲットフォルダに書き込まれます。そのファイルをブラウザで開いて、2つのビューを確認します:
構造グラフ:
.astra_graph.jsonからの対話型モジュール、クラス、関数、メソッド、および定義/呼び出しエッジ。ベクターチャンク:
.astra_vectors/chunks.jsonからの検索可能なファイルとシンボルカード。ソースプレビューを展開できます。
別の出力パスを選択することもできます:
astra visualize C:\Users\YourName\Downloads\my-project --output C:\Users\YourName\Desktop\astra-report.htmlレポートは、構造キャンバスにVis NetworkブラウザライブラリをCDNから使用します。ベクタービューと生成されたデータはローカルに残ります。インターネット接続が必要なのは、レポートを開くときに対話型グラフライブラリを読み込む場合のみです。
MCP
Astraはそのエンジンを、stdio上の公式MCPサーバーとしても公開しています。MCPホストを設定して astra-mcp を実行してください。サーバーは、そのホストが使用する環境にインストールされている必要があります。
4つのネイティブツールは次のとおりです:
ツール | 目的 |
| ローカルのPythonリポジトリをインデックス化します。 |
| インデックス化されたコードチャンクを検索します。 |
| 構造グラフを通じて呼び出し元を検索します。 |
| セマンティックマッチとグラフ展開を組み合わせます。 |
| ローカルHTMLグラフレポートを生成し、そのファイルパスとURLを返します。 |
リポジトリには、VS Code MCPクライアント用の .vscode/mcp.json が含まれています。他のホストの場合は、ホストの設定にサーバーを登録します:
[mcp_servers.astra]
command = "astra-mcp"
args = []ホストがシェルからコマンドを見つけられない場合は、絶対実行可能パスを使用してください: Windowsでは .venv\Scripts\astra-mcp.exe、macOS/Linuxでは .venv/bin/astra-mcp。サーバーはstdioを介して通信するため、そのstdoutをリダイレクトしないでください。
開発
pytest
ruff check .Astraは、インデックス化するファイルをインポートしたり実行したりすることはありません。解析の失敗はスキップされ、結果のカウントを通じてのみ報告されるため、部分的に壊れた作業ツリーでもインデックス化が有用に機能します。
Available Tools
5 toolsastra_get_callersB
Find exact callers of a function or method using the structural graph.
Inputs: path (required), target (required), limit. Returns: result
astra_hybrid_contextC
Combine semantic matches with structural expansion.
Inputs: path (required), query (required), limit, expansion.
astra_index_repoC
Index a local Python code directory into Astra's graph and vector store.
Inputs: path (required).
astra_semantic_searchC
Search indexed code chunks by conceptual intent.
Inputs: path (required), query (required), limit. Returns: result
astra_visualizeC
Generate a local HTML visualization and return its path and file URL.
Inputs: path (required), output.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a distinct purpose: indexing a repo, semantic search, exact callers, hybrid context, and visualization. No two tools overlap in functionality; agents can easily select the right one.
All tools follow a consistent 'astra_' prefix with verb_noun naming: index_repo, semantic_search, get_callers, hybrid_context, visualize. The pattern is uniform and predictable.
Five tools is an ideal scope for a code indexing and querying server. Each tool serves a core workflow without unnecessary bloat or missing essential operations.
The set covers the main lifecycle: indexing, searching, structural queries, combined retrieval, and visualization. Minor gaps exist (e.g., no delete index or update) but they are not critical for the primary use case.
Related MCP Connectors
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Shared memory for coding agents. Stop re-explaining your codebase every session.
Codebase intelligence for AI agents — dead code, blast radius, ownership.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables LLM agents to efficiently understand and navigate a codebase by providing semantic search over symbols and a reference graph, replacing expensive grep/glob calls with structured tools like definition lookup, caller/callee queries, and change-impact analysis.4MIT
- FlicenseAqualityDmaintenanceProvides codebase indexing and retrieval tools that give AI agents token-efficient, query-relevant context packages (symbols, imports, and dependencies) instead of scanning entire repositories.6-
- AlicenseBqualityBmaintenanceEnables AI coding agents to build and query local repository memory, returning ranked files, context packs, relationship maps, semantic recall, and feedback-tuned search without uploading code.9137 PyPI1MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI coding agents to search and navigate indexed codebases through lexical, semantic, and hybrid queries, with tools for symbols, call graphs, outlines, spans, impact analysis, and recall.9Apache 2.0