Skip to main content

Model Context Protocol (MCP) server providing documentation and code analysis for Python packages

Project description

MCPyDoc - Python Package Documentation MCP Server

CI PyPI version Python 3.9+ License: MIT Code style: black

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, especially when working with private libraries and unfamiliar packages.

✨ 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

Once installed and configured with your AI agent, the server will automatically start when needed.

Development Installation

If you want to contribute or modify the source code:

git clone https://github.com/amit608/MCPyDoc.git
cd MCPyDoc
pip install -e .[dev]

🔌 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"
    }
  }
}

📊 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 name
  • module_path (str, optional): Dot-separated path to specific module
  • version (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 name
  • pattern (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 name
  • symbol_name (str): Dot-separated path to symbol
  • version (str, optional): Specific version to use

Returns: SourceCodeResult

analyze_package_structure(package, version=None)

Analyze complete package structure.

Parameters:

  • package (str): Package name
  • version (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

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Run the test suite
  6. Submit a pull request

Made with ❤️ for the Python community

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcpydoc-1.0.0.tar.gz (38.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcpydoc-1.0.0-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

Details for the file mcpydoc-1.0.0.tar.gz.

File metadata

  • Download URL: mcpydoc-1.0.0.tar.gz
  • Upload date:
  • Size: 38.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mcpydoc-1.0.0.tar.gz
Algorithm Hash digest
SHA256 59011faaacc1672e0092e5aaee2198ab2c2bf51563cdfcddbf7d48bd97858f88
MD5 d58d3a148fe82017c299d75363b96bdb
BLAKE2b-256 d033f6e79a999d23ca1af0e60a93628dc0ee9ea55f4617ea92f98809e323ba03

See more details on using hashes here.

File details

Details for the file mcpydoc-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: mcpydoc-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 27.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mcpydoc-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 83307c5c7135d470c6eda56db15936e7a7ff394a395ad9c452a4ed1137d0a593
MD5 66acd8a60f206faecbbfa49ba07ff003
BLAKE2b-256 dde86cbda50adcef19918408504d0c017ddcb11691047f7fcf0db88833c816f8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page