Skip to main content

Query latest package versions from PyPI, npm, crates.io, Docker Hub, and GitHub Actions

Project description

package-query

Query the latest package versions from PyPI, npm, crates.io, Docker Hub, and GitHub Actions — directly from Python or as an MCP server for AI agents.

Installation

# Core library only
uv pip install package-query

# With MCP server support
uv pip install "package-query[mcp]"

Python Usage

from asyncio import run
from package_query import PackageQuery, PackageInfo

async def main():
    pq = PackageQuery()

    # Single query — format_pinned() returns the registry-native pinning format
    info: PackageInfo = await pq.query("pypi", "requests")
    print(info.format_pinned())  # [pypi] requests==2.32.3

    info = await pq.query("npm", "express")
    print(info.format_pinned())  # [npm] express@5.2.1

    info = await pq.query("github-actions", "actions/checkout")
    print(info.format_pinned())  # [github-actions] actions/checkout@v4

    # Batch query — all resolved concurrently
    packages = [
        {"registry": "pypi", "package": "flask"},
        {"registry": "npm", "package": "typescript"},
        {"registry": "crates", "package": "tokio"},
        {"registry": "docker", "package": "nginx"},
        {"registry": "github-actions", "package": "actions/setup-python"},
    ]
    results = await pq.query_batch(packages)
    print(pq.format_batch(packages, results))
    # [pypi] flask==3.1.1
    # [npm] typescript@5.8.3
    # [crates] tokio = "=1.45.0"
    # [docker] nginx:stable-alpine3.23
    # [github-actions] actions/setup-python@v5

run(main())

Output Format

Each registry uses its ecosystem-standard version-pinning format, prefixed with [registry]:

Registry Format Example
pypi [pypi] name==version [pypi] requests==2.32.3
npm [npm] name@version [npm] express@5.2.1
crates [crates] name = "=version" [crates] serde = "=1.0.228"
docker [docker] name:tag [docker] nginx:stable-alpine3.23
github-actions [github-actions] owner/repo@tag [github-actions] actions/checkout@v4

Supported Registries

Registry Example Package
pypi requests
npm express
crates serde
docker nginx
github-actions actions/checkout

MCP Server

The MCP server allows AI agents (Claude, Copilot, Cursor, etc.) to query package versions without web search.

Running the Server

# If installed with [mcp] extra
package-query-mcp

# Or from source
uv run --extra mcp package-query-mcp

IDE Configuration

VS Code / Cursor

Add to your settings.json:

{
  "mcp": {
    "servers": {
      "package-query": {
        "command": "uvx",
        "args": ["--from", "package-query[mcp]", "package-query-mcp"]
      }
    }
  }
}

Or if installed globally:

{
  "mcp": {
    "servers": {
      "package-query": {
        "command": "package-query-mcp"
      }
    }
  }
}

Claude Desktop

Add to ~/.config/Claude/claude_desktop_config.json (Linux) or equivalent:

{
  "mcpServers": {
    "package-query": {
      "command": "uvx",
      "args": ["--from", "package-query[mcp]", "package-query-mcp"]
    }
  }
}

Antigravity IDE

Add to ~/.gemini/antigravity/mcp_config.json:

{
  "mcpServers": {
    "package-query": {
      "command": "uvx",
      "args": ["--from", "package-query[mcp]", "package-query-mcp"]
    }
  }
}

Available Tools

Tool Description
get_package_version Get the latest version of a single package
get_package_versions Get versions for multiple packages in one call (recommended)

get_package_version

  • registry (string): One of pypi, npm, crates, docker, github-actions
  • package (string): Package name (e.g. "requests", "actions/checkout")
  • include_prerelease (bool, optional): Include pre-release versions

Returns a single line like [pypi] requests==2.32.3.

get_package_versions (batch — preferred)

  • packages (list): Array of objects with "registry" and "package" keys
  • include_prerelease (bool, optional): Apply to all queries

All queries run concurrently. Returns one line per package:

[pypi] requests==2.32.3
[npm] express@5.2.1
[crates] serde = "=1.0.228"
[docker] nginx:stable-alpine3.23
[github-actions] actions/checkout@v4
[pypi] nonexistent: error: Package 'nonexistent' not found on PyPI

Development

# Clone and install all dependencies
git clone https://github.com/henrique-coder/package-query.git
cd package-query
uv sync --upgrade --all-groups --all-extras
just lint
just format

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

package_query-0.1.2.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

package_query-0.1.2-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file package_query-0.1.2.tar.gz.

File metadata

  • Download URL: package_query-0.1.2.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for package_query-0.1.2.tar.gz
Algorithm Hash digest
SHA256 269e49c228d886f2e356bffabcd9be52de5f1e93cb276c65efbf8dd1444408f3
MD5 05a2265844aea3f26977e26242a089c9
BLAKE2b-256 44dbd614ade751f6b134ee123ba66380b128d570f0a3e63dac812401a30fffb3

See more details on using hashes here.

File details

Details for the file package_query-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: package_query-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for package_query-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1c07bfcfe93e03283d258a34f90403ae9a859a7064a3144da67137f76ca0508d
MD5 ce21e6e72228b9beb92a007fd151bd3c
BLAKE2b-256 b1d7ec12ade42b79373956d305d3d083b08d11755378c7ecb1815bcd54c7219a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page