|
| 1 | +## PyPI Query MCP Server |
| 2 | + |
| 3 | +A Model Context Protocol (MCP) server that lets AI agents explore and analyze Python packages from PyPI (and private indexes). It’s deployed as an Apify Actor and proxies the excellent open-source **pypi-query-mcp-server** over Streamable HTTP, with optional per-tool charging and a configurable whitelist. |
| 4 | + |
| 5 | +**About this MCP Server:** To understand how to connect to and utilize this MCP server, please refer to the official Model Context Protocol documentation at [mcp.apify.com](https://mcp.apify.com). |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Connection URL |
| 10 | + |
| 11 | +MCP clients can connect to this server at: |
| 12 | + |
| 13 | +```text |
| 14 | +https://mcp-servers--pypi-query-mcp-server.apify.actor/mcp |
| 15 | +``` |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## Client Configuration |
| 20 | + |
| 21 | +Add this to your MCP client configuration: |
| 22 | + |
| 23 | +```json |
| 24 | +{ |
| 25 | + "mcpServers": { |
| 26 | + "pypi-query": { |
| 27 | + "url": "https://mcp-servers--pypi-query-mcp-server.apify.actor/mcp", |
| 28 | + "headers": { |
| 29 | + "Authorization": "Bearer YOUR_APIFY_TOKEN" |
| 30 | + } |
| 31 | + } |
| 32 | + } |
| 33 | +} |
| 34 | +``` |
| 35 | + |
| 36 | +**Note:** Replace `YOUR_APIFY_TOKEN` with your Apify API token (find it in the [Apify Console](https://console.apify.com/account/integrations)). |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +## 🚩 Claim this MCP server |
| 41 | + |
| 42 | +All credit to the original authors of **pypi-query-mcp-server**: <https://github.com/loonghao/pypi-query-mcp-server> |
| 43 | +To claim this server on Apify, please email [[email protected]](mailto:[email protected]). |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## What this server does |
| 48 | + |
| 49 | +- Proxies the **PyPI Query MCP Server** to HTTP so any MCP client can connect. |
| 50 | +- Supports **per-tool charging** (via Apify’s `Actor.charge`) and a **tool whitelist**. |
| 51 | +- Passes through environment variables for public mirrors and **private package indexes**. |
| 52 | +- Runs reliably in **Apify Standby** with an `/mcp` endpoint and a small helper HTML page at `/`. |
| 53 | + |
| 54 | +--- |
| 55 | + |
| 56 | +## Features |
| 57 | + |
| 58 | +- Look up package info, versions, dependencies, and compatibility. |
| 59 | +- Resolve dependency trees and detect conflicts. |
| 60 | +- Gather download stats, trends, and top packages. |
| 61 | +- Analyze package quality and security (if enabled upstream). |
| 62 | +- Plan upgrades, migrations, and environment updates. |
| 63 | + |
| 64 | +--- |
| 65 | + |
| 66 | +## Available Tools |
| 67 | + |
| 68 | +This server exposes the PyPI tools provided by the upstream server (whitelisted by default). Tool identifiers: |
| 69 | + |
| 70 | +- `get_package_info` |
| 71 | +- `get_package_versions` |
| 72 | +- `get_package_dependencies` |
| 73 | +- `check_package_python_compatibility` |
| 74 | +- `get_package_compatible_python_versions` |
| 75 | +- `resolve_dependencies` |
| 76 | +- `download_package` |
| 77 | +- `get_download_statistics` |
| 78 | +- `get_download_trends` |
| 79 | +- `get_top_downloaded_packages` |
| 80 | +- `analyze_package_quality` |
| 81 | +- `compare_packages` |
| 82 | +- `suggest_alternatives` |
| 83 | +- `resolve_dependency_conflicts` |
| 84 | +- `plan_version_upgrade` |
| 85 | +- `audit_security_risks` |
| 86 | +- `plan_package_migration` |
| 87 | +- `generate_migration_checklist` |
| 88 | +- `analyze_environment_dependencies` |
| 89 | +- `check_outdated_packages` |
| 90 | +- `generate_update_plan` |
| 91 | +- `analyze_daily_trends` |
| 92 | +- `find_trending_packages` |
| 93 | +- `track_package_updates` |
| 94 | + |
| 95 | +> Note: The exact set may evolve with upstream releases. This proxy can be configured to allow all tools or only a curated subset. |
| 96 | +
|
| 97 | +--- |
| 98 | + |
| 99 | +## Environment Variables |
| 100 | + |
| 101 | +The proxy launches the upstream server via `uvx` (stdio) and forwards these environment variables: |
| 102 | + |
| 103 | +- Public indexes & mirrors |
| 104 | + - `PYPI_INDEX_URL` (default: `https://pypi.org/pypi`) |
| 105 | + - `PYPI_INDEX_URLS`, `PYPI_EXTRA_INDEX_URLS` (comma-separated) |
| 106 | +- Caching & logging |
| 107 | + - `PYPI_CACHE_TTL` (default: `3600`) |
| 108 | + - `PYPI_LOG_LEVEL` (default: `INFO`) |
| 109 | +- Networking |
| 110 | + - `PYPI_REQUEST_TIMEOUT` (default: `30`) |
| 111 | +- Private repository support (optional) |
| 112 | + - `PYPI_PRIVATE_PYPI_URL` |
| 113 | + - `PYPI_PRIVATE_PYPI_USERNAME` |
| 114 | + - `PYPI_PRIVATE_PYPI_PASSWORD` |
| 115 | +- Advanced (optional) |
| 116 | + - `PYPI_DEPENDENCY_MAX_DEPTH` (default: `5`) |
| 117 | + - `PYPI_DEPENDENCY_MAX_CONCURRENT` (default: `10`) |
| 118 | + - `PYPI_ENABLE_SECURITY_ANALYSIS` (`true`|`false`, default: `false`) |
| 119 | + |
| 120 | +Set these in your Apify Actor (Secrets / Environment) as needed. |
| 121 | + |
| 122 | +--- |
| 123 | + |
| 124 | +## Usage Examples |
| 125 | + |
| 126 | +Ask your MCP client to: |
| 127 | + |
| 128 | +- “Get info for `requests`.” → `get_package_info` |
| 129 | +- “Show versions for `pydantic`.” → `get_package_versions` |
| 130 | +- “Resolve dependencies for `fastapi==0.115.0`.” → `resolve_dependencies` |
| 131 | +- “Are `httpx 0.27` and Python 3.12 compatible?” → `check_package_python_compatibility` |
| 132 | +- “Top downloads last week” → `get_top_downloaded_packages` |
| 133 | +- “Compare `requests` vs `httpx`” → `compare_packages` |
| 134 | + |
| 135 | +--- |
| 136 | + |
| 137 | +## Pricing / Charging (optional) |
| 138 | + |
| 139 | +This server can charge per MCP operation. Defaults are defined in code (`src/const.py`) and can be tuned per tool (e.g., heavier “resolve” or “download” operations can cost more). If you don’t want charging, remove or relax the whitelist and omit charging hooks. |
| 140 | + |
| 141 | +--- |
| 142 | + |
| 143 | +## Local development & debugging |
| 144 | + |
| 145 | +- This Actor only serves in **STANDBY** on Apify. When running locally you can still start it, but the HTTP `/mcp` endpoint is designed for Standby on the platform. |
| 146 | +- The server logs a ready-to-copy MCP JSON snippet with the endpoint URL at startup. |
| 147 | + |
| 148 | +--- |
| 149 | + |
| 150 | +## References |
| 151 | + |
| 152 | +To learn more: |
| 153 | + |
| 154 | +- [Apify SDK for Python](https://docs.apify.com/sdk/python) |
| 155 | +- [Apify Platform](https://docs.apify.com/platform) |
| 156 | +- [Apify MCP Server](https://docs.apify.com/platform/integrations/mcp) |
| 157 | +- [Model Context Protocol docs](https://mcp.apify.com) |
| 158 | +- [Webinar: Building and Monetizing MCP Servers on Apify](https://www.youtube.com/watch?v=w3AH3jIrXXo) |
| 159 | +- [Join the Apify developer community on Discord](https://discord.com/invite/jyEM2PRvMU) |
| 160 | + |
| 161 | +--- |
| 162 | + |
| 163 | +**Attribution:** Built as a proxy over the open-source **pypi-query-mcp-server**. |
0 commit comments