# `pypi__download_package`

Download a PyPI package and all its dependencies to local directory.

This tool downloads a Python package and all its dependencies, providing
comprehensive package collection for offline installation or analysis.

Args:
package_name: The name of the PyPI package to download (e.g., 'pyside2', 'requests')
download_dir: Local directory to download packages to (default: './downloads')
python_version: Target Python version for compatibility (e.g., '3.10', '3.11')
include_extras: List of extra dependency groups to include (e.g., \['dev', 'test'\])
include_dev: Whether to include development dependencies (default: False)
prefer_wheel: Whether to prefer wheel files over source distributions (default: True)
verify_checksums: Whether to verify downloaded file checksums (default: True)
max_depth: Maximum dependency resolution depth (default: 5)

Returns:
Dictionary containing download results including:
\- Download statistics and file information
\- Dependency resolution results
\- File verification results
\- Success/failure summary for each package

Raises:
InvalidPackageNameError: If package name is empty or invalid
PackageNotFoundError: If package is not found on PyPI
NetworkError: For network-related errors

- Server: [PyPI](https://gateway.mcpharbor.dev/docs/servers/pypi) (`dev.mcpharbor.gateway/pypi`)
- Price per call: $0.0001 (100 micro-USD); only tools/call is charged
- Endpoint: `https://gateway.mcpharbor.dev/mcp` or `https://gateway.mcpharbor.dev/mcp/pypi`
- Upstream tool: exposed by the provider; called through this gateway as `pypi__download_package`
- Provider terms: <https://policies.python.org/pypi.org/Terms-of-Service/> (verified 2026-09-19)
- Upstream API documentation: <https://docs.pypi.org/api/json/>
- Rate limit: 600 requests per minute

## Parameters

- `download_dir` (string, optional): Default: `./downloads`.
- `include_dev` (boolean, optional): Default: `false`.
- `include_extras` (any, optional)
- `max_depth` (integer, optional): Default: `5`.
- `package_name` (string, required)
- `prefer_wheel` (boolean, optional): Default: `true`.
- `python_version` (any, optional)
- `verify_checksums` (boolean, optional): Default: `true`.

## Example call

Request headers and body:

```http
POST /mcp HTTP/1.1
Host: gateway.mcpharbor.dev
Authorization: Bearer <your gateway API key>
Content-Type: application/json
Accept: application/json, text/event-stream
MCP-Protocol-Version: 2026-07-28
Mcp-Method: tools/call
Mcp-Name: pypi__download_package
```

```json
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "_meta": {
      "io.modelcontextprotocol/clientCapabilities": {},
      "io.modelcontextprotocol/clientInfo": {
        "name": "example-agent",
        "version": "1.0.0"
      },
      "io.modelcontextprotocol/protocolVersion": "2026-07-28"
    },
    "arguments": {
      "package_name": "example"
    },
    "name": "pypi__download_package"
  }
}
```

A successful response:

```json
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "_meta": {
      "dev.mcpharbor.gateway/call": {
        "chargedMicroUsd": 100,
        "id": "<the id of this charge>"
      }
    },
    "content": [
      {
        "text": "<whatever the upstream tool returned>",
        "type": "text"
      }
    ],
    "resultType": "complete"
  }
}
```

This call costs $0.0001 (100 micro-USD). Reading this page and listing the tool cost nothing.
The `dev.mcpharbor.gateway/call` record in the result is the receipt for that charge. Each
POST is metered separately, so sending the same call again buys another one: see
[agent.txt](https://gateway.mcpharbor.dev/agent.txt), section 7, before retrying.

## Attribution

This provider asks for no attribution. Their terms still apply: see the table above.

## Tool definition

Exactly as `tools/list` returns it (free):

```json
{
  "_meta": {
    "dev.mcpharbor.gateway/pricing": {
      "currency": "USD",
      "pricePerCallMicroUsd": 100
    }
  },
  "description": "Download a PyPI package and all its dependencies to local directory.\n\nThis tool downloads a Python package and all its dependencies, providing\ncomprehensive package collection for offline installation or analysis.\n\nArgs:\n    package_name: The name of the PyPI package to download (e.g., 'pyside2', 'requests')\n    download_dir: Local directory to download packages to (default: './downloads')\n    python_version: Target Python version for compatibility (e.g., '3.10', '3.11')\n    include_extras: List of extra dependency groups to include (e.g., ['dev', 'test'])\n    include_dev: Whether to include development dependencies (default: False)\n    prefer_wheel: Whether to prefer wheel files over source distributions (default: True)\n    verify_checksums: Whether to verify downloaded file checksums (default: True)\n    max_depth: Maximum dependency resolution depth (default: 5)\n\nReturns:\n    Dictionary containing download results including:\n    - Download statistics and file information\n    - Dependency resolution results\n    - File verification results\n    - Success/failure summary for each package\n\nRaises:\n    InvalidPackageNameError: If package name is empty or invalid\n    PackageNotFoundError: If package is not found on PyPI\n    NetworkError: For network-related errors",
  "inputSchema": {
    "properties": {
      "download_dir": {
        "default": "./downloads",
        "type": "string"
      },
      "include_dev": {
        "default": false,
        "type": "boolean"
      },
      "include_extras": {
        "anyOf": [
          {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          {
            "type": "null"
          }
        ],
        "default": null
      },
      "max_depth": {
        "default": 5,
        "type": "integer"
      },
      "package_name": {
        "type": "string"
      },
      "prefer_wheel": {
        "default": true,
        "type": "boolean"
      },
      "python_version": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "default": null
      },
      "verify_checksums": {
        "default": true,
        "type": "boolean"
      }
    },
    "required": [
      "package_name"
    ],
    "type": "object"
  },
  "name": "pypi__download_package",
  "outputSchema": {
    "additionalProperties": true,
    "type": "object"
  }
}
```
