Metadata-Version: 2.4
Name: mcp-server-ipinfo
Version: 0.5.0
Summary: IP Geolocation Server for MCP
Project-URL: Repository, https://github.com/briandconnelly/mcp-server-ipinfo.git
Project-URL: Issues, https://github.com/briandconnelly/mcp-server-ipinfo/issues
Author-email: Brian Connelly <bdc@bconnelly.net>
License: MIT License
        
        Copyright (c) 2025 Brian Connelly
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Networking
Requires-Python: >=3.13
Requires-Dist: fastmcp>=3.2.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: ipinfo>=5.4.0
Requires-Dist: pydantic>=2.10.6
Provides-Extra: dev
Requires-Dist: prek>=0.3.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
Requires-Dist: pytest-cov>=7.1.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.11.0; extra == 'dev'
Requires-Dist: time-machine>=2.16.0; extra == 'dev'
Requires-Dist: ty>=0.0.1a7; extra == 'dev'
Description-Content-Type: text/markdown

# IP Geolocation MCP Server

[![PyPI](https://img.shields.io/pypi/v/mcp-server-ipinfo)](https://pypi.org/project/mcp-server-ipinfo/)
[![CI](https://github.com/briandconnelly/mcp-server-ipinfo/actions/workflows/checks.yml/badge.svg)](https://github.com/briandconnelly/mcp-server-ipinfo/actions/workflows/checks.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A [Model Context Protocol](https://modelcontextprotocol.io) server that exposes the [ipinfo.io](https://ipinfo.io) API to AI agents. Geolocate IPv4 and IPv6 addresses, identify ISPs and ASNs, detect VPN/proxy/Tor exit nodes, and generate interactive maps for sets of IPs.


## Installation

Sign up for a free IPInfo API token at <https://ipinfo.io/signup> if you don't have one. The server runs with no token (free Lite tier — country and ASN basics) but most fields require a token.

Most MCP clients accept the following values:

| Field | Value |
|-------|-------|
| **Command** | `uvx` |
| **Arguments** | `mcp-server-ipinfo` |
| **Environment** | `IPINFO_API_TOKEN` = `<YOUR TOKEN>` |

### Development Version

To run the latest from `main`:

| Field | Value |
|-------|-------|
| **Command** | `uvx` |
| **Arguments** | `--from`, `git+https://github.com/briandconnelly/mcp-server-ipinfo`, `mcp-server-ipinfo` |
| **Environment** | `IPINFO_API_TOKEN` = `<YOUR TOKEN>` |


## Tools

- **`ipinfo_lookup_my_ip()`** — Geolocate the calling client's own IP. Takes no arguments. On stdio transports the result reflects this server's outbound IP, not the end user's.
- **`ipinfo_lookup_ips(ips, detail="full")`** — Geolocate one or more specified IPs. `detail="summary"` strips heavy nested blocks (continent, flags, currency, abuse, domains) for batch token savings while preserving shape parity. Capped at 500,000 IPs per call. Invalid or special-use addresses (private, loopback, etc.) are filtered with `ctx.warning()` and excluded from the result list — match returned `IPDetails.ip` values back to your input to detect what was dropped.
- **`ipinfo_check_residential_proxy(ip)`** — Check whether an IP is a known residential-proxy exit node. Tagged `enterprise` — requires the IPInfo residential-proxy add-on.
- **`ipinfo_generate_map_url(ips)`** — Build an interactive ipinfo.io map for a set of IPs. Returns a `MapResult` with the URL, the count that made the map, the IPs filtered out (with reasons, capped at 100), and a `truncated` flag.

### Plan tiers

| Tier | Fields available |
|------|------------------|
| Free Lite (no token) | country, country_code, continent, ASN basics |
| Core | full geolocation, ASN details, privacy/VPN/proxy/Tor/hosting flags |
| Plus | adds carrier and company data |
| Enterprise | adds domains and abuse contacts |
| Residential-proxy add-on | enables `ipinfo_check_residential_proxy`. Sold separately on top of Enterprise; not included by default. |

### Errors

Every tool raises a `ToolError` whose message is a JSON-encoded envelope with a stable `code` (`invalid_ip_address`, `special_ip_unsupported`, `no_valid_ips`, `too_many_ips`, `auth_invalid`, `auth_insufficient_scope`, `quota_exceeded`, `timeout`, `api_error`, `unknown_error`), a `temporary` flag, optional `retry_after_ms`, and a `repair` hint. Agents should parse the message as JSON and branch on `code`.

### Deprecated tools

`get_ip_details`, `get_residential_proxy_info`, and `get_map_url` are forwarding aliases retained from 0.4.x. They are tagged `deprecated` and **will be removed in 0.6.0**. New code should call the `ipinfo_*` tools directly.


## Configuration

### Environment Variables

| Variable | Description | Default |
|----------|-------------|---------|
| `IPINFO_API_TOKEN` | IPInfo API token. Without it the server runs in free Lite mode. | unset (Lite) |
| `IPINFO_CACHE_TTL` | Per-IP cache TTL in seconds. Cached results retain their original `ts_retrieved` timestamp. | `3600` |
| `IPINFO_CACHE_SIZE` | Maximum cache entries before oldest-first eviction. | `4096` |


## License

MIT License — see [LICENSE](LICENSE). Release history in [CHANGELOG.md](CHANGELOG.md).

## Disclaimer

This project is not affiliated with [IPInfo](https://ipinfo.io).
