Skip to main content
Glama

BotDuaChuot Host MCP

一个极简 MCP 服务器,让 ChatGPT 可以直接操作你的机器,作用范围限定在 HOST_WORKSPACE_DIR 内。

本仓库有两个主要功能:

  1. 在主机上读取、写入、搜索文件并运行命令。

  2. 通过 duachuot_knowledge 提供操作指南以及机器上已安装工具的真实清单。

目录结构

app/
├── host/                 # File, command, policy and tool-inventory logic
├── geo/                  # Geo Engine (convert, geodesic, exif, reverse, timezone)
├── ops/                  # OPSEC gate
├── platform/             # OS/distro/arch/shell + tool resolution
├── tools/                # MCP adapters: health, host, knowledge, geo, probes, ops
├── config.py
├── mcp_server.py
└── main.py

knowledge/
├── WORKING_GUIDE.md
├── HOST_ENVIRONMENT.md
├── TOOL_CATALOG.json
├── GEO_PLAYBOOK.md
├── FORENSICS_PLAYBOOK.md
└── OSINT_PLAYBOOK.md

skills/
├── ctf-geo/
├── ctf-forensics-plus/
├── ctf-osint-plus/
└── ctf-stego-plus/

datasets/
└── landmarks.json

resources/
└── RESOURCE_MAP.json (generated from the host ctf-tools repo)
└── landmarks.json

install.sh
scripts/
├── install_basic.sh
├── install_cli.sh
├── uninstall_cli.sh
├── restart_server_only.sh
├── start_tunnel_server.sh
├── dev.sh
├── install_datasets.py
└── test.sh

Related MCP server: local-drive-mcp

安装

1. 一行命令安装(推荐)

curl -fsSL https://raw.githubusercontent.com/cornhub69-x/botduachuot_mcp/main/install.sh | bash

默认情况下,脚本会将 main 分支克隆到 ~/.botduachuot_mcp,创建 .venv,安装依赖,以 600 权限创建 .env,并将 CLI 链接到 ~/.local/bin/duachuot。重新运行同一命令会通过快进方式更新安装;如果工作树中有未提交的文件,安装程序会停止,以避免覆盖用户数据。

可以通过环境变量进行自定义:

curl -fsSL https://raw.githubusercontent.com/cornhub69-x/botduachuot_mcp/main/install.sh | \
  DUACHUOT_INSTALL_DIR="$HOME/apps/botduachuot_mcp" \
  DUACHUOT_BIN_DIR="$HOME/.local/bin" \
  DUACHUOT_BRANCH=main \
  bash

支持的变量:DUACHUOT_REPO_URL、DUACHUOT_INSTALL_DIR、DUACHUOT_BIN_DIR、DUACHUOT_BRANCH。DUACHUOT_SKIP_PIP_UPGRADE=true 只应在测试环境或已准备好软件包缓存的离线环境中使用。

2. 从本地仓库手动安装

cd botduachuot_mcp
./install.sh

scripts/install_basic.sh 为兼容性而保留,并直接转发到主安装程序。

3. 配置与安装后检查

确保 ~/.local/bin 在你的 PATH 中:

export PATH="$HOME/.local/bin:$PATH"

将此行添加到 ~/.bashrc 或 ~/.zshrc 中以跨会话保留。

在暴露服务之前配置 .env。默认模板要求进行身份验证:

REQUIRE_AUTH=true
GATEWAY_TOKEN=<secret-random-token>
HOST_WORKSPACE_DIR=/home/user

然后验证:

duachuot version
duachuot config validate
duachuot doctor

通过 Cloudflare Tunnel 运行

./run_mcp_tunnel.sh
./run_mcp_tunnel.sh --status
./run_mcp_tunnel.sh --url
./run_mcp_tunnel.sh --stop

连接器 URL 如下所示:

https://<random>.trycloudflare.com/mcp

Streamable HTTP 以无状态方式配置并直接返回 JSON。每个 ChatGPT 请求都是独立工作的:不需要 mcp-session-id,常规工具调用也不会保持 SSE 流。

MCP_JSON_RESPONSE=true
MCP_STATELESS_HTTP=true

REST API

REST API 与 MCP 服务器共享主机服务,并运行在同一服务器/隧道上。基础路径:

/api/v1

OpenAPI 文档:

/api/v1/openapi.json

主要端点:

方法

端点

用途

GET

/api/v1/health

服务器状态

GET

/api/v1/capabilities

工具、工作区与限制

GET

/api/v1/files

列出目录

GET

/api/v1/files/content

读取文本文件

PUT

/api/v1/files/content

创建或覆盖文件

PATCH

/api/v1/files/content

替换文件中的文本

POST

/api/v1/files/append

向文件追加内容

POST

/api/v1/directories

创建目录

GET

/api/v1/search

在工作区中搜索文本

POST

/api/v1/commands/check

检查命令

POST

/api/v1/commands/run

在主机上运行命令

GET

/api/v1/knowledge

读取指南与工具清单

当 REQUIRE_AUTH=true 时,使用以下任一请求头:

Authorization: Bearer <GATEWAY_TOKEN>
X-Gateway-Token: <GATEWAY_TOKEN>

示例:

BASE_URL="https://<tunnel>.trycloudflare.com"
TOKEN="<GATEWAY_TOKEN>"

curl -H "Authorization: Bearer $TOKEN" \
  "$BASE_URL/api/v1/files?path=GitHub"

curl -X PUT \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"path":"Workspace/demo.txt","content":"hello REST\n"}' \
  "$BASE_URL/api/v1/files/content"

curl -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"command":"git status --short","cwd":"GitHub/botduachuot_mcp"}' \
  "$BASE_URL/api/v1/commands/run"

MCP 工具

health_check
get_capabilities
duachuot_list_directory
duachuot_read_file
duachuot_write_file
duachuot_replace_in_file
duachuot_append_file
duachuot_make_directory
duachuot_search_text
duachuot_check_command
duachuot_run_command
duachuot_knowledge

duachuot_run_command 没有 approval="approved" 参数。策略完全由服务器端决定。

调查工具(取证 + OSINT + 地理)

BotDuaChuot 增加了 21 个专用调查工具,完全离线且确定性执行:

# Geo Engine (offline, no network required)
duachuot_geo_extract         # EXIF GPS, exiftool/exiv2 cross-check, DOP/HPE, timezone, landmarks
duachuot_geo_scan            # scan arbitrary text/logs/SRT/NMEA/MGRS/UTM for coordinates
duachuot_coord_convert       # DMS/decimal/UTM/MGRS + datum transform (WGS84/ED50/NAD27)
duachuot_geo_calc            # geodesic distance/bearing + uncertainty from DOP/HPE
duachuot_geo_reverse         # offline reverse geocoding (landmarks + country resolution)
duachuot_geo_verify          # conclude only with >= 2 independent facts; fewer -> BLOCKER
duachuot_geo_landmark_check  # radius check around a landmark
duachuot_timezone_at         # offline timezone/UTC offset from coordinates

# Probes
duachuot_media_probe         # file + exiftool JSON + ffprobe
duachuot_pcap_probe          # conversations/endpoints/DNS + GPS hints (NMEA, Wi-Fi probes)
duachuot_disk_probe          # fsstat + fls
duachuot_mem_probe           # Volatility 3 (info/pslist)
duachuot_stego_probe         # binwalk + steghide, WAV LSB detection, LSB/MP3 extraction
duachuot_ocr_probe           # tesseract + QR (zxing-cpp)
duachuot_win_probe           # SAM/SYSTEM hives, LNK, prefetch (pure-Python, Linux/Windows)

# OPSEC + platform
duachuot_ops_check           # blocks telemetry / attack tools / discovery while ctf-live / flags in commands
duachuot_ops_jitter          # human-like delay between network queries
duachuot_ops_redact          # redact secret/flag before writing logs
duachuot_platform            # probe OS/arch/distro/shell + tool availability (native/WSL/missing)
duachuot_plan                # generate an investigation plan by artifact type
duachuot_resource_lookup     # resolve a managed ctf-tools resource from RESOURCE_MAP.json

资源注册表:resources/RESOURCE_MAP.json 由 scripts/generate_resource_map.py 从主机上的 ctf-tools 仓库生成(技能、脚本、工具、bin 条目、笔记)。查询返回路径 + 调用模板 + 可用性;缺失的资源是 BLOCKER,绝不会静默回退。

完整剧本:knowledge/GEO_PLAYBOOK.md、knowledge/FORENSICS_PLAYBOOK.md、knowledge/OSINT_PLAYBOOK.md。捆绑技能:skills/ctf-geo、skills/ctf-forensics-plus、skills/ctf-osint-plus、skills/ctf-stego-plus。

OPSEC(CTF 期间强制要求)

  • 默认 ctf-live:不进行公开来源查询(sherlock/maigret/whois/dnsrecon/搜索引擎),不对目标范围使用自动化攻击工具,不自动提交 flag——始终通过人工操作。

  • investigation 模式(OSINT_MODE=true)开启 OSINT 查询,范围限定为操作员指定的内容。

  • 网络查询之间:等待 duachuot_ops_jitter()(800–3000 毫秒)。

  • 每个坐标结论需要 >= 2 个独立事实(通过 duachuot_geo_verify 验证)。

duachuot_knowledge

duachuot_knowledge(section="overview")
duachuot_knowledge(section="guide")
duachuot_knowledge(section="tools", query="python", include_versions=true)
duachuot_knowledge(section="search", query="docker")

此工具读取 knowledge/ 中的文档,并将 TOOL_CATALOG.json 与机器实际的 PATH 进行匹配。

测试

./scripts/test.sh
./scripts/quality_gate.sh
./scripts/manual_test_installer.sh

manual_test_installer.sh 使用临时仓库和 /tmp 中的 HOME;它绝不会启动、停止或重启真实的 Cloudflare tunnel。

关键配置

HOST_WORKSPACE_DIR=/home/light
HOST_RESTRICT_TO_WORKSPACE=true
HOST_COMMAND_POLICY=guarded
MAX_TIMEOUT_SECONDS=60
MAX_OUTPUT_BYTES=500000
REQUIRE_AUTH=true
GATEWAY_TOKEN=<secret>

guarded 只是针对明显破坏性操作的保护层,并非沙箱。MCP 服务器以启动进程的用户的权限运行。

另见:docs/ARCHITECTURE.md 和 SECURITY.md。

duachuot CLI

仓库附带一个统一 CLI,用于操作桥接/隧道并调用 REST API,无需手写 curl。

安装可编辑入口点:

.venv/bin/python -m pip install -e . --no-deps

两种方式均可运行:

./bin/duachuot --help
.venv/bin/duachuot --help

本地操作组:

duachuot start
duachuot status
duachuot url
duachuot server restart   # restart the bridge only, keep the tunnel URL
duachuot restart --yes    # restart the tunnel too, URL may change
duachuot stop

REST API 组:

duachuot health
duachuot --public health
duachuot capabilities --tools
duachuot fs ls GitHub
duachuot fs cat GitHub/project/README.md --lines 1:40
duachuot fs write GitHub/demo.txt --text "hello"
printf 'next\n' | duachuot fs append GitHub/demo.txt --stdin
duachuot fs search FastMCP --path GitHub/botduachuot_mcp
duachuot cmd check 'git status --short'
duachuot cmd run 'git status --short' --cwd GitHub/botduachuot_mcp
duachuot knowledge tools --query python --versions

操作支持组:

duachuot logs server -n 100
duachuot logs follow server
duachuot config show
duachuot config validate
duachuot doctor
duachuot completion bash

每个命令都支持 --json。全局选项可以放在子命令之前或之后:

duachuot --public health --json
duachuot health --public --json

默认情况下,CLI 调用 http://127.0.0.1:<MCP_PORT> 上的本地 REST 端点。使用 --public 从 logs/tunnel_url.txt 获取当前 URL,或使用 --base-url 指向其他端点。

主要退出码:

0  success
1  operation failed
2  invalid arguments
3  cannot reach the server
4  authentication failed
5  blocked by policy
6  resource not found
7  timeout
8  conflict

对于 duachuot cmd run,当服务器在请求层面成功执行命令时,CLI 退出码会镜像该命令的真实退出码。

完整设计:docs/CLI_DESIGN_PLAN.md。

其他 CLI 文档:docs/CLI_MANUAL_TEST_PLAN.md 和 docs/CLI_IMPLEMENTATION_REPORT.md。

运维与恢复

统一质量门禁:

./scripts/quality_gate.sh
./scripts/quality_gate.sh --runtime
./scripts/quality_gate.sh --full

严格诊断与配置:

duachuot doctor --local-only
duachuot doctor --strict
duachuot config validate --strict

收集诊断信息(敏感配置已脱敏):

./scripts/collect_diagnostics.sh

安装、仅桥接重启(保留隧道)、恢复、回滚以及生产检查清单详见 docs/OPERATIONS_RUNBOOK.md。

架构、安全与发布

  • 运行时架构与边界:docs/ARCHITECTURE.md

  • 安全模型与加固:SECURITY.md

  • 运维、恢复与回滚:docs/OPERATIONS_RUNBOOK.md

  • 发布检查清单:docs/RELEASE_CHECKLIST.md

GitHub Actions 在推送和拉取请求时运行质量门禁;Dependabot 跟踪 Python 和 GitHub Actions 依赖。

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    MCP server enabling ChatGPT to interact with local filesystem via controlled file operations like read, write, edit, and search, with configurable guardrails for safety.
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Local MCP server enabling Codex and ChatGPT to read/write files, execute commands, manage processes, use Git, and inspect images on the user's machine with full privileges.
    Apache 2.0