feat(mcp): integrate MCP Server into backend service as built-in endpoint
Build and Deploy / build-and-push (push) Successful in 54s
Build and Deploy / build-and-push (push) Successful in 54s
- Add MCP Controller and register /mcp route - MCP Server now uses OpenAPI Token for authentication - Update frontend settings to show built-in MCP endpoint config - Update docs to reflect integrated MCP endpoint
This commit is contained in:
+51
-14
@@ -4,34 +4,71 @@ TaskPool 提供官方 **MCP Server**,让 Hermes、OpenClaw、Cursor 等 AI Age
|
||||
|
||||
> OpenAPI ≠ MCP
|
||||
> - **OpenAPI**:`/open2api/v1` REST 接口(设置页「启用 OpenAPI」)
|
||||
> - **MCP Server**:`taskpool mcp`,把上述接口封装成 Agent 可调用的 Tools
|
||||
> - **MCP Server**:`/mcp` HTTP 端点,把 OpenAPI 封装成 Agent 可调用的 Tools
|
||||
|
||||
## 前置条件
|
||||
|
||||
1. 启动后端:`taskpool server`
|
||||
1. 启动后端服务(Docker 或 `taskpool server`)
|
||||
2. 系统设置 → **启用 OpenAPI** → **生成 Token**
|
||||
3. 本机或 Agent 环境能访问面板地址(如 `http://127.0.0.1:8052`)
|
||||
3. Agent 能访问面板地址(如 `http://your-server:8052`)
|
||||
|
||||
## 两种传输模式
|
||||
## 内置 MCP 端点
|
||||
|
||||
| 模式 | 传输方式 | 适用场景 | Agent 配置 |
|
||||
|------|----------|----------|------------|
|
||||
| **stdio** | stdin/stdout | 本地 Agent(Claude Desktop、Cursor) | `command` |
|
||||
| **http** | HTTP/SSE | 远程 Agent(Hermes、OpenClaw) | `url` |
|
||||
MCP Server 已**内置在后端服务中**,无需单独启动进程。启用 OpenAPI 后,MCP 端点自动可用:
|
||||
|
||||
### stdio 模式(默认)
|
||||
```
|
||||
http://your-server:8052/mcp
|
||||
```
|
||||
|
||||
由 Agent 拉起子进程,通过标准输入输出通信。日志输出在 **stderr**,不会污染协议。
|
||||
## Agent 配置示例
|
||||
|
||||
### HTTP 模式(推荐)
|
||||
|
||||
远程 Agent 直接访问内置端点,无需本地安装二进制。
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"taskpool": {
|
||||
"url": "http://your-server:8052/mcp",
|
||||
"headers": {
|
||||
"Authorization": "Bearer 你的OpenAPI_Token"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### stdio 模式
|
||||
|
||||
本地 Agent 需要安装 `taskpool` 二进制(Claude Desktop、Cursor)。
|
||||
|
||||
```bash
|
||||
export TASKPOOL_URL=http://127.0.0.1:8052
|
||||
export TASKPOOL_URL=http://your-server:8052
|
||||
export TASKPOOL_TOKEN=你的OpenAPI_Token
|
||||
taskpool mcp
|
||||
```
|
||||
|
||||
### HTTP 模式
|
||||
Agent 配置:
|
||||
|
||||
独立 HTTP 服务,Agent 通过 URL 访问,无需本地安装二进制。
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"taskpool": {
|
||||
"command": "taskpool",
|
||||
"args": ["mcp"],
|
||||
"env": {
|
||||
"TASKPOOL_URL": "http://your-server:8052",
|
||||
"TASKPOOL_TOKEN": "你的OpenAPI_Token"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 独立 HTTP 服务模式(可选)
|
||||
|
||||
如果需要单独部署 MCP 服务(如不同的端口或机器):
|
||||
|
||||
```bash
|
||||
# 监听默认端口 :8053
|
||||
@@ -45,7 +82,7 @@ export MCP_HTTP_ADDR=:8053
|
||||
taskpool mcp --http
|
||||
```
|
||||
|
||||
HTTP 模式暴露端点:
|
||||
独立模式暴露端点:
|
||||
- `POST /mcp` - MCP 协议端点
|
||||
- `GET /health` - 健康检查
|
||||
|
||||
|
||||
Reference in New Issue
Block a user