PyPI Package MCP Server

PyPI Package MCP Server

Enables AI assistants to fetch, explore, and analyze source code from any Python package on PyPI, including listing files, reading specific code, and searching packages across all published versions.

Category
Visit Server

README

๐Ÿ“ฆ PyPI Package MCP Server

Python License: MIT

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)

git clone https://github.com/Qvakk/pypi-package-mcp-server.git
cd pypi-package-mcp-server
pip install -e .
pypi-package-mcp-server

Option 2: Local Development (HTTP Mode)

git 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

Option 3: With Authentication Token

# 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

Option 4: Docker (Production - HTTP Mode)

# 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

๐Ÿ”ง Configuration

Environment Variables

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

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 /health
  • MCP endpoint: POST /mcp
  • Command: 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:

# 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

๐Ÿ“Š 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:

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

๐Ÿ› ๏ธ Tools

1. get_pypi_package_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"
)

2. list_package_files

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")

3. get_package_info

Get metadata about a package.

pypi_server.get_package_info(package_name="requests")

4. search_pypi_packages

Search for packages on PyPI.

pypi_server.search_pypi_packages(query="web framework", limit=20)

๐Ÿ“‹ Requirements

  • Python 3.9 or higher
  • mcp >= 0.1.0
  • requests >= 2.31.0
  • pydantic >= 2.0.0

๐Ÿ”’ Authentication (Optional)

Set the AUTH_TOKEN environment variable for API authentication:

export AUTH_TOKEN=your-secret-token
pypi-package-mcp-server

๐Ÿงช Development

Install Development Dependencies

pip install -e ".[dev]"

Run Tests

pytest

Format Code

black pypi_mcp_server/

Lint Code

ruff check pypi_mcp_server/

Type Checking

mypy pypi_mcp_server/

๐Ÿ› Troubleshooting

Package Not Found

  • Verify the package name is correct (use lowercase, hyphens not underscores)
  • Search first with search_pypi_packages to 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 โค๏ธ

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured