MCP server for automatic Python package documentation context
Project description
AutoDocs MCP Server
💡 Passion Project Note: This is a personal passion project focused on exploring "intention-only programming" - the practice of describing what you want the code to do rather than how to implement it. The development process is completely transparent, and you can explore how this project evolved by examining the
.claude/(Claude Code agent configurations) and.specstory/(session history) folders in this repository.
Intelligent documentation context provider for AI assistants
AutoDocs MCP Server automatically provides AI assistants with contextual, version-specific documentation for Python project dependencies. It uses intelligent dependency resolution to include both the requested package and its most relevant dependencies, giving AI assistants comprehensive context for accurate code assistance.
✨ Features
🧠 Phase 4: Dependency Context System (Complete)
- Smart dependency resolution with relevance scoring for major frameworks
- AI-optimized documentation extraction with token management
- Concurrent fetching of dependency documentation (3-5 second response times)
- Contextual intelligence - includes 3-8 most relevant dependencies automatically
🛠️ Production-Ready Core
- 8 comprehensive MCP tools including system health and monitoring
- Network resilience with circuit breakers and exponential backoff
- Version-specific caching with immutable cache keys for optimal performance
- Graceful degradation with partial results on failures
- FastMCP integration for seamless AI tool compatibility
🎯 Intelligent Context
- Framework-aware: Special handling for FastAPI, Django, Flask ecosystems
- Token-aware: Respects context window limits (30k tokens default)
- Performance-optimized: Concurrent requests with connection pooling
- Configurable scope: Primary-only, runtime deps, or smart context
🔍 Development Transparency
This project demonstrates transparent AI-assisted development:
.claude/agents/- Claude Code agent configurations and specialized contexts.specstory/history/- Complete session history showing the development processplanning/- Comprehensive planning documents and technical decisions
Explore these folders to see how this project evolved through intention-only programming!
🚀 Installation
From PyPI (Recommended)
# Using uv (recommended)
uv tool install autodoc-mcp
# Using pip
pip install autodoc-mcp
For Development
# Clone and install
git clone https://github.com/bradleyfay/autodoc-mcp.git
cd autodoc-mcp
uv sync --all-extras
# Run tests (277 tests)
uv run pytest
# Start development server
uv run python -m autodoc_mcp.main
🔌 Usage
MCP Client Configuration
Claude Code Sessions
To use in Claude Code sessions:
# 1. Install the server in current session
uv tool install autodoc-mcp
# 2. Start the MCP server (the command is available globally)
autodoc-mcp
# 3. The server provides 8 MCP tools:
# Core: scan_dependencies, get_package_docs, get_package_docs_with_context
# Cache: refresh_cache, get_cache_stats
# Health: health_check, ready_check, get_metrics
Cursor Desktop
Add to your Cursor settings (Cmd+, → Extensions → Rules for AI → MCP Servers):
{
"mcpServers": {
"autodoc-mcp": {
"command": "autodoc-mcp",
"env": {
"CACHE_DIR": "~/.cache/autodoc-mcp",
"LOG_LEVEL": "INFO"
}
}
}
}
Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"autodoc-mcp": {
"command": "autodoc-mcp",
"env": {
"CACHE_DIR": "~/.cache/autodoc-mcp",
"LOG_LEVEL": "INFO"
}
}
}
}
Other MCP Clients
{
"mcpServers": {
"autodoc-mcp": {
"command": "python",
"args": ["-m", "autodoc_mcp.main"],
"cwd": "/path/to/autodoc-mcp",
"env": {
"CACHE_DIR": "~/.cache/autodoc-mcp",
"LOG_LEVEL": "INFO",
"MAX_CONCURRENT": "10"
}
}
}
}
Testing Your Setup
-
Start the MCP server manually to test:
# Should show FastMCP startup screen autodoc-mcp -
Test in your AI client:
- Ask: "What packages are available in this project?" (uses
scan_dependencies) - Ask: "Tell me about the FastAPI package with its dependencies" (uses
get_package_docs_with_context)
- Ask: "What packages are available in this project?" (uses
🛠️ Available MCP Tools
The server provides 8 production-ready MCP tools organized into three categories:
Core Documentation Tools
scan_dependencies
Scans project dependencies from pyproject.toml files with graceful error handling.
Parameters:
project_path(optional): Path to project directory (defaults to current directory)
Returns:
- Project metadata and dependency specifications
- Graceful degradation info for malformed dependencies
- Success/failure counts and error details
Example:
# AI Assistant can call this to understand your project
{
"success": true,
"project_name": "my-fastapi-app",
"total_dependencies": 12,
"dependencies": [
{"name": "fastapi", "version_constraint": ">=0.100.0"},
{"name": "pydantic", "version_constraint": "^2.0.0"}
]
}
get_package_docs_with_context ⭐ Primary Phase 4 Tool
Retrieves comprehensive documentation context including the requested package and its most relevant dependencies with smart scoping.
Parameters:
package_name(required): Primary package to documentversion_constraint(optional): Version constraint for primary packageinclude_dependencies(optional): Include dependency context (default: true)context_scope(optional): "primary_only", "runtime", or "smart" (default: "smart")max_dependencies(optional): Maximum dependencies to include (default: 8)max_tokens(optional): Token budget for context (default: 30000)
Returns:
- Rich documentation context with primary package + key dependencies
- Performance metrics (response times, cache hits)
- Token estimates and context scope information
Example:
# AI Assistant gets comprehensive context
{
"success": true,
"context": {
"primary_package": {
"name": "fastapi",
"version": "0.104.1",
"summary": "FastAPI framework, high performance...",
"key_features": ["Automatic API docs", "Type hints", "Async support"],
"main_classes": ["FastAPI", "APIRouter", "Depends"],
"usage_examples": "from fastapi import FastAPI\napp = FastAPI()..."
},
"runtime_dependencies": [
{
"name": "pydantic",
"version": "2.5.1",
"why_included": "Required by fastapi",
"summary": "Data validation using Python type hints",
"key_features": ["Data validation", "Serialization"]
},
{
"name": "starlette",
"version": "0.27.0",
"why_included": "Required by fastapi",
"summary": "Lightweight ASGI framework/toolkit"
}
],
"context_scope": "smart (2 deps)",
"total_packages": 3,
"token_estimate": 15420
},
"performance": {
"total_time": 0.89,
"cache_hits": 1,
"cache_misses": 2
}
}
get_package_docs (Legacy)
Retrieves basic documentation for a single package without dependency context.
Parameters:
package_name(required): Package to documentversion_constraint(optional): Version constraintquery(optional): Filter documentation sections
Note: For rich context with dependencies, use get_package_docs_with_context instead.
Cache Management Tools
refresh_cache
Clears the local documentation cache.
Returns:
- Statistics about cleared entries and freed space
get_cache_stats
Gets statistics about the documentation cache.
Returns:
- Cache statistics (total entries, size, hit rates)
- List of cached packages
System Health & Monitoring Tools
health_check
Comprehensive health status for monitoring and load balancer checks.
Returns:
- Overall health status of all system components
- Component-level health information
- System diagnostics
ready_check
Kubernetes-style readiness check for deployment orchestration.
Returns:
- Simple ready/not-ready status
- Readiness for handling requests
get_metrics
System performance metrics for monitoring.
Returns:
- Performance statistics and metrics
- Health metrics
- Request/response statistics
- Cache performance data
⚙️ Configuration
Environment Variables
CACHE_DIR: Cache directory (default:~/.cache/autodoc-mcp)MAX_DEPENDENCY_CONTEXT: Max dependencies in context (default: 8)MAX_CONTEXT_TOKENS: Token budget for context (default: 30000)LOG_LEVEL: Logging level (default: INFO)MAX_CONCURRENT: Maximum concurrent PyPI requests (default: 10)
Advanced Configuration
# Increase context size for complex projects
export MAX_DEPENDENCY_CONTEXT=12
export MAX_CONTEXT_TOKENS=50000
# Use custom cache location
export CACHE_DIR="/tmp/autodoc-cache"
# Enable debug logging
export LOG_LEVEL=DEBUG
# Adjust concurrency for network conditions
export MAX_CONCURRENT=5
🏗️ Architecture
Layered Architecture (Phase 4 Complete)
- Core Services Layer (
src/autodoc_mcp/core/): 10 specialized modules for dependency parsing, resolution, fetching, caching, and context management - Infrastructure Layer (
src/autodoc_mcp/): MCP server, configuration, security, observability, health checks - Network Resilience: Circuit breakers, exponential backoff, connection pooling
- Production Ready: Graceful shutdown, comprehensive error handling, structured logging
Intelligent Dependency Resolution
- Relevance scoring: Core frameworks (FastAPI, Django, Flask) get priority
- Package relationships: Framework-specific dependency boosts
- Token awareness: Respects context window limits with automatic truncation
- Smart scoping: Runtime vs development dependency classification
- Graceful degradation: Partial results when some dependencies fail
Performance Optimizations
- Version-based caching: Immutable package versions cached indefinitely with
{package}-{version}.jsonkeys - Concurrent fetching: Up to 10 simultaneous PyPI requests with connection pooling
- Smart timeouts: 15-second max for dependency fetching with exponential backoff
- Circuit breakers: Prevents cascade failures with automatic recovery
AI-Optimized Output
- Structured data: Clean JSON with consistent formatting and metadata
- Token estimation: Helps AI clients manage context windows effectively
- Relevance filtering: Only includes most important information based on scoring
- Context metadata: Clear indication of what was included/excluded and why
🧪 Testing
Comprehensive Test Suite (277 Tests)
# Run all tests
uv run pytest
# Run with coverage
uv run pytest --cov=src --cov-report=html
# Run linting
uv run ruff check
# Type checking
uv run mypy src
# Development testing with scripts
uv run python scripts/dev.py test-scan
uv run python scripts/dev.py test-docs fastapi ">=0.100.0"
uv run python scripts/dev.py cache-stats
uv run python scripts/dev.py clear-cache
Development Standards
- Conventional Commits: All commits follow conventional commit standards
- Pre-commit Hooks: Automated linting, formatting, and type checking
- pytest Ecosystem: pytest-mock, pytest-asyncio, pytest-cov, pytest-xdist
- Security Focused: Input validation and security controls throughout
🤔 Troubleshooting
Common Issues
"Context fetcher not initialized" error:
- Ensure the MCP server started successfully
- Check logs for initialization errors with
LOG_LEVEL=DEBUG - Verify network connectivity to PyPI
"No dependencies found" for known packages:
- Check if the package has dependencies in its PyPI metadata
- Try with
context_scope="smart"parameter - Some packages have optional-only dependencies
Slow response times:
- Dependencies are fetched on first request (cache miss)
- Subsequent requests use cache (much faster)
- Network latency to PyPI affects first-time fetching
- Adjust
MAX_CONCURRENTfor network conditions
MCP client can't connect:
- Verify the command path in your MCP configuration
- Check if
autodoc-mcppackage is installed correctly:autodoc-mcp --version - Test manual server startup:
autodoc-mcp - Check server logs with
LOG_LEVEL=DEBUG
Debug Mode
# Enable debug logging
export LOG_LEVEL=DEBUG
# Run server manually to see debug output
autodoc-mcp
# Check cache contents
ls ~/.cache/autodoc-mcp/
# View cache statistics
uv run python scripts/dev.py cache-stats
# Test specific functionality
uv run python scripts/dev.py --help
Health Monitoring
# Check system health (using the MCP tools)
# Ask your AI assistant: "Check the health status of AutoDocs"
# This uses the health_check MCP tool
# View performance metrics
# Ask your AI assistant: "Show me AutoDocs performance metrics"
# This uses the get_metrics MCP tool
🔮 Future Enhancements
Immediate Robustness (Technical Debt)
- Enhanced input validation for edge cases
- Memory pressure monitoring for long-running instances
- Cache corruption recovery mechanisms
- Dependency graph analysis with circular dependency detection
Performance & Scalability
- Streaming context delivery for large dependency trees
- Predictive caching based on usage patterns
- Delta documentation (changes between versions)
- Distributed caching with Redis support
AI Integration
- Semantic documentation filtering with embedding models
- ML-based relevance scoring for dependency prioritization
- Documentation quality assessment
- Custom context templates for different AI use cases
Enterprise Features
- Authentication & authorization (API keys, JWT)
- Rate limiting and quota management
- Multi-tenant support with isolated caching
- OpenTelemetry integration for distributed tracing
📊 Project Statistics
- Version: 0.3.4 (Phase 4 Complete)
- Architecture: Layered with 10 core service modules
- Test Coverage: 277 comprehensive tests
- MCP Tools: 8 production-ready tools
- Dependencies: Minimal, production-focused
- Language Support: Python (with plans for multi-language)
📄 License
MIT License - see LICENSE for details.
🤝 Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Follow conventional commits (
feat:,fix:,docs:, etc.) - Run tests and linting (
uv run pytest && uv run ruff check) - Create a Pull Request
Development Workflow
- Work on
developbranch for most changes - Use
feature/*branches for larger features - Create
release/v0.x.xbranches for version releases - All commits must pass pre-commit hooks (never use
--no-verify)
Built with ❤️ using FastMCP and intention-only programming
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file autodoc_mcp-0.5.1.tar.gz.
File metadata
- Download URL: autodoc_mcp-0.5.1.tar.gz
- Upload date:
- Size: 96.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0fd4433112c6fd9531867500a7c61d7236b93ad1d7c9e4ed62aef96fda6ff08
|
|
| MD5 |
3bf90fd73e8ba8365fdabccdd69ac180
|
|
| BLAKE2b-256 |
932aa4620c8e6165e6d7291eb2d1f05fe75cd1ada6615f00b4f7f4cdf80cccbf
|
Provenance
The following attestation bundles were made for autodoc_mcp-0.5.1.tar.gz:
Publisher:
ci.yml on bradleyfay/autodoc-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
autodoc_mcp-0.5.1.tar.gz -
Subject digest:
c0fd4433112c6fd9531867500a7c61d7236b93ad1d7c9e4ed62aef96fda6ff08 - Sigstore transparency entry: 376563827
- Sigstore integration time:
-
Permalink:
bradleyfay/autodoc-mcp@5dbb0570f30768899d9e2c65db6d83cfdeae8923 -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/bradleyfay
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@5dbb0570f30768899d9e2c65db6d83cfdeae8923 -
Trigger Event:
push
-
Statement type:
File details
Details for the file autodoc_mcp-0.5.1-py3-none-any.whl.
File metadata
- Download URL: autodoc_mcp-0.5.1-py3-none-any.whl
- Upload date:
- Size: 51.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd7196053f13bf5ae8270f347f9a5ac29562388eff798bce16c4fa29814e11a6
|
|
| MD5 |
982a171e78a974ce41a5fd35c6ffb4ad
|
|
| BLAKE2b-256 |
1eb36823681f49bc42bca633cbc7fc65bd34db5a9dc88d5ea4a90b86f2b45c25
|
Provenance
The following attestation bundles were made for autodoc_mcp-0.5.1-py3-none-any.whl:
Publisher:
ci.yml on bradleyfay/autodoc-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
autodoc_mcp-0.5.1-py3-none-any.whl -
Subject digest:
fd7196053f13bf5ae8270f347f9a5ac29562388eff798bce16c4fa29814e11a6 - Sigstore transparency entry: 376563835
- Sigstore integration time:
-
Permalink:
bradleyfay/autodoc-mcp@5dbb0570f30768899d9e2c65db6d83cfdeae8923 -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/bradleyfay
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@5dbb0570f30768899d9e2c65db6d83cfdeae8923 -
Trigger Event:
push
-
Statement type: