A powerful Model Context Protocol (MCP) server that enables AI assistants to fetch, explore, and analyze source code from any Python package on PyPI.
- π¦ 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
- 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
git clone https://github.com/Qvakk/pypi-package-mcp-server.git
cd pypi-package-mcp-server
pip install -e .
pypi-package-mcp-servergit clone https://github.com/Qvakk/pypi-package-mcp-server.git
cd pypi-package-mcp-server
pip install -e .
TRANSPORT_MODE=http PORT=3000 pypi-package-mcp-server# Stdio mode with auth
AUTH_TOKEN=your-secret-token pypi-package-mcp-server
# HTTP mode with auth
TRANSPORT_MODE=http PORT=3000 AUTH_TOKEN=your-secret-token pypi-package-mcp-server# Build Docker image
docker build -t pypi-package-mcp-server .
# Run in stdio mode (Claude Desktop)
docker run -it pypi-package-mcp-server
# Run in HTTP mode
docker run -p 3000:3000 \
-e TRANSPORT_MODE=http \
-e PORT=3000 \
pypi-package-mcp-server
# Run with authentication
docker run -p 3000:3000 \
-e TRANSPORT_MODE=http \
-e PORT=3000 \
-e AUTH_TOKEN=your-secret-token \
pypi-package-mcp-server
# Use Docker Compose
docker-compose up -d| Variable | Default | Description |
|---|---|---|
TRANSPORT_MODE |
stdio |
Transport mode: stdio or http |
PORT |
3000 |
HTTP server port (only used in http mode) |
AUTH_TOKEN |
(none) | Optional authentication token for API access |
- Best for: Claude Desktop, local development
- Connection: Standard input/output streams
- Command:
pypi-package-mcp-server
- Best for: Remote servers, containerized deployments
- Connection: HTTP requests on specified port
- Health endpoint:
GET /health - MCP endpoint:
POST /mcp - Command:
TRANSPORT_MODE=http PORT=3000 pypi-package-mcp-server
When AUTH_TOKEN environment variable is set, all HTTP requests must include the token in the Authorization header:
# Using Bearer token
curl -H "Authorization: Bearer your-secret-token" http://localhost:3000/health
# Or just the token
curl -H "Authorization: your-secret-token" http://localhost:3000/health- β All public PyPI packages
- β Any published version
- β
Source distributions (
.tar.gz) - β
Binary wheels (
.whl) - β Monorepo packages
- β Pure Python and native extensions
Try these commands with your AI assistant:
"Analyze the requests library implementation"
"Show me the Django ORM structure"
"Explore the Flask application framework"
"Review the NumPy array implementation"
"Study the pandas DataFrame code"
Fetch source code from a Python package.
# Get all source files from the latest version
pypi_server.get_pypi_package_code(package_name="requests")
# Get a specific version
pypi_server.get_pypi_package_code(package_name="django", version="4.2.0")
# Get a specific file
pypi_server.get_pypi_package_code(
package_name="flask",
file_path="src/flask/app.py"
)List all files in a package.
pypi_server.list_package_files(package_name="numpy")
pypi_server.list_package_files(package_name="pandas", version="2.0.0")Get metadata about a package.
pypi_server.get_package_info(package_name="requests")Search for packages on PyPI.
pypi_server.search_pypi_packages(query="web framework", limit=20)- Python 3.9 or higher
mcp>= 0.1.0requests>= 2.31.0pydantic>= 2.0.0
Set the AUTH_TOKEN environment variable for API authentication:
export AUTH_TOKEN=your-secret-token
pypi-package-mcp-serverpip install -e ".[dev]"pytestblack pypi_mcp_server/ruff check pypi_mcp_server/mypy pypi_mcp_server/- Verify the package name is correct (use lowercase, hyphens not underscores)
- Search first with
search_pypi_packagesto find the exact name
- Some packages may not have source distributions
- Check if a wheel-only package is available
- Large packages may take time to download
- Increase timeout values if needed
MIT License - See LICENSE file for details
Contributions are welcome! Please feel free to submit a Pull Request.
Inspired by the NPM Package MCP Server
Made with β€οΈ