Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pypi-mcp-server/.actor/actor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"actorSpecification": 1,
"name": "pypi-query-mcp-server",
"title": "PyPI Query MCP Server",
"description": "An Apify Actor that proxies the pypi-query-mcp-server over Streamable HTTP with optional charging and tool whitelisting.",
"version": "0.1",
"buildTag": "latest",
"usesStandbyMode": true,
"meta": {
"templateId": "python-mcp-server"
},
"dockerfile": "../Dockerfile",
"webServerMcpPath": "/mcp"
}
12 changes: 12 additions & 0 deletions pypi-mcp-server/.actor/pay_per_event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"actor-start": {
"eventTitle": "MCP server startup",
"eventDescription": "Initial fee for starting the MCP Server Actor.",
"eventPriceUsd": 0.10
},
"tool-call": {
"eventTitle": "PyPI tool call",
"eventDescription": "Flat fee for any PyPI Query MCP tool invocation.",
"eventPriceUsd": 0.001
}
}
167 changes: 167 additions & 0 deletions pypi-mcp-server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
.mise.toml
.nvim.lua
storage

# The rest is copied from https://github.com/github/gitignore/blob/main/Python.gitignore

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
.python-version

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

# Visual Studio Code
# Ignores the folder created by VS Code when changing workspace settings, doing debugger
# configuration, etc. Can be commented out to share Workspace Settings within a team
.vscode

# Zed editor
# Ignores the folder created when setting Project Settings in the Zed editor. Can be commented out
# to share Project Settings within a team
.zed

# Added by Apify CLI
node_modules
35 changes: 35 additions & 0 deletions pypi-mcp-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# First, specify the base Docker image.
# You can see the Docker images from Apify at https://hub.docker.com/r/apify/.
# You can also use any other image from Docker Hub.
FROM apify/actor-python:3.13

USER myuser

# Second, copy just requirements.txt into the Actor image,
# since it should be the only file that affects the dependency installation in the next step,
# in order to speed up the build.
COPY --chown=myuser:myuser requirements.txt ./

# Install the packages specified in requirements.txt,
# print the installed Python version, pip version,
# and all installed packages with their versions for debugging.
RUN echo "Python version:" \
&& python --version \
&& echo "Pip version:" \
&& pip --version \
&& echo "Installing dependencies:" \
&& pip install -r requirements.txt \
&& echo "All installed Python packages:" \
&& pip freeze

# Next, copy the remaining files and directories with the source code.
# Since we do this after installing the dependencies, quick builds will be really fast
# for most source file changes.
COPY --chown=myuser:myuser . ./

# Use compileall to ensure the runnability of the Actor Python code.
RUN python3 -m compileall -q src/

# Specify how to launch the source code of your Actor.
# By default, the "python3 -m ." command is run.
CMD ["python3", "-m", "src"]
163 changes: 163 additions & 0 deletions pypi-mcp-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
## PyPI Query MCP Server

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.

**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).

---

## Connection URL

MCP clients can connect to this server at:

```text
https://mcp-servers--pypi-query-mcp-server.apify.actor/mcp
```

---

## Client Configuration

Add this to your MCP client configuration:

```json
{
"mcpServers": {
"pypi-query": {
"url": "https://mcp-servers--pypi-query-mcp-server.apify.actor/mcp",
"headers": {
"Authorization": "Bearer YOUR_APIFY_TOKEN"
}
}
}
}
```

**Note:** Replace `YOUR_APIFY_TOKEN` with your Apify API token (find it in the [Apify Console](https://console.apify.com/account/integrations)).

---

## 🚩 Claim this MCP server

All credit to the original authors of **pypi-query-mcp-server**: <https://github.com/loonghao/pypi-query-mcp-server>
To claim this server on Apify, please email [[email protected]](mailto:[email protected]).

---

## What this server does

- Proxies the **PyPI Query MCP Server** to HTTP so any MCP client can connect.
- Supports **per-tool charging** (via Apify’s `Actor.charge`) and a **tool whitelist**.
- Passes through environment variables for public mirrors and **private package indexes**.
- Runs reliably in **Apify Standby** with an `/mcp` endpoint and a small helper HTML page at `/`.

---

## Features

- Look up package info, versions, dependencies, and compatibility.
- Resolve dependency trees and detect conflicts.
- Gather download stats, trends, and top packages.
- Analyze package quality and security (if enabled upstream).
- Plan upgrades, migrations, and environment updates.

---

## Available Tools

This server exposes the PyPI tools provided by the upstream server (whitelisted by default). Tool identifiers:

- `get_package_info`
- `get_package_versions`
- `get_package_dependencies`
- `check_package_python_compatibility`
- `get_package_compatible_python_versions`
- `resolve_dependencies`
- `download_package`
- `get_download_statistics`
- `get_download_trends`
- `get_top_downloaded_packages`
- `analyze_package_quality`
- `compare_packages`
- `suggest_alternatives`
- `resolve_dependency_conflicts`
- `plan_version_upgrade`
- `audit_security_risks`
- `plan_package_migration`
- `generate_migration_checklist`
- `analyze_environment_dependencies`
- `check_outdated_packages`
- `generate_update_plan`
- `analyze_daily_trends`
- `find_trending_packages`
- `track_package_updates`

> Note: The exact set may evolve with upstream releases. This proxy can be configured to allow all tools or only a curated subset.

---

## Environment Variables

The proxy launches the upstream server via `uvx` (stdio) and forwards these environment variables:

- Public indexes & mirrors
- `PYPI_INDEX_URL` (default: `https://pypi.org/pypi`)
- `PYPI_INDEX_URLS`, `PYPI_EXTRA_INDEX_URLS` (comma-separated)
- Caching & logging
- `PYPI_CACHE_TTL` (default: `3600`)
- `PYPI_LOG_LEVEL` (default: `INFO`)
- Networking
- `PYPI_REQUEST_TIMEOUT` (default: `30`)
- Private repository support (optional)
- `PYPI_PRIVATE_PYPI_URL`
- `PYPI_PRIVATE_PYPI_USERNAME`
- `PYPI_PRIVATE_PYPI_PASSWORD`
- Advanced (optional)
- `PYPI_DEPENDENCY_MAX_DEPTH` (default: `5`)
- `PYPI_DEPENDENCY_MAX_CONCURRENT` (default: `10`)
- `PYPI_ENABLE_SECURITY_ANALYSIS` (`true`|`false`, default: `false`)

Set these in your Apify Actor (Secrets / Environment) as needed.

---

## Usage Examples

Ask your MCP client to:

- “Get info for `requests`.” → `get_package_info`
- “Show versions for `pydantic`.” → `get_package_versions`
- “Resolve dependencies for `fastapi==0.115.0`.” → `resolve_dependencies`
- “Are `httpx 0.27` and Python 3.12 compatible?” → `check_package_python_compatibility`
- “Top downloads last week” → `get_top_downloaded_packages`
- “Compare `requests` vs `httpx`” → `compare_packages`

---

## Pricing / Charging (optional)

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.

---

## Local development & debugging

- 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.
- The server logs a ready-to-copy MCP JSON snippet with the endpoint URL at startup.

---

## References

To learn more:

- [Apify SDK for Python](https://docs.apify.com/sdk/python)
- [Apify Platform](https://docs.apify.com/platform)
- [Apify MCP Server](https://docs.apify.com/platform/integrations/mcp)
- [Model Context Protocol docs](https://mcp.apify.com)
- [Webinar: Building and Monetizing MCP Servers on Apify](https://www.youtube.com/watch?v=w3AH3jIrXXo)
- [Join the Apify developer community on Discord](https://discord.com/invite/jyEM2PRvMU)

---

**Attribution:** Built as a proxy over the open-source **pypi-query-mcp-server**.
Loading
Loading