Skip to main content
Glama
ip2location

IP2Location IP Geolocation MCP Server

Official

IP2Location.io MCP 服务器

这是一个用于 IP2Location.io API 的简单模型上下文协议 (MCP) 服务器实现。它将为任何给定的 IPv4 或 IPv6 地址返回详细的地理位置信息。

功能

  • 全面的地理位置数据:检索广泛的信息,包括国家、地区、城市、纬度、经度、邮政编码、时区等。

  • 网络详情:提供与网络相关的数据,如 ASN、ISP、域名和网络速度。

  • 安全洞察:检测代理信息,包括代理类型和提供商。

  • 简单集成:构建为 FastMCP 工具,可轻松集成到兼容的系统中。

  • 异步:利用 httpx 进行非阻塞异步 API 请求。

要求

此 MCP 服务器支持在没有 API 密钥的情况下进行查询,每天限制为 1,000 次查询。您也可以注册获取免费 API 密钥,每月最多可享受 50,000 次查询。

此设置还使用了 uv,可以通过遵循指南进行安装。

设置

按照以下步骤在 Claude Desktop 中使用此 MCP 服务器:

  1. 将存储库下载到本地。

  2. 设置 uv 包管理器,您可以再次参考指南来完成此操作。

  3. 确保您已安装 Claude Desktop,如果没有,请从此处下载(适用于 Windows 和 MacOS 用户),或按照此指南操作(适用于 Linux 用户)。

  4. 在您选择的编辑器中打开 claude_desktop_config.json,如果您还没有该文件,请按照此指南创建一个。

  5. 将以下内容添加到您的 claude_desktop_config.json 中:

{
  "mcpServers": {
    "ip2locationio": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/ip2locationio/src",
        "run",
        "server.py"
      ],
      "env": {
        "IP2LOCATION_API_KEY": "<YOUR API key HERE>"
      }
    }
  }
}
  1. 请记住将 /path/to/ip2locationio 路径替换为您本地 IP2Location.io MCP 服务器的实际路径。

  2. 要获取您的 API 密钥,只需登录到您的仪表板并从中获取。将上面的 <YOUR API key HERE> 替换为您实际的 API 密钥。

  3. 保存更改后重启 Claude Desktop,您应该会在 Connectors 菜单中看到它。

使用方法

只需在 Claude Desktop 的聊天中输入关于 IP 的查询即可。以下是一些查询示例:

  • (IP) 的位置在哪里?

  • (IP) 位于哪里?

  • (IP) 的坐标是多少?

例如,以下是 IP 8.8.8.8 的结果:

IP 8.8.8.8 的输出

在 Claude Desktop 中,模型将根据 IP2Location.io MCP 服务器返回的结果自动生成输出。

您还可以利用 IP2Location.io 批量 IP 地理位置 API 来查询多个 IP 地址。只需输入所有 IP 地址,并在每个 IP 地址之间用空格隔开。例如 8.8.8.8 8.8.6.6。

[!NOTE] IP2Location.io 批量 IP 地理位置 API 需要付费计划才能使用。

环境变量

IP2LOCATION_API_KEY

IP2Location.io API 密钥,允许您每月查询多达 50,000 次并获取更多 IP 地址详情。您可以注册获取免费 API 密钥,或订阅计划以享受更多权益。

工具

get_geolocation

描述 获取给定 IP 地址或一批 IP 地址的地理位置。它帮助用户检索详细信息,例如任何 IPv4 或 IPv6 地址的国家、地区、城市、纬度、经度、邮政编码、时区、ASN 和代理信息。当检测到多个 IP 时,它会自动将请求路由到 IP2Location.io 批量 API 以进行高效处理。

参数

  • ip (str):要分析的 IP 地址(IPv4 或 IPv6)。您可以通过传递以逗号、空格或换行符分隔的单个字符串来一次查询多个 IP(例如:"1.1.1.1, 2.2.2.2")。

返回 包含地理位置数据的 JSON 字符串。如果查询了多个 IP,它将返回一个 JSON 对象,其中每个键都是一个 IP 地址,映射到其各自的数据。根据您的 API 计划,结果可能包含以下字段:

  • 位置与地理:国家、地区、行政区、城市、邮政编码、纬度和经度、时区。

  • 网络与连接:ASN(自治系统编号)、ISP(互联网服务提供商)、域名、网络速度、IDD 代码、区号、地址类型、使用类型。

  • 移动信息:MNC(移动网络代码)、MCC(移动国家代码)、移动品牌。

  • 货币与语言:货币代码、货币名称、货币符号、语言代码、语言名称。

  • 代理与安全:代理类型、最后可见时间、威胁级别/类型、代理提供商、欺诈评分。

  • 其他:IAB 分类、天气、海拔、人口等。

如果单个 IP 请求失败或 IP 无效,该工具将返回一个字符串形式的错误消息。对于批量请求,任何失败的单个 IP 将返回一个映射到该特定 IP 地址的错误对象,而不会导致整个批次失败。

许可证

请参阅 LICENSE 文件。

Available Tools

1 tool
get_geolocationA

Fetch geolocation for the given IP address(es).

CRITICAL INSTRUCTION FOR AI AGENT: If the user provides multiple IP addresses in their prompt, DO NOT call this tool multiple times sequentially. You MUST batch all IP addresses together into a single comma-separated string and make exactly ONE tool call.

It helps users to retrieve detailed information such as country, region, city, latitude, longitude, ZIP code, time zone, ASN, and proxy information for any IPv4 or IPv6 address.

Args: ip: The IP address to analyze (IPv4 or IPv6). For multiple IPs, you MUST combine them into a single string separated by commas (e.g., "1.1.1.1, 2.2.2.2").

Returns: A JSON string result includes:

Location & Geography:
Country, region, district, city, ZIP code, latitude & longitude, time zone.

Network & Connectivity
ASN (Autonomous System Number), ISP (Internet Service Provider), domain, net speed, IDD code, area code, address type, usage type.

Mobile Information
MNC (Mobile Network Code), MCC (Mobile Country Code), Mobile Brand.

Currency & Language
currency code, currency name, currency symbol, language code, language name.

Proxy & Security
proxy type, last seen, threat level/type, proxy provider, fraud score.

Others
IAB category, weather, elevation, population and more.

Note that some information may only available in paid plan. Learn more on this in https://www.ip2location.io/pricing.
ParametersJSON Schema
NameRequiredDescriptionDefault
ipYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Describes the return structure in detail and notes that some information may be limited to paid plans. No annotations exist, so the description carries the burden; it discloses the tool is a read operation but lacks info on error handling or rate limits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well-structured with headings, critical instruction upfront, and detailed return breakdown. Slightly verbose but each section adds clear value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given one required parameter, no annotations, and presence of an output schema, the description provides extensive return field details and notes on plan limitations, making it complete for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema provides no description for the 'ip' parameter (0% coverage), but the description compensates fully by explaining it accepts IPv4/IPv6 and can be comma-separated for multiple IPs.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states the tool fetches geolocation for IP addresses, specifying the range of detailed data returned. No sibling tools exist, but it distinguishes itself as a geolocation lookup tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit critical instruction to batch multiple IPs into a single comma-separated string to avoid multiple calls. Does not mention when not to use or alternatives, but this is adequate given the single-purpose tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev1.0.1
    • Changedget_geolocation1 field changed
      • changedOutput schema / (root)
        Previous value: -nullNew value: +{
        +  "properties": {
        +    "result": {
        +      "anyOf": [
        +        {
        +          "additionalProperties": true,
        +          "type": "object"
        +        },
        +        {
        +          "type": "string"
        +        }
        +      ],
        +      "title": "Result"
        +    }
        +  },
        +  "required": [
        +    "result"
        +  ],
        +  "title": "get_geolocationOutput",
        +  "type": "object"
        +}
  2. 1 tool update
    • First observedget_geolocation

TDQS

A4.6/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of confusion or overlap. The tool's purpose is clearly defined and distinct.

Naming Consistency5/5

The single tool 'get_geolocation' follows a clear verb_noun pattern, which is consistent and predictable.

Tool Count4/5

While the server has only one tool, it is sufficient for its focused purpose of IP geolocation. The count is slightly below the typical 3-15 range but still reasonable.

Completeness5/5

The tool provides comprehensive geolocation data covering location, network, security, and more. No obvious gaps exist for a read-only service of this nature.

Maintenance

ActivitySlowing
ResponsivenessUnresponsive

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    An MCP server that provides IP geolocation services using MaxMind's GeoIP2 databases, allowing users to retrieve geographical information for single or multiple IP addresses including country, city, coordinates, and ASN details.
    GPL 3.0
  • A
    license
    B
    quality
    D
    maintenance
    An MCP server that provides access to the Netdetective API for querying information about IP addresses. It enables users to retrieve metadata for a specified IP address or the connecting client's default IP address.
    1
    MIT
  • A
    license
    Not graded
    quality
    F
    maintenance
    MCP server for IP geolocation lookups using ipinfo.io, with single, own, and batch queries.
    1
    MIT