# Subnet Calculator MCP Server
[](https://github.com/sanjayshreeyans/subnet-calculator-mcp/actions/workflows/ci.yml)
`subnet-calculator-mcp` is a production-ready [Model Context Protocol](https://modelcontextprotocol.io/) server that delivers reliable IPv4 subnet planning utilities to LLM-powered assistants. It eliminates tedious manual math by exposing fast, well-tested tools for subnet sizing, wildcard mask generation, gateway selection, and host validation.
## Why Use This Server?
- 🔢 Convert host requirements into accurate subnet masks and CIDR prefixes
- 🌐 Produce Cisco-friendly OSPF wildcard masks and network statements
- ✅ Verify whether an IP belongs to a subnet, including gateway hints and address position
- 🔄 Reverse-calculations from dotted masks or find the Nth usable address instantly
- ⚙️ Built on the official Python MCP SDK with thorough type hints, validation, and tests
## Install & Run
The package is published on PyPI: <https://pypi.org/project/subnet-calculator-mcp/>
### Install with pip
```bash
pip install subnet-calculator-mcp
python -m subnet_calculator_mcp.server
```
### Run instantly (no install)
```bash
uvx subnet-calculator-mcp
```
### Install as a reusable CLI
```bash
uv tool install subnet-calculator-mcp
# later
subnet-calculator-mcp
```
## Client Configuration
### Claude Desktop / Claude for Windows
Add the server to `claude_desktop_config.json`.
**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
```json
{
  "mcpServers": {
    "subnet-calculator": {
      "command": "uvx",
      "args": ["subnet-calculator-mcp"]
    }
  }
}
```
If you installed via `uv tool install` or `pip`, change the command to `"subnet-calculator-mcp"` and omit `args`.
### Generic `mcp.json`
Many editors (Cursor, Windsurf, etc.) use an `mcp.json` file. Add the following entry:
```json
{
  "subnet-calculator": {
    "command": "uvx",
    "args": ["subnet-calculator-mcp"],
    "env": {}
  }
}
```
Set `command` to `"subnet-calculator-mcp"` if the binary is installed globally.
## Tool Reference
### `calculate_subnet`
- **Inputs**: `network_base` (IPv4 address), `hosts_needed` (int), optional `return_format` (`"detailed"` or `"simple"`).
- **Returns**: CIDR prefix, dotted mask, wildcard mask, usable range, broadcast, binary representations, total/usable host counts.
- **Use it for**: deriving the smallest subnet that can host the requested number of usable addresses.
### `calculate_wildcard_mask`
- **Inputs**: `ip_address` (any IP in the subnet), `cidr_prefix` (0–32), optional `include_ospf_command` (bool).
- **Returns**: network address, mask, wildcard mask, binary wildcard string, and optional `network ... area 0` statement.
- **Use it for**: creating OSPF configurations or ACLs that rely on wildcard masks.
### `validate_ip_in_subnet`
- **Inputs**: `ip_address`, `network` (CIDR string), optional `return_gateway` (bool).
- **Returns**: membership flag, mask, prefix, network/broadcast flags, usability, likely gateway, position index, and remaining usable addresses.
- **Use it for**: quickly verifying assignments and identifying first-hop router addresses.
### `calculate_subnet_from_mask`
- **Inputs**: `ip_address`, `subnet_mask` (dotted decimal).
- **Returns**: network boundary, prefix, wildcard mask, usable range, broadcast, and host counts.
- **Use it for**: analysing legacy configurations that provide dotted masks instead of CIDR notation.
### `get_nth_usable_ip`
- **Inputs**: `network` (CIDR string), `position` (1-based index).
- **Returns**: IP address at that position, whether it is last usable, total usable hosts, and associated network address.
- **Use it for**: allocating deterministic host positions (first server, second router, etc.).
Example invocation:
```json
{
  "tool": "calculate_subnet",
  "arguments": {
    "network_base": "172.16.0.16",
    "hosts_needed": 14
  }
}
```
## Development Workflow
```bash
git clone https://github.com/sanjayshreeyans/subnet-calculator-mcp.git
cd subnet-calculator-mcp
# Install dependencies (dev group includes pytest, mypy, ruff, black)
uv sync --group dev
# Run the automated test suite
uv run pytest
# Type-check, lint, and format
uv run mypy src
uv run ruff check src tests
uv run black --check src tests
# Build distribution artifacts
uv build
```
## License
MIT License – see `LICENSE` for details.
            
         
        Raw data
        
            {
    "_id": null,
    "home_page": null,
    "name": "subnet-calculator-mcp",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "calculator, cisco, mcp, networking, ospf, subnet",
    "author": null,
    "author_email": "Sanjay Shreeyans Javangula <sanjayshreeyans@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/91/84/2ac5498b378408229690c65aae9e58462770b0712f6e40c393feb8dadd99/subnet_calculator_mcp-0.1.2.tar.gz",
    "platform": null,
    "description": "# Subnet Calculator MCP Server\n\n[](https://github.com/sanjayshreeyans/subnet-calculator-mcp/actions/workflows/ci.yml)\n`subnet-calculator-mcp` is a production-ready [Model Context Protocol](https://modelcontextprotocol.io/) server that delivers reliable IPv4 subnet planning utilities to LLM-powered assistants. It eliminates tedious manual math by exposing fast, well-tested tools for subnet sizing, wildcard mask generation, gateway selection, and host validation.\n\n## Why Use This Server?\n\n- \ud83d\udd22 Convert host requirements into accurate subnet masks and CIDR prefixes\n- \ud83c\udf10 Produce Cisco-friendly OSPF wildcard masks and network statements\n- \u2705 Verify whether an IP belongs to a subnet, including gateway hints and address position\n- \ud83d\udd04 Reverse-calculations from dotted masks or find the Nth usable address instantly\n- \u2699\ufe0f Built on the official Python MCP SDK with thorough type hints, validation, and tests\n\n## Install & Run\n\nThe package is published on PyPI: <https://pypi.org/project/subnet-calculator-mcp/>\n\n### Install with pip\n\n```bash\npip install subnet-calculator-mcp\npython -m subnet_calculator_mcp.server\n```\n\n### Run instantly (no install)\n\n```bash\nuvx subnet-calculator-mcp\n```\n\n### Install as a reusable CLI\n\n```bash\nuv tool install subnet-calculator-mcp\n# later\nsubnet-calculator-mcp\n```\n\n## Client Configuration\n\n### Claude Desktop / Claude for Windows\n\nAdd the server to `claude_desktop_config.json`.\n\n**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`\n\n**Windows:** `%APPDATA%\\Claude\\claude_desktop_config.json`\n\n```json\n{\n  \"mcpServers\": {\n    \"subnet-calculator\": {\n      \"command\": \"uvx\",\n      \"args\": [\"subnet-calculator-mcp\"]\n    }\n  }\n}\n```\n\nIf you installed via `uv tool install` or `pip`, change the command to `\"subnet-calculator-mcp\"` and omit `args`.\n\n### Generic `mcp.json`\n\nMany editors (Cursor, Windsurf, etc.) use an `mcp.json` file. Add the following entry:\n\n```json\n{\n  \"subnet-calculator\": {\n    \"command\": \"uvx\",\n    \"args\": [\"subnet-calculator-mcp\"],\n    \"env\": {}\n  }\n}\n```\n\nSet `command` to `\"subnet-calculator-mcp\"` if the binary is installed globally.\n\n## Tool Reference\n\n### `calculate_subnet`\n\n- **Inputs**: `network_base` (IPv4 address), `hosts_needed` (int), optional `return_format` (`\"detailed\"` or `\"simple\"`).\n- **Returns**: CIDR prefix, dotted mask, wildcard mask, usable range, broadcast, binary representations, total/usable host counts.\n- **Use it for**: deriving the smallest subnet that can host the requested number of usable addresses.\n\n### `calculate_wildcard_mask`\n\n- **Inputs**: `ip_address` (any IP in the subnet), `cidr_prefix` (0\u201332), optional `include_ospf_command` (bool).\n- **Returns**: network address, mask, wildcard mask, binary wildcard string, and optional `network ... area 0` statement.\n- **Use it for**: creating OSPF configurations or ACLs that rely on wildcard masks.\n\n### `validate_ip_in_subnet`\n\n- **Inputs**: `ip_address`, `network` (CIDR string), optional `return_gateway` (bool).\n- **Returns**: membership flag, mask, prefix, network/broadcast flags, usability, likely gateway, position index, and remaining usable addresses.\n- **Use it for**: quickly verifying assignments and identifying first-hop router addresses.\n\n### `calculate_subnet_from_mask`\n\n- **Inputs**: `ip_address`, `subnet_mask` (dotted decimal).\n- **Returns**: network boundary, prefix, wildcard mask, usable range, broadcast, and host counts.\n- **Use it for**: analysing legacy configurations that provide dotted masks instead of CIDR notation.\n\n### `get_nth_usable_ip`\n\n- **Inputs**: `network` (CIDR string), `position` (1-based index).\n- **Returns**: IP address at that position, whether it is last usable, total usable hosts, and associated network address.\n- **Use it for**: allocating deterministic host positions (first server, second router, etc.).\n\nExample invocation:\n\n```json\n{\n  \"tool\": \"calculate_subnet\",\n  \"arguments\": {\n    \"network_base\": \"172.16.0.16\",\n    \"hosts_needed\": 14\n  }\n}\n```\n\n## Development Workflow\n\n```bash\ngit clone https://github.com/sanjayshreeyans/subnet-calculator-mcp.git\ncd subnet-calculator-mcp\n\n# Install dependencies (dev group includes pytest, mypy, ruff, black)\nuv sync --group dev\n\n# Run the automated test suite\nuv run pytest\n\n# Type-check, lint, and format\nuv run mypy src\nuv run ruff check src tests\nuv run black --check src tests\n\n# Build distribution artifacts\nuv build\n```\n\n## License\n\nMIT License \u2013 see `LICENSE` for details.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "IPv4 subnet calculator MCP server for host planning, wildcard masks, and IP validation",
    "version": "0.1.2",
    "project_urls": {
        "Documentation": "https://github.com/sanjayshreeyans/subnet-calculator-mcp#readme",
        "Homepage": "https://github.com/sanjayshreeyans/subnet-calculator-mcp",
        "Issues": "https://github.com/sanjayshreeyans/subnet-calculator-mcp/issues",
        "Repository": "https://github.com/sanjayshreeyans/subnet-calculator-mcp"
    },
    "split_keywords": [
        "calculator",
        " cisco",
        " mcp",
        " networking",
        " ospf",
        " subnet"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "377b1fc482a6bf9bea8d6f758ea8eee11a83d9b1dbdf5250d9ad7a8bfdca11e5",
                "md5": "3cb9e66b4d4c408cbe8162ffc49e8b50",
                "sha256": "d7ea8bb60ef1c65f10392daf7d9ed2cac5c7652d1ddb93c28f2806cc6862e589"
            },
            "downloads": -1,
            "filename": "subnet_calculator_mcp-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3cb9e66b4d4c408cbe8162ffc49e8b50",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 9881,
            "upload_time": "2025-10-31T01:22:34",
            "upload_time_iso_8601": "2025-10-31T01:22:34.118705Z",
            "url": "https://files.pythonhosted.org/packages/37/7b/1fc482a6bf9bea8d6f758ea8eee11a83d9b1dbdf5250d9ad7a8bfdca11e5/subnet_calculator_mcp-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "91842ac5498b378408229690c65aae9e58462770b0712f6e40c393feb8dadd99",
                "md5": "33bd01a9689e4912f2e6dd82fb8aa5f9",
                "sha256": "800a215c685827519ef681501de08f38382af0f7d755abf52a2fcbfd8a11e8b0"
            },
            "downloads": -1,
            "filename": "subnet_calculator_mcp-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "33bd01a9689e4912f2e6dd82fb8aa5f9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 39303,
            "upload_time": "2025-10-31T01:22:32",
            "upload_time_iso_8601": "2025-10-31T01:22:32.999039Z",
            "url": "https://files.pythonhosted.org/packages/91/84/2ac5498b378408229690c65aae9e58462770b0712f6e40c393feb8dadd99/subnet_calculator_mcp-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-31 01:22:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sanjayshreeyans",
    "github_project": "subnet-calculator-mcp#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "subnet-calculator-mcp"
}