ast-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
⚡ ast-mcp: Smart Context Compiler & MCP Server for AI Agents
A lightweight, zero-C-extension context compiler and Model Context Protocol (MCP) server that compresses Python codebases into high-signal AST interface skeletons, cutting prompt window consumption by 60% to 80%.
The Problem: "Fat Context" Exhaustion
LLM-driven coding agents (Antigravity, Claude, Cursor) are often fed hundreds or thousands of lines of code when analyzing a task. In real-world repositories:
Up to 85% of source lines consist of internal function algorithms, repetitive loops, and intermediate calculations.
Feeding raw implementations for every dependency wastes token budgets, slows inference, and dilutes the model's attention over long horizons.
Related MCP server: @penqwin/mcp
The Solution: Selective AST Interface Skeletons
ast-mcp utilizes Python's built-in ast parser to strip out function and method bodies into ... (Ellipsis), preserving:
Class declarations, inheritances, and metaclasses
Method and function signatures with type annotations
Parameter default values,
*args, and**kwargsModule, class, and method docstrings
Global constants and type aliases
When targeting a specific focus symbol (e.g., --symbol CoreEngine), ast-mcp preserves the full implementation of the target file while delivering all auxiliary project files as ultra-compact AST skeletons.
Compression Benchmark (Tested on ast-mcp/src)
Compression Mode | Files Processed | Original Tokens | Compressed Tokens | Tokens Saved | Reduction (%) | Compression Ratio |
All Files (Interface Skeleton) | 7 | ~5,847 | ~2,230 | ~3,617 | 61.88% | 2.62x |
Focused ( | 7 (1 full, 6 skel) | ~5,847 | ~2,530 | ~3,317 | 56.76% | 2.31x |
Quickstart
Installation
Requires Python 3.14+:
git clone https://github.com/your-username/ast-mcp.git
cd ast-mcp
uv pip install -e .CLI Usage
# Compile entire directory into terminal output
ast-mcp pack src
# Focus on a specific symbol (keeps full code for target, skeletonizes rest)
ast-mcp pack src --symbol CodeSkeletonizer
# Copy compressed markdown context directly to system clipboard
ast-mcp pack src --symbol ContextPacker --copy
# Save compressed context to file
ast-mcp pack src -o context.mdMCP Server Integration
Run standalone over stdio:
ast-mcp runAdd to your MCP Client Configuration (~/.gemini/config/mcp_config.json or Claude Desktop):
{
"mcpServers": {
"ast-mcp": {
"command": "/Users/iliaprosvirnikov/Downloads/ast-mcp/.venv/bin/python3",
"args": ["-m", "src.cli", "run"]
}
}
}Available MCP Tools
get_smart_context(repo_path: str, focus_symbol: str = "") -> str: Builds a structured markdown slice of the target repository with token reduction metrics.get_file_skeleton(file_path: str) -> str: Generates an instant AST skeleton for an individual Python file.
License
MIT © 2026 ast-mcp contributors.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Persistent memory, knowledge graph, task management and more for AI agents via MCP.
Codebase knowledge graph — architectural awareness for AI coding agents via MCP
Shared context for your codebase: a hosted code knowledge graph over MCP. Free plan, OAuth sign-up.
Team memory for AI coding agents and code reviews, reviewed by humans and served over MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides AI assistants with a structured, token-efficient map of a codebase's symbols, dependencies, and relationships via MCP tools like overview, query, and impact analysis.9MIT
- AlicenseAqualityDmaintenanceAn AST-based MCP server that provides token-efficient codebase skeletons to LLM agents, reducing context token usage by 80-95% by exposing structural information instead of full source files.513 npm3MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI coding agents to query a codebase as a knowledge graph, providing token-budgeted context, search, and impact analysis via MCP tools.18 PyPIMIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that folds function and class implementations into structural skeletons while preserving signatures, interfaces, and docstrings, reducing tokens by up to 90%+ for AI agents. Exposes tools to get repository skeletons, unfold specific symbols on demand, and retrieve exact token and prompt cost savings metrics.MIT