Model Context Protocol (MCP) server providing documentation and code analysis for Python packages
Project description
MCPyDoc - Python Package Documentation MCP Server
MCPyDoc is a Model Context Protocol (MCP) server that provides comprehensive documentation and code analysis capabilities for Python packages. It enables AI agents like Cline and GitHub Copilot to understand and work with Python codebases more effectively.
✨ Features
- 📚 Package Documentation: Get comprehensive docs for any Python package
- 🔍 Symbol Search: Find classes, functions, and modules by pattern
- 💻 Source Code Access: Retrieve actual implementation code
- 🏗️ Structure Analysis: Analyze complete package architecture
- 🔧 Type Hints: Extract and analyze type annotations
- 📖 Docstring Parsing: Support for Google, NumPy, and Sphinx formats
- 🏃 High Performance: Efficient caching and optimized operations
- 🛡️ Error Handling: Robust error management and validation
🚀 Quick Start
Installation
# Install from PyPI (Recommended)
pip install mcpydoc
# Or install from source
git clone https://github.com/amit608/MCPyDoc.git
cd MCPyDoc
pip install .
Once installed and configured with your AI agent, the server will automatically start when needed.
🔌 Integration with you favorite coding AI agent
Configuration
Add MCPyDoc to your Cline/Claude Code/Cursor/Github Copilot MCP configuration:
{
"mcpServers": {
"mcpydoc": {
"command": "python",
"args": ["-m", "mcpydoc"],
"env": {},
"description": "Python package documentation and code analysis server"
}
}
}
Recommended Rules
To help the coding AI agent use MCPyDoc effectively, add these rules to your rules file (Cline: .clinerules, Cursor: .cursor/rules/, Github Copilot:copilot-instructions.md, Claude Code: .claude/settings.json):
# Python Package Analysis Guidelines
## When to Use MCPyDoc Tools
### Always use MCPyDoc when:
- User asks about Python package functionality or capabilities
- Need to understand how to use a specific Python library
- Looking for specific functions or classes in a package
- Want to see source code implementation details
- Need to understand package structure or available modules
- Troubleshooting Python package usage issues
### Recommended workflow:
1. **Start with `analyze_structure`** to understand package organization
2. **Use `search_symbols`** to find relevant functions/classes
3. **Use `get_package_docs`** for comprehensive documentation of packages/modules
4. **Use `get_package_docs` with `module_path`** for specific method/class documentation
5. **Use `get_source_code`** when you need to see implementation details
### For specific method documentation:
- **Option 1**: `get_package_docs` with `module_path` parameter (e.g., `package="requests", module_path="Session.get"`)
- **Option 2**: `search_symbols` to find the method, then `get_package_docs` for details
- **Option 3**: `get_source_code` for the method implementation and its docstring
### Examples of when to use MCPyDoc:
- "I need to understand how to use the SQLAlchemy Session.query() method - show me its documentation and parameters"
- "How do I use requests to make HTTP calls?"
- "What classes are available in the pathlib module?"
- "Show me the source code for json.loads"
- "What functions does the os module provide for file operations?"
- "How do I use pandas for data analysis?"
### Don't use MCPyDoc for:
- Questions about Python language syntax
- General programming concepts
- Non-Python packages or libraries
- Questions already answered in previous context
Place this in your .clinerules file to help Cline automatically use MCPyDoc when working with Python packages.
📊 Supported Package Types
- ✅ Standard Library - Built-in modules (
json,os,sys, etc.) - ✅ Third-Party Packages - pip-installed packages
- ✅ Local Packages - Development packages in current environment
- ✅ Virtual Environments - Proper path resolution
🛠️ API Reference
Core Methods
get_module_documentation(package, module_path=None, version=None)
Get comprehensive documentation for a package or specific module.
Parameters:
package(str): Package namemodule_path(str, optional): Dot-separated path to specific moduleversion(str, optional): Specific version to use
Returns: ModuleDocumentationResult
search_package_symbols(package, pattern=None, version=None)
Search for symbols in a package.
Parameters:
package(str): Package namepattern(str, optional): Search pattern (case-insensitive)version(str, optional): Specific version to use
Returns: List[SymbolSearchResult]
get_source_code(package, symbol_name, version=None)
Get source code for a specific symbol.
Parameters:
package(str): Package namesymbol_name(str): Dot-separated path to symbolversion(str, optional): Specific version to use
Returns: SourceCodeResult
analyze_package_structure(package, version=None)
Analyze complete package structure.
Parameters:
package(str): Package nameversion(str, optional): Specific version to use
Returns: PackageStructure
🏗️ Architecture
MCPyDoc uses a clean, modular architecture:
mcpydoc/
├── __init__.py # Package interface
├── __main__.py # CLI entry point
├── server.py # Core MCPyDoc class
├── mcp_server.py # MCP JSON-RPC server
├── analyzer.py # Package analysis engine
├── documentation.py # Docstring parsing
├── models.py # Pydantic data models
├── exceptions.py # Custom exceptions
└── utils.py # Utility functions
Key Components
- Analyzer: Package introspection and symbol discovery
- Documentation Parser: Multi-format docstring parsing
- MCP Server: JSON-RPC protocol implementation
- Models: Type-safe data structures with Pydantic
- Exception Handling: Comprehensive error management
📝 License
MIT License - see LICENSE file for details.
🤝 Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Run the test suite
- Submit a pull request
Made with ❤️ for the Python community
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 mcpydoc-0.2.0.tar.gz.
File metadata
- Download URL: mcpydoc-0.2.0.tar.gz
- Upload date:
- Size: 34.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57eade1770e419e6d6caaa942deefa35e70c03d1f2cf30bcd01678ea5c9b4d43
|
|
| MD5 |
8b0a1fa08967dd7b0597b63d9f4a33ca
|
|
| BLAKE2b-256 |
2493c5c4a3958aa18ee981cc1bf675bf0ee8ee197160d3526a6c1569e3301851
|
File details
Details for the file mcpydoc-0.2.0-py3-none-any.whl.
File metadata
- Download URL: mcpydoc-0.2.0-py3-none-any.whl
- Upload date:
- Size: 23.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d4dff73259c08c06c6f076a91e51ca295a6b6cf71c8a1a81847bf7a817db106
|
|
| MD5 |
23932cf6a5a5daa3688e7e9002cfba1d
|
|
| BLAKE2b-256 |
896892654f66da2e00151e4f3942558ed74488787709930d3d524b211d4f3702
|