Skip to main content
Glama
seanWeb3dDev

TdxClaw-compatible MCP Server

by seanWeb3dDev
README.md
# TdxClaw-compatible MCP Server

独立的本地 MCP Server,复刻 TdxClaw (openclaw) 的数据请求能力。无需安装 TdxClaw 即可让你的 agent 通过 MCP 协议调用网页抓取、搜索和 HTTP 请求工具。

## 提供的工具

| 工具 | 说明 |
|------|------|
| `web_fetch` | 抓取网页内容,自动转换为 Markdown 或纯文本,带 SSRF 防护 |
| `web_search` | 使用 DuckDuckGo 搜索网页,无需 API Key |
| `http_request` | 通用 HTTP 请求工具,支持 GET/POST/PUT/PATCH/DELETE,自定义 Headers 和 Body |

## 快速开始

### 前置条件

- [uv](https://docs.astral.sh/uv/)(TdxClaw 自带:`C:\TdxClaw\resources\bin\uv.exe`)
- 或 Python 3.10+

### 方式一:使用启动脚本(推荐)

```cmd
start.cmd
```

首次运行会自动创建虚拟环境并安装依赖。

### 方式二:手动运行

```bash
cd tdx-mcp-server

# 创建虚拟环境并安装依赖
uv venv
uv pip install "mcp[cli]>=1.0.0" "httpx>=0.27.0" "beautifulsoup4>=4.12.0" "markdownify>=0.13.0" "duckduckgo-search>=6.0.0"

# 启动 stdio 模式(大多数 MCP 客户端)
.venv\Scripts\python.exe server.py

# 或启动 HTTP 模式(openclaw 风格的 agent)
.venv\Scripts\python.exe server.py --http --port 31868
```

## 连接你的 Agent

### Stdio 模式(适用于大多数 MCP 客户端)

在你的 agent 的 MCP 配置中添加:

```json
{
  "mcpServers": {
    "tdx-mcp": {
      "command": "C:\\path\\to\\tdx-mcp-server\\.venv\\Scripts\\python.exe",
      "args": ["C:\\path\\to\\tdx-mcp-server\\server.py"]
    }
  }
}
```

### HTTP 模式(适用于 openclaw 等支持 HTTP MCP 的 agent)

先启动 HTTP 服务:

```bash
.venv\Scripts\python.exe server.py --http --port 31868
```

然后在 agent 配置中指向 `http://127.0.0.1:31868/mcp`。

### OpenClaw 配置示例

在 `openclaw.json` 中添加:

```json
{
  "mcp": {
    "servers": {
      "tdx-mcp": {
        "type": "http",
        "url": "http://127.0.0.1:31868/mcp"
      }
    }
  }
}
```

或使用 stdio:

```json
{
  "mcp": {
    "servers": {
      "tdx-mcp": {
        "command": "C:\\path\\to\\.venv\\Scripts\\python.exe",
        "args": ["C:\\path\\to\\server.py"]
      }
    }
  }
}
```

## 工具参数说明

### web_fetch

```json
{
  "url": "https://example.com",
  "extractMode": "markdown",
  "maxChars": 20000
}
```

### web_search

```json
{
  "query": "搜索关键词",
  "maxResults": 5,
  "region": "cn-zh"
}
```

### http_request

```json
{
  "url": "https://api.example.com/data",
  "method": "POST",
  "headers": {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json"
  },
  "body": "{\"key\": \"value\"}",
  "timeout": 30,
  "maxChars": 20000
}
```

## 与 TdxClaw MCP 的对比

| 特性 | TdxClaw MCP | 本 Server |
|------|-------------|-----------|
| 传输协议 | HTTP (Streamable HTTP) | Stdio + HTTP |
| 默认端口 | 31868 | 31868 (HTTP 模式) |
| web_fetch | ✅ | ✅ |
| web_search | ✅ (需配置 API Key) | ✅ (DuckDuckGo, 免费) |
| http_request | ❌ | ✅ |
| 认证 | Bearer Token | 无(本地使用) |
| SSRF 防护 | ✅ | ✅ |
| 依赖 | TdxClaw 完整安装 | 仅 Python + 几个包 |