命令行工具转MCP服务器

MCP-Ables是一个将命令行工具转换为AI可调用的MCP服务器的工具,通过简单的YAML配置即可实现,适用于安全扫描、DevOps、网络诊断等多种场景。

  • by mfakbar127
  • Python
  • 本地部署
  • 4 星标
  • 更新于
在 GitHub 查看 mfakbar127/MCP-Ables

使用说明

MCP-Able(此处“Ables”可能为拼写错误或特定语境下的用词,但按常规理解翻译为“能够”或保持原样,若“Ables”有特定含义,请根据实际情况调整)

将任何shell命令转换为MCP服务器

为什么非要为每种需求编写长长的MCP服务器代码,当你可以直接使用MCP-Ables时?

什么是MCP-Ables?

MCP-Ables 桥接了命令行工具与 Claude Code 等 AI 代理之间的鸿沟。只需编写一个描述您 shell 命令的微型 YAML 文件,MCP-Ables 就会自动生成一个 MCP(模型上下文协议)服务器,供 AI 代理调用。

无需Python编码。无需复杂设置。只需YAML → MCP → 可被AI调用的工具。

快速入门

先决条件

  • Python 3.11+(或“Python 3.11及以上版本”)
  • 您想要暴露的命令行工具(例如。, nuclei, nmap, kubectl 等

安装

git clone https://github.com/mfakbar127/MCP-Ables.git
cd MCP-Ables
pip install -r requirements.txt

使用方法

  1. 创建一个YAML文件来描述你的工具(参见以下示例)

  2. 使用文件或目录运行 MCP-Ables:

    # Single file
    python mcpables-main.py examples/nuclei.yaml
    
    # Directory (scans recursively for .yaml/.yml files)
    python mcpables-main.py examples/
    
  3. MCP服务器“mcpables”现已启动,所有工具均已就绪!

Yaml 示例 - 简单回显

示例/工具/echo.yaml:

name: echo_message
description: Echo a message to stdout (simple test tool)

run:
  kind: shell
  cmd: "echo {{message}}"

args:
  message:
    type: string
    description: "Message to echo"
    required: true

运行它:

python mcpables-main.py examples/tools/echo.yaml

可用的MCP工具

工具名称 描述 类别 位置
cloudlist 枚举跨云提供商的资产(ProjectDiscovery) 安全 工具/安全/策略定义/云列表.yaml
subfinder 被动子域名枚举(ProjectDiscovery) 安全 工具/安全/PD/subfinder.yaml
naabu 快速扫描主机端口(ProjectDiscovery) 安全 工具/安全/pd/naabu.yaml
asnmap ASN、域名、IP和组织网络范围查询(ProjectDiscovery) 安全 工具/安全/项目目录(pd)/ASN映射配置文件(asnmap.yaml)
mapcidr 用于大规模扫描的CIDR/IP处理和切片(ProjectDiscovery) 安全 工具/安全/策略定义/映射CIDR配置文件(mapcidr.yaml)
黑客工具包 一套攻击性工具(sqlmap, hydra, gobuster, nikto) 安全 工具/安全/黑客工具.yaml

用例

🔐 安全运营(SecOps)氛围

从聊天界面运行安全扫描器来枚举资产、发现漏洞并绘制攻击面地图;您可以运行诸如nmap、nuclei和subfinder等命令。

🎯 黑客风格

从聊天界面触发攻击性工作流程,如SQL注入测试、暴力破解、内容发现和网页扫描;您可以运行诸如sqlmap、hydra、gobuster和nikto等命令。

🚀 DevOps 风格(或氛围)

通过聊天界面控制基础设施,用于部署、集群操作、配置管理和打包;您可以运行如kubectl、terraform、ansible和helm等命令。

🖥️ 系统管理员风格

通过聊天界面管理服务器,包括服务、容器、日志和防火墙规则;您可以运行如systemctl、docker、journalctl和iptables等命令。

🌐 网络运营氛围(或“网络运维风潮”)

运行网络诊断,如连接性测试、路径追踪、DNS查询和域名解析;您可以执行ping、traceroute、dig和whois等命令。

📊 数据氛围/数据感觉

从命令行界面(CLI)处理数据,包括JSON解析、HTTP请求、文本过滤和媒体转换;您可以运行如jq、curl、grep/awk和ffmpeg等命令。

YAML模式(或YAML架构)

见 examples/

单工具格式

name: <tool_name>
description: <brief description for AI agents>

run:
  kind: shell
  cmd: "command {{arg1}} {{arg2}}"

args:
  arg1:
    type: string|int|float|bool
    description: "What this argument does"
    required: true|false
    default: <optional default value>

多功能工具格式

在一个YAML文件中定义多个工具:

tools:
  - name: tool1
    description: First tool description
    run:
      kind: shell
      cmd: "command1 {{arg1}}"
    args:
      arg1:
        type: string
        description: "Argument description"
        required: true

  - name: tool2
    description: Second tool description
    run:
      kind: shell
      cmd: "command2 {{arg2}}"
    args:
      arg2:
        type: int
        description: "Argument description"
        required: false
        default: 10

参数字段

  • 类型数据类型(string, int, float, bool)
  • 描述为AI代理提供易于人类理解的使用说明
  • 所需的;要求的是否必须提供论据(true 或者 false)
  • 默认如果未提供,则为默认值(仅适用于可选参数)

示例

核扫描仪

示例/工具/nuclei.yaml:

name: nuclei_scan
description: Run Nuclei vulnerability scanner against a target URL or IP address

run:
  kind: shell
  cmd: "nuclei -c {{concurrency}} -t {{target}} -t {{template_path}}"

args:
  target:
    type: string
    description: "Target URL or IP address to scan (e.g., https://example.com)"
    required: true

  template_path:
    type: string
    description: "Path to Nuclei templates directory (e.g., ~/nuclei-templates/)"
    required: true

  concurrency:
    type: int
    description: "Number of concurrent requests (1-100)"
    required: false
    default: 10

多功能工具示例

示例/安全工具.yaml:

tools:
  - name: nmap_scan
    description: Run Nmap network scanner against a target
    run:
      kind: shell
      cmd: "nmap {{scan_type}} {{target}}"
    args:
      target:
        type: string
        description: "Target IP or hostname"
        required: true
      scan_type:
        type: string
        description: "Scan type flag (e.g., -sV)"
        required: false
        default: "-sV"

  - name: whois_lookup
    description: Perform WHOIS lookup for a domain
    run:
      kind: shell
      cmd: "whois {{domain}}"
    args:
      domain:
        type: string
        description: "Domain name to lookup"
        required: true

  - name: dig_dns
    description: DNS lookup using dig command
    run:
      kind: shell
      cmd: "dig {{record_type}} {{domain}}"
    args:
      domain:
        type: string
        description: "Domain name to query"
        required: true
      record_type:
        type: string
        description: "DNS record type (A, MX, TXT, etc.)"
        required: false
        default: "A"

运行它:

python mcpables-main.py examples/security-tools.yaml
# Loads 3 tools: nmap_scan, whois_lookup, dig_dns

目录示例

将工具分别组织到不同的文件中:

examples/tools/
├── ping.yaml     (ping_host tool)
├── curl.yaml     (http_request tool)
└── ...

从目录中运行所有工具:

python mcpables-main.py examples/tools/
# Recursively loads all .yaml/.yml files

Claude 桌面集成

将MCP-Ables连接到Claude桌面版,以便AI能直接在聊天中使用您的工具。

配置

  1. 找到Claude桌面配置文件:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. 添加MCP-Ables服务器:

{
  "mcpServers": {
    "mcpables": {
      "command": "python",
      "args": [
        "/absolute/path/to/mcpables-main.py",
        "/absolute/path/to/examples/"
      ]
    }
  }
}
  1. 重启Claude桌面版 - 工具将自动出现

配置示例

单文件(特定氛围):

{
  "mcpServers": {
    "secops": {
      "command": "python",
      "args": ["/path/to/mcpables-main.py", "/path/to/examples/secops-tools.yaml"]
    }
  }
}

目录(所有工具):

{
  "mcpServers": {
    "mcpables-all": {
      "command": "python",
      "args": ["/path/to/mcpables-main.py", "/path/to/examples/"]
    }
  }
}

多种配置(不同氛围):

{
  "mcpServers": {
    "secops": {
      "command": "python",
      "args": ["/path/to/mcpables-main.py", "/path/to/examples/secops-tools.yaml"]
    },
    "devops": {
      "command": "python",
      "args": ["/path/to/mcpables-main.py", "/path/to/examples/devops-tools.yaml"]
    },
    "netops": {
      "command": "python",
      "args": ["/path/to/mcpables-main.py", "/path/to/examples/netops-tools.yaml"]
    }
  }
}

验证连接

重启Claude Desktop后,您可以验证工具是否可用:

  • 输入一条信息询问Claude可用的工具
  • 工具将以类似以下名称出现: nuclei_scan, nmap_scan等。
  • 克劳德现在可以直接执行命令了!

作者

由……创建 穆罕默德·法尼·“拉玛”·阿克巴 linkedin.com/in/mf-akbar/(可译为)领英个人主页:mf-akbar(注:实际翻译时,网址本身通常不直接翻译,而是说明其为领英上的某个个人主页链接,此处为保持格式一致,仅对网址中的用户名部分进行说明性翻译)