DNS查询服务

一个提供REST API接口的DNS查询服务,支持正向和反向DNS查询,可配置DNS服务器选择。

  • by wgr1984
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 wgr1984/ns-lookup-mcp

使用说明

NS查找MCP服务器

一个简单的MCP(模型上下文协议)服务器,它公开了nslookup命令功能。此服务提供了一个REST API接口来执行DNS查找,从而可以轻松地将DNS解析功能集成到应用程序中。

特性

  • 通过REST API公开nslookup命令功能
  • 简单而专注的微服务
  • 使用uv和pyproject.toml的现代Python工具
  • 支持正向和反向DNS查找
  • 可配置的DNS服务器选择
  • 简洁明了的输出格式

需求

  • Python 3.9或更高版本
  • uv(Python包管理器)

安装

  1. 克隆存储库
  2. 使用uv安装依赖项:
uv pip install -e .

用法

启动服务器:

uv run ns-lookup-mcp

调试模式:

npx @modelcontextprotocol/inspector uv run ns-lookup-mcp 

MCP接口

工具

服务器公开了以下工具:

{
  "name": "nslookup",
  "description": "Performs DNS lookups using the nslookup command. Supports both forward and reverse DNS lookups.",
  "inputSchema": {
    "type": "object",
    "properties": {
      "hostname": {
        "type": "string",
        "description": "Domain name or IP address to look up"
      },
      "server": {
        "type": "string",
        "description": "Optional DNS server to use for the lookup"
      }
    },
    "required": ["hostname"]
  }
}

鼓励

服务器提供以下提示:

{
  "name": "nslookup",
  "description": "Perform a DNS lookup using nslookup",
  "arguments": [
    {
      "name": "hostname",
      "description": "Domain name or IP address to look up",
      "required": true
    },
    {
      "name": "server",
      "description": "Optional DNS server to use",
      "required": false
    }
  ]
}

MCP客户端配置

要将此服务器与MCP客户端一起使用,请将以下配置添加到客户端的设置中:

{
  "mcpServers": {
    "nslookup": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "[workspace]/ns-lookup-mcp",
        "ns-lookup-mcp"
      ]
    }
  }
}

替换 [workspace] 使用工作区目录的实际路径。

输出示例

服务器以简洁明了的格式返回DNS查找结果:

DNS:    192.168.1.1
Name:   example.com
Address: 93.184.216.34

常见DNS服务器

  • 谷歌DNS: 8.8.8.8
  • Cloudflare DNS: 1.1.1.1
  • OpenDNS: 208.67.222.222

许可证

麻省理工学院