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: codebase-mcp
インストール
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.
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| limit | No | ||
| target | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It discloses the structural-graph mechanism and implies a read-only lookup, but it does not mention prerequisites such as an indexed repository, whether callers are direct or indirect, limits on traversal, or error behavior. This is too little transparency for an unannotated tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single sentence with no filler. 'Exact' and 'structural graph' are meaningful qualifiers, and the core purpose is front-loaded. Every word earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Even though an output schema exists, this unannotated tool has three undocumented parameters and no usage guidance. The description does not explain how to construct path/target values, whether the repo must be indexed first, or how result limits behave. An agent would need to guess important invocation details.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It only hints that 'target' refers to a function or method; it does not explain what 'path' means, how 'limit' applies, or the expected format of 'target'. The description fails to close the parameter documentation gap.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('Find') and names the resource ('exact callers of a function or method') plus the mechanism ('structural graph'). The qualifiers 'exact' and 'structural' help differentiate it from semantic-search siblings, so an agent can tell what the tool does.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The phrase 'exact callers' implies a precise, structural query rather than a semantic one, giving some context for when to use it. However, the description never explicitly names alternatives like astra_semantic_search or states when not to use this tool.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
astra_hybrid_contextC
Combine semantic matches with structural expansion.
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| limit | No | ||
| query | Yes | ||
| expansion | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must carry the full behavioral burden. It does not disclose whether the operation reads or writes, whether it is safe to call repeatedly, or any side effects. The phrase 'Combine semantic matches with structural expansion' is too abstract to convey behavioral implications.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single under-specified fragment rather than a properly sized explanation. It is not well-structured and does not front-load any practical information. While brief, the brevity sacrifices clarity, making it inadequate for an agent selecting the tool.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With no output schema, no annotations, and a two-line description, the tool is critically incomplete. The agent lacks information on what the tool returns, how to construct the path/query, what limit and expansion control, and any usage constraints. This is insufficient for correct invocation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema describes four parameters (path, query, limit, expansion) with 0% coverage from the description. The description does not explain any parameter's meaning, acceptable values, or how they interact, forcing the agent to guess from names alone. This is a severe gap.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description gives a general sense of the tool's role ('Combine semantic matches with structural expansion') but does not state a concrete verb+resource outcome or differentiate from siblings like astra_semantic_search and astra_get_callers. It implies a hybrid behavior but is ambiguous about what it actually produces.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use this tool versus relying on astra_semantic_search alone or astra_get_callers. No exclusions, prerequisites, or context that would help an agent decide between siblings. The description merely states the concept without any conditions for use.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
astra_index_repoC
Index a local Python code directory into Astra's graph and vector store.
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are present, so the description carries the full burden of behavioral disclosure. It only states the action without disclosing whether the operation is destructive, requires permissions, is additive or overwriting, or what the return value or side effects are. This is a significant gap for a mutating tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, direct sentence with zero filler. It is appropriately concise and the primary action is stated immediately.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For an indexing operation with no annotations, no output schema, and an undocumented parameter, the description is critically incomplete. It does not explain prerequisites, the effect on an existing index, or the result of the operation. An agent cannot predict what happens on success or failure.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema provides no description for the sole parameter 'path' (0% coverage), and the tool description does not reference it at all. There is no indication of expected format (absolute vs relative, file vs directory), whether it must exist, or what constraints apply. The agent has no way to correctly populate the parameter.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb ('Index') and a specific resource ('local Python code directory'), and it is clearly distinct from the sibling tools which are query/visualization operations. The purpose is unambiguous and immediately understood.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus the alternatives. There is no mention that indexing is a prerequisite for search tools, nor any exclusions or conditions that would help an agent decide to call this instead of astra_semantic_search or astra_visualize.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
astra_semantic_searchC
Search indexed code chunks by conceptual intent.
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| limit | No | ||
| query | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the behavioral disclosure burden. It does convey that this is a read-only semantic lookup over an already-indexed corpus, but it does not disclose ranking behavior, behavior for unindexed paths, or any rate/access constraints.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single front-loaded sentence with no filler and a clear action-resource structure. It is concise, but the brevity comes at the cost of missing parameter and usage context, so it is not a perfect score.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema exists, so return shape is partially covered, but the description omits essential operational context: what path means, whether the repository must already be indexed, and how this tool relates to astra_index_repo. For a tool with three parameters and no annotations, this is a meaningful gap.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, and the description only partially characterizes the query parameter as a 'conceptual intent.' It does not explain what 'path' refers to or how 'limit' affects results, leaving most parameter semantics to the agent to infer.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('Search'), a resource ('indexed code chunks'), and a method ('by conceptual intent'), making the tool's semantic retrieval purpose clear. It does not explicitly contrast with sibling tools like astra_hybrid_context or astra_get_callers, so it stops short of a top score.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is given about when to use this tool versus alternatives such as astra_hybrid_context or astra_get_callers. The phrase 'by conceptual intent' hints at semantic queries, but there is no explicit when-to-use, when-not-to-use, or prerequisite such as running astra_index_repo first.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
astra_visualizeC
Generate a local HTML visualization and return its path and file URL.
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| output | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full disclosure burden. It does reveal the key side effect: generating a local HTML file and returning its path/URL. However, it omits whether the file overwrites an existing output, whether it is temporary or persistent, and any resource or environment constraints.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence that is front-loaded with the action and clearly states the return value. Every word contributes to understanding, with no filler or repetition.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
There is no output schema, so mentioning the returned path and file URL is useful. However, the required 'path' parameter is unexplained, the optional 'output' parameter is undefined, and there is no context about what should be visualized. A simple tool with two parameters still needs at least minimal input semantics to be invoked correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, and the description does not explain the meaning of the required 'path' parameter or the optional 'output' parameter. The phrase 'return its path and file URL' refers to the result, not the input parameters, leaving the agent without enough information to construct a valid invocation.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific action and result: 'Generate a local HTML visualization and return its path and file URL.' It is clear about what the tool does. However, it does not differentiate from sibling tools by naming them or contrasting the visualization use case with indexing/searching.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided about when to use this tool versus alternatives such as astra_index_repo or astra_semantic_search. There is no explicit condition, prerequisite, or exclusions. The intended context is only vaguely implied by the tool name.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
5 tool updates
v0.1.0- First observed
astra_get_callers - First observed
astra_hybrid_context - First observed
astra_index_repo - First observed
astra_semantic_search - First observed
astra_visualize
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.
Maintenance
Related MCP Connectors
Codebase graphs, caller impact analysis, and recorded project context for AI coding agents.
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.
Related MCP Servers
FlicenseNot gradedqualityDmaintenanceProvides AI coding agents with structured access to indexed codebases via semantic search, symbol analysis, and file reading tools.13-- FlicenseNot gradedqualityDmaintenanceEnables AI agents to semantically search and navigate code repositories using natural language, with support for multiple repos, incremental indexing, and no local install needed.-
- 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.18 PyPI3MIT
- FlicenseAqualityCmaintenanceProvides 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-