code-ast-mcp
Code AST MCP Server (code-ast-mcp)
code-ast-mcp — это архитектурный сервер Model Context Protocol (MCP), построенный на нативном парсере Abstract Syntax Tree (ast) из Python. Он позволяет моделям ИИ (в Claude Desktop, Cursor, Antigravity или пользовательских MCP-клиентах) анализировать структуру локальных кодовых баз 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Живой JSON-ресурс, предоставляющий статистику рабочей области (количество просканированных файлов, процент покрытия docstring, количество отсутствующих элементов).
Related MCP server: codeweave-mcp
🚀 Быстрый старт и установка
Вариант 1: установка через Smithery CLI
smithery mcp add sameerbalouch758/code-ast-mcpВариант 2: локальная установка из исходного кода
Клонируйте репозиторий и установите зависимости в режиме editable:
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🧪 Локальное тестирование
Запуск модульных тестов
pytestТестирование с помощью MCP 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" путь к вашему виртуальному окружению или Python в Conda (например, 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