Enables fetching, exploring, and analyzing source code from Python packages on PyPI, including listing package files, retrieving specific versions, searching for packages, and accessing package metadata.
π¦ PyPI Package MCP Server
A powerful Model Context Protocol (MCP) server that enables AI assistants to fetch, explore, and analyze source code from any Python package on PyPI.
β¨ Features
π¦ Fetch Any PyPI Package: Download and explore source code from millions of packages
π Smart File Discovery: List and filter files with intelligent code detection
π Selective Code Reading: Get specific files or entire codebases
π·οΈ Version Control: Support for any published package version
π§Ή Auto Cleanup: Automatic temporary file management
π Type Safe: Full type hints with mypy support
β‘ Async First: Modern async/await patterns throughout
π€ AI-Ready: Perfect integration with Claude, ChatGPT, and other AI assistants
π― Use Cases
Code Analysis: Analyze libraries before adopting them
Learning: Study well-written open source code
AI Development: Enable AI assistants to understand package internals
Documentation: Generate docs by analyzing source code
Security Auditing: Review dependencies for security issues
Migration Planning: Understand APIs when upgrading packages
π Installation & Setup
Option 1: Local Development (Stdio Mode)
Option 2: Local Development (HTTP Mode)
Option 3: With Authentication Token
Option 4: Docker (Production - HTTP Mode)
π§ Configuration
Environment Variables
Variable | Default | Description |
|
| Transport mode:
or
|
|
| HTTP server port (only used in
mode) |
| (none) | Optional authentication token for API access |
Transport Modes
Stdio Mode (Default)
Best for: Claude Desktop, local development
Connection: Standard input/output streams
Command:
pypi-package-mcp-server
HTTP Mode
Best for: Remote servers, containerized deployments
Connection: HTTP requests on specified port
Health endpoint:
GET /healthMCP endpoint:
POST /mcpCommand:
TRANSPORT_MODE=http PORT=3000 pypi-package-mcp-server
Authentication
When AUTH_TOKEN environment variable is set, all HTTP requests must include the token in the Authorization header:
π Supported Packages
β All public PyPI packages
β Any published version
β Source distributions (
.tar.gz)β Binary wheels (
.whl)β Monorepo packages
β Pure Python and native extensions
π₯ Popular Packages to Explore
Try these commands with your AI assistant:
π οΈ Tools
1. get_pypi_package_code
Fetch source code from a Python package.
2. list_package_files
List all files in a package.
3. get_package_info
Get metadata about a package.
4. search_pypi_packages
Search for packages on PyPI.
π Requirements
Python 3.9 or higher
mcp>= 0.1.0requests>= 2.31.0pydantic>= 2.0.0
π Authentication (Optional)
Set the AUTH_TOKEN environment variable for API authentication:
π§ͺ Development
Install Development Dependencies
Run Tests
Format Code
Lint Code
Type Checking
π Troubleshooting
Package Not Found
Verify the package name is correct (use lowercase, hyphens not underscores)
Search first with
search_pypi_packagesto find the exact name
Extraction Failed
Some packages may not have source distributions
Check if a wheel-only package is available
Timeout Issues
Large packages may take time to download
Increase timeout values if needed
π Related Projects
π License
MIT License - See LICENSE file for details
π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
β Credits
Inspired by the NPM Package MCP Server
Made with β€οΈ