IP Geolocation Skill
Use this skill to query geographic and ASN information from IP addresses through the mcp-geoip-server MCP service.
This skill is designed for:
- - Single IP lookup
- Multi-IP batch lookup
- Domain-to-IP then geolocation workflow
- Structured result output for quick user reading
MCP Server
- - Name: INLINECODE1
- URL: INLINECODE2
- Transport: Streamable HTTP
VS Code MCP Configuration
Add to .vscode/mcp.json (workspace) or user MCP settings:
CODEBLOCK0
Tools
get_ip_geolocation
Look up geolocation information for one IP.
Input:
| Name | Type | Required | Description |
|---|
| INLINECODE5 | string | Yes | IPv4 or IPv6 address to look up (e.g. 8.8.8.8 or 2001:4860:4860::8888) |
Output fields:
| Field | Description |
|---|
| INLINECODE8 | The queried IP address |
| INLINECODE9 |
Country name |
|
country_code | ISO country code (e.g.
US,
CN) |
|
province | Province or state |
|
city | City name |
|
asn | Autonomous System Number |
|
asn_org | ASN organization name |
Detailed tool schema and protocol notes: API reference
Execution Workflow
- 1. Extract query targets from user input.
- Classify each target as IPv4, IPv6, or domain.
- If target is a domain, resolve to IP first using resolve script.
- Call
get_ip_geolocation for each IP. - Return concise and structured results.
- If multiple IPs are provided, present results in a table for easy comparison.
Input Handling Rules
- - Trim whitespace and punctuation around candidate IPs.
- Keep duplicates out during batch lookup.
- Support both IPv4 and IPv6.
- If input is neither valid IP nor resolvable domain, return a clear validation error.
- For script-based calls, only valid IP literals are sent to remote MCP (invalid inputs are rejected locally).
- Private/reserved IP ranges (for example
127.0.0.1, 10.x.x.x, 192.168.x.x, fc00::/7) must not be sent to external MCP.
Security and Privacy
- - This skill sends queried IP addresses to an external MCP service (
ip.api4claw.com). - The default endpoint uses HTTPS transport to encrypt traffic in transit.
- The script implementation is restricted to a fixed HTTPS endpoint (
https://ip.api4claw.com/mcp) to reduce misuse risk. - Private/internal IPs are blocked in the script implementation to reduce privacy leakage risk.
Output Format
Use this format by default:
| IP | Country | Province/State | City | Country Code | ASN | ASN Org |
|---|
| 8.8.8.8 | United States | - | - | US | 15169 | Google LLC |
If a field is empty, display -.
Error Handling
- - MCP unavailable/timeout: explain temporary service issue and suggest retry.
- Invalid IP format: ask user to confirm/correct the IP.
- Private or reserved IP: explain that local/private addresses are intentionally blocked from external lookup.
- Empty/unknown location fields: keep response transparent and do not fabricate values.
- Encoding anomalies (for example garbled country text): include
country_code and raw value. - Session timeout/invalid session ID: re-run MCP
initialize to get a new Mcp-Session-Id, then retry the failed tool call once.
Domain-to-IP Flow
When user asks for a domain location (for example example.com):
- 1. Resolve A/AAAA records with resolve script.
- Query each resolved IP using
get_ip_geolocation. - Summarize domain-level findings and list per-IP differences.
Implementation Scripts
- - invoke MCP lookup: includes
initialize before calls and auto re-initialize on session expiration. - resolve domain: resolves domain to unique A/AAAA addresses.
Example: Single IP
User: INLINECODE31
Call:
INLINECODE32
Response (example):
CODEBLOCK1
Example: Batch IPs
User: INLINECODE33
Execution:
- 1. Call
get_ip_geolocation with INLINECODE35 - Call
get_ip_geolocation with INLINECODE37 - Return merged table with both records
Success Criteria
- - Every valid input IP returns one result row.
- Invalid targets are explicitly marked with reason.
- No inferred or fabricated geographic values.
- Response is readable for both Chinese and English users.
IP 地理定位技能
使用此技能通过 mcp-geoip-server MCP 服务查询 IP 地址的地理和 ASN 信息。
此技能适用于:
- - 单个 IP 查询
- 多个 IP 批量查询
- 域名转 IP 后再进行地理定位的工作流程
- 结构化结果输出,便于用户快速阅读
MCP 服务器
- - 名称:mcp-geoip-server
- URL:https://ip.api4claw.com/mcp
- 传输方式:可流式 HTTP
VS Code MCP 配置
添加到 .vscode/mcp.json(工作区)或用户 MCP 设置:
json
{
servers: {
mcp-geoip-server: {
type: http,
url: https://ip.api4claw.com/mcp
}
}
}
工具
getipgeolocation
查询一个 IP 的地理位置信息。
输入:
| 名称 | 类型 | 必填 | 描述 |
|---|
| ip_address | 字符串 | 是 | 要查询的 IPv4 或 IPv6 地址(例如 8.8.8.8 或 2001:4860:4860::8888) |
输出字段:
国家名称 |
| country_code | ISO 国家代码(例如 US、CN) |
| province | 省或州 |
| city | 城市名称 |
| asn | 自治系统编号 |
| asn_org | ASN 组织名称 |
详细的工具架构和协议说明:API 参考
执行工作流程
- 1. 从用户输入中提取查询目标。
- 将每个目标分类为 IPv4、IPv6 或域名。
- 如果目标是域名,首先使用 解析脚本 解析为 IP。
- 对每个 IP 调用 getip_geolocation。
- 返回简洁且结构化的结果。
- 如果提供了多个 IP,以表格形式呈现结果以便于比较。
输入处理规则
- - 去除候选 IP 周围的空白和标点符号。
- 批量查询时去除重复项。
- 同时支持 IPv4 和 IPv6。
- 如果输入既不是有效 IP 也不是可解析的域名,返回明确的验证错误。
- 对于基于脚本的调用,只有有效的 IP 字面量会发送到远程 MCP(无效输入在本地拒绝)。
- 私有/保留 IP 范围(例如 127.0.0.1、10.x.x.x、192.168.x.x、fc00::/7)不得发送到外部 MCP。
安全与隐私
- - 此技能将查询的 IP 地址发送到外部 MCP 服务(ip.api4claw.com)。
- 默认端点使用 HTTPS 传输来加密传输中的流量。
- 脚本实现限制为固定的 HTTPS 端点(https://ip.api4claw.com/mcp)以减少滥用风险。
- 脚本实现中阻止了私有/内部 IP,以减少隐私泄露风险。
输出格式
默认使用此格式:
| IP | 国家 | 省/州 | 城市 | 国家代码 | ASN | ASN 组织 |
|---|
| 8.8.8.8 | 美国 | - | - | US | 15169 | Google LLC |
如果某个字段为空,显示 -。
错误处理
- - MCP 不可用/超时:说明临时服务问题并建议重试。
- 无效 IP 格式:要求用户确认/更正 IP。
- 私有或保留 IP:说明本地/私有地址被有意阻止进行外部查询。
- 空/未知位置字段:保持响应透明,不虚构值。
- 编码异常(例如乱码的国家文本):包含 country_code 和原始值。
- 会话超时/无效会话 ID:重新运行 MCP initialize 以获取新的 Mcp-Session-Id,然后重试失败的工具调用一次。
域名转 IP 流程
当用户询问域名位置时(例如 example.com):
- 1. 使用 解析脚本 解析 A/AAAA 记录。
- 使用 getip_geolocation 查询每个解析后的 IP。
- 总结域名级别的发现结果并列出每个 IP 的差异。
实现脚本
- - 调用 MCP 查询:在调用前包含 initialize,并在会话过期时自动重新初始化。
- 解析域名:将域名解析为唯一的 A/AAAA 地址。
示例:单个 IP
用户:8.8.8.8 在哪里?
调用:
getipgeolocation({ ip_address: 8.8.8.8 })
响应(示例):
json
{
ip: 8.8.8.8,
country: 美国,
country_code: US,
province: ,
city: ,
asn: 15169,
asn_org: Google LLC
}
示例:批量 IP
用户:帮我查 8.8.8.8 和 1.1.1.1 的地理位置
执行:
- 1. 使用 8.8.8.8 调用 getipgeolocation
- 使用 1.1.1.1 调用 getipgeolocation
- 返回包含两条记录的合并表格
成功标准
- - 每个有效的输入 IP 返回一行结果。
- 无效目标明确标注原因。
- 不推断或虚构地理值。
- 响应对中英文用户均可读。