code-ast-mcp
Code AST MCP Server (code-ast-mcp)
code-ast-mcp は、Python 標準の抽象構文木 (ast) パーサーで構築されたアーキテクチャ用 Model Context Protocol (MCP) サーバーです。Claude Desktop、Cursor、Antigravity、またはカスタム MCP クライアント内の AI モデルが、ローカルの Python コードベース構造の分析、シンボル定義の検索、依存関係グラフの構築、docstring カバレッジの監査、コードのリファクタリングを、生のソースファイル全体を LLM コンテキストウィンドウに読み込むことなく実行できるようにします。
🔗 ライブリポジトリ: https://github.com/m-sameerkhan/code-ast-mcp
🔗 Smithery レジストリ: https://smithery.ai/servers/sameerbalouch758/code-ast-mcp
⚡ 機能と特徴
🛠️ ツール
analyze_file_ast(file_path: str).pyファイルをクリーンな AST アウトラインに解析します。モジュールの docstring、行数、インポート、トップレベル関数、クラス、メソッド、変数を抽出します。
find_class_methods(file_path: str, class_name: str)特定のクラスを特定し、メソッドシグネチャ、型アノテーション、行範囲、docstring を返します。
find_symbol(target_dir: str, symbol_name: str)ディレクトリを再帰的に検索し、
symbol_nameに一致するクラス、関数、メソッド、または変数代入を探します。
get_imports_graph(target_dir: str)Python ファイルをスキャンして依存関係のインポートマップを構築し、Mermaid ダイアグラム文字列を出力します。
find_missing_docstrings(target_dir: str, include_private: bool = False)コードベースの docstring を監査し、全体的な docstring カバレッジ率を計算します。
📝 プロンプト
refactor_code_summary(file_path: str)LLM にファイルの AST アウトラインをレビューさせ、リファクタリング、デザインパターンの改善、ドキュメント修正を提案させる構造化プロンプトを生成します。
📊 リソース
codeast://statsワークスペースの統計情報(スキャンされたファイル総数、docstring カバレッジ率、欠落項目数)を提供するライブ JSON リソース。
Related MCP server: codeweave-mcp
🚀 クイックスタートとインストール
オプション 1: Smithery CLI でインストール
smithery mcp add sameerbalouch758/code-ast-mcpオプション 2: ソースからのローカルインストール
リポジトリをクローンし、依存関係を編集可能モードでインストールします:
git clone https://github.com/m-sameerkhan/code-ast-mcp.git
cd code-ast-mcp
# Create & activate virtual environment (or Conda)
python -m venv .venv
# On Windows:
.venv\Scripts\activate
# On macOS/Linux:
source .venv/bin/activate
# Install project and dependencies
pip install -r requirements.txt
pip install -e .オプション 3: MCP バンドル (.mcpb) としてパッケージ化
MCP バンドルをサポートするデスクトップクライアント(Claude Desktop など)向け:
# Install MCPB toolchain
npm install -g @anthropic-ai/mcpb
# Build bundle
mcpb pack . code-ast-mcp.mcpb🧪 ローカルでのテスト
ユニットテストの実行
pytestMCP Inspector でのテスト
公式の MCP Inspector を使用して、ツールとリソースを対話的にテストします:
npx @modelcontextprotocol/inspector python -m code_ast_mcp.server⚙️ クライアント設定
Claude Desktop / Cursor / Antigravity との統合
code-ast-mcp をクライアント設定ファイル(claude_desktop_config.json または mcp_config.json)に追加します:
{
"mcpServers": {
"code-ast-mcp": {
"command": "python",
"args": [
"-m",
"code_ast_mcp.server"
],
"cwd": "/path/to/code-ast-mcp"
}
}
}Windows ユーザーへの注意:"command" を仮想環境または Conda の Python パス(例:C:/Users/<Username>/.conda/envs/code-ast-mcp/python.exe または D:/my_mcp/.venv/Scripts/python.exe)に指定できます。
📦 プロジェクト構造
code-ast-mcp/
├── code_ast_mcp/ # Core package
│ ├── __init__.py # Package exports
│ ├── analyzer.py # Python AST parsing & static analysis engine
│ └── server.py # FastMCP server definition & tool handlers
├── tests/ # Test suite
│ └── test_analyzer.py # Unit tests with pytest
├── manifest.json # MCPB extension manifest
├── smithery.yaml # Smithery registry configuration
├── Dockerfile # Container image definition
├── pyproject.toml # Packaging & metadata
└── requirements.txt # Dependencies📄 ライセンス
MIT ライセンス。m-sameerkhan によって作成されました。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseBqualityDmaintenanceAn MCP server that enables LLMs to understand and analyze code structure through function call graphs, allowing AI assistants to explore relationships between functions and analyze dependencies in Python repositories.618
- Alicense-qualityCmaintenanceAn MCP server that gives AI agents structured code understanding and precise code intelligence via local indexing of AST, call graphs, and semantic search.1084Apache 2.0
- -license-quality-maintenanceAn advanced MCP server that provides deep code understanding and analysis using GraphRAG, AST parsing, and semantic memory, enabling AI agents to query and interact with complex codebases.
- Alicense-qualityCmaintenanceUniversal MCP server that analyzes any codebase and provides structured context to AI assistants. Dynamic, accurate, and token-efficient.19MIT
Related MCP Connectors
An MCP server that gives your AI access to the source code and docs of all public github repos
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Hosted MCP server for structured code review passes on human- and AI-written code. Free tier.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/m-sameerkhan/code-ast-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server