返回市场
whois-mcp

whois-mcp

作者:dadepo2 星标更新:2025-11-17

项目介绍

whois-mcp

一个模型上下文协议(MCP)服务器,通过WHOIS和RIPE数据库查询为大型语言模型提供网络信息查找工具。

功能

可用工具

  • whois_query - 查询WHOIS服务器以获取域名、IP地址和ASN信息
  • expand_as_set - 递归扩展AS-SET为具体的ASN列表
  • validate_route_object - 检查IRR路由对象是否存在
  • contact_card - 获取滥用、管理员和技术联系人信息

区域互联网注册机构(RIR)支持

此MCP服务器支持所有五个区域互联网注册机构(RIR),具有不同的工具可用性:

工具RIPE NCCARINAPNICAfriNICLACNIC
WHOIS查询
AS-SET扩展
路由验证
联系卡

图例:

  • ✅ 完全支持通过REST/RDAP API
  • ➖ 不可用(无公开API;使用 {rir}_whois_query 并解析输出代替)

RIR覆盖范围:

  • RIPE NCC : 欧洲、中东、中亚
  • ARIN : 北美
  • APNIC : 亚太地区
  • AfriNIC : 非洲
  • LACNIC : 拉丁美洲及加勒比海地区

使用方法

此MCP服务器支持两种传输模式:

  • 标准输入输出模式(推荐用于Claude Desktop和Claude Code CLI)
  • HTTP服务器模式(适用于基于Web的客户端和远程访问)

与Claude Desktop一起使用

在您的Claude Desktop配置文件中添加:

位置:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

配置:

{
  "mcpServers": {
    "whois-mcp": {
      "command": "/path/to/bin/uvx",
      "args": ["--from", "git+https://github.com/dadepo/whois-mcp.git", "whois-mcp"]
    }
  }
}

与Claude Code CLI一起使用

使用CLI添加MCP服务器:


claude mcp add --transport stdio whois-mcp -- uvx --from git+https://github.com/dadepo/whois-mcp.git whois-mcp

# 验证是否已添加
claude mcp list

# 启动Claude Code
claude

HTTP服务器模式

对于基于Web的MCP客户端或远程访问:

启动服务器:


uvx --from git+https://github.com/dadepo/whois-mcp.git whois-mcp-server

# 自定义主机/端口
HTTP_HOST=0.0.0.0 HTTP_PORT=9000 uvx --from git+https://github.com/dadepo/whois-mcp.git whois-mcp-server

服务器默认将在 http://127.0.0.1:8000/mcp 上可用。

添加到Claude Code(HTTP):

claude mcp add --transport http whois-mcp-http http://127.0.0.1:8000/mcp

添加到Claude Desktop(HTTP):

{
  "mcpServers": {
    "whois-mcp-http": {
      "url": "http://127.0.0.1:8000/mcp"
    }
  }
}

工具使用示例

查询网络信息

“谁拥有8.8.8.8?”
→ 使用whois_query检索注册详情

扩展AS-SET

“AS-HETZNER中的ASNs有哪些?”
→ 使用expand_as_set列出成员ASNs

验证路由对象

“是否有由AS61417发起的185.1.1.0/24路由对象?”
→ 使用validate_route_object检查IRR数据库

获取联系信息

“我应该联系谁关于来自AS15169的滥用问题?”
→ 使用contact_card检索联系详情

配置

环境变量(可选):

# 启用/禁用RIR支持(所有默认为true)
SUPPORT_RIPE=true      # RIPE NCC(欧洲/中东/中亚)
SUPPORT_ARIN=true      # ARIN(北美)
SUPPORT_APNIC=true     # APNIC(亚太地区)
SUPPORT_AFRINIC=true   # AfriNIC(非洲)
SUPPORT_LACNIC=true    # LACNIC(拉丁美洲及加勒比海地区)

# 通用配置
HTTP_TIMEOUT_SECONDS=10
WHOIS_CONNECT_TIMEOUT_SECONDS=5
WHOIS_READ_TIMEOUT_SECONDS=5
CACHE_TTL_SECONDS=60
CACHE_MAX_ITEMS=512

# 自定义User-Agent字符串
USER_AGENT="whois-mcp/1.0"

# HTTP服务器配置(仅用于whois-mcp-server命令)
HTTP_HOST=127.0.0.1
HTTP_PORT=8000

RIR支持控制

每个RIR都可以单独启用或禁用使用环境变量。所有RIR端点都是硬编码以确保可靠性:

  • RIPE NCC: whois.ripe.net, https://rest.db.ripe.net
  • ARIN: whois.arin.net, https://whois.arin.net/rest
  • APNIC: whois.apnic.net, https://rdap.apnic.net
  • AfriNIC: whois.afrinic.net, https://rdap.afrinic.net/rdap
  • LACNIC: whois.lacnic.net, https://rdap.lacnic.net/rdap

设置任何 SUPPORT_{RIR}=false 来禁用特定的RIR。工具前面会加上RIR名称(例如,ripe_whois_queryarin_whois_queryapnic_contact_card)。

开发

本地设置

# 克隆仓库
git clone https://github.com/dadepo/whois-mcp.git
cd whois-mcp

# 安装依赖
uv sync

# 在标准输入输出模式下运行
uv run whois-mcp

# 运行HTTP服务器模式
uv run whois-mcp-server

# 运行测试
uv run pytest

许可证

本项目根据MIT许可证发布 - 查看LICENSE文件了解详情。