MCP服务器IPInfo
这是一个用于IPInfo的MCP服务器版本,它实现了完整的IPInfo OpenAPI规范,具有强类型模型和全面的工具覆盖。
特性
- 完整的OpenAPI规范实现:完全实现IPInfo的OpenAPI规范
- 强型别:所有API响应都使用Pydantic模型进行类型安全
- HTTP传输:支持具有健康端点的流式http传输
- 综合工具:25多种MCP工具,涵盖所有IPInfo API端点
- 内置技能资源:服务a
skill://ipinfo/usage教授LLM最佳工具选择和上下文重用模式的资源
安装
# Using uv (recommended)
uv pip install -e .
# Or with pip
pip install -e .配置
将您的IPInfo API令牌设置为环境变量:
export IPINFO_API_TOKEN=your_token_here运行服务器
作为独立的MCP服务器
# Using uv
uv run mcp-ipinfo
# Or with Python
python -m mcp_ipinfo.server克劳德密码
将此配置添加到您的Claude代码设置中:
{
"mcpServers": {
"ipinfo": {
"command": "/path/to/.local/bin/uv",
"args": [
"--directory",
"/path/to/mcp-server-ipinfo",
"run",
"mcp-ipinfo"
],
"env": {
"IPINFO_API_TOKEN": "your_ipinfo_api_token_here"
}
}
}
}技能资源
该服务器内置了一项技能 skill://ipinfo/usage 该指南指导LLM:
- 工具选择:针对每种意图使用哪种工具(一般查找、VPN检测和WHOIS)
- 上下文重用:在后续问题中携带IP地址
- VPN检测:使用Plus API(
get_plus_ip_info)而不是用于隐私标志的核心API
服务器的 instructions 字段告诉兼容MCP客户端在使用工具之前读取此资源。这也作为独立技能发布在 mpak.dev/技能/@nimblebrainnc/ipinfo.
可用的MCP工具
核心IP信息
get_ip_info(ip?)-获取全面的IP信息get_plus_ip_info(ip)-通过Plus API获取完整的IP智能(包括隐私检测)get_account_info()-获取API帐户限制和功能batch_lookup(ips[])-批量查找多个IPsummarize_ips(ips[])-获取IP列表的摘要统计信息map_ips(ips[])-创建IP位置的可视化地图
公司和承运人
get_company_info(ip)-获取IP的公司详细信息get_carrier_info(ip)-获取移动运营商信息
隐私和安全
get_plus_ip_info(ip)-检测VPN、代理、Tor、中继(通过Plus API)get_residential_proxy_info(ip)-检测住宅代理服务get_abuse_contact(ip)-获取虐待联系信息
网络信息
get_hosted_domains(ip, page?, limit?)-获取IP上的域get_ip_ranges(domain)-获取域的IP范围
WHOIS查询
whois_lookup_by_ip(ip, page?, source?)-WHOIS按IPwhois_lookup_by_domain(domain, page?, source?)-按域名分类的WHOISwhois_lookup_by_asn(asn, page?, source?)-ASN的WHOIS
单现场工具
get_ip_city(ip?)-只得到城市get_ip_country(ip?)-只获取国家代码get_ip_region(ip?)-只获取地区/州get_ip_location(ip?)-获取坐标get_ip_postal(ip?)-只需获取邮政编码get_ip_timezone(ip?)-只获取时区get_ip_hostname(ip?)-只获取主机名get_ip_org(ip?)-只获取组织/ASN
测试
运行测试客户端以验证实现:
python test_client.pyAPI客户端使用情况
您还可以在Python代码中直接使用API客户端:
import asyncio
from mcp_ipinfo.api_client import IPInfoClient
async def main():
async with IPInfoClient() as client:
# Get current IP info
info = await client.get_current_info()
print(f"Current IP: {info.ip}")
print(f"Location: {info.city}, {info.country}")
# Get specific IP info
google = await client.get_info_by_ip("8.8.8.8")
print(f"Google DNS: {google.org}")
# Privacy detection via Plus API
plus_info = await client.get_plus_info("1.1.1.1")
print(f"VPN detected: {plus_info.anonymous.is_vpn}")
print(f"ASN: {plus_info.as_info.asn}")
asyncio.run(main())类型安全
所有模型都使用Pydantic进行强类型化:
from mcp_ipinfo.api_models import (
FullResponse, # Basic IP information
PlusResponse, # Comprehensive IP intelligence (geo, ASN, privacy)
CompanyResponse, # Company information
RangesResponse, # IP ranges for a domain
# ... and many more
)需求
- Python 3.13+
- 意图tp
- fastmcp
- 皮丹提克
- 主控程序
关于
许可证
麻省理工学院
