Files
admin bcf7cbbeea
Build and Deploy / build-and-push (push) Successful in 54s
refactor(mcp): remove standalone HTTP mode, keep only built-in endpoint and stdio
- MCP Server is now only available via built-in /mcp endpoint or stdio
- Remove --http flag and standalone HTTP server code
- Simplify documentation and frontend settings
2026-07-27 02:52:46 +08:00

94 lines
2.0 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package mcp
import (
"fmt"
"os"
"strings"
"github.com/engigu/taskpool/internal/mcp"
imc "github.com/engigu/taskpool/internal/mcp"
)
// Run 启动 TaskPool MCP Serverstdio 模式)
// 环境变量(可选,默认使用本地服务器配置):
// TASKPOOL_URL 面板地址
// TASKPOOL_TOKEN OpenAPI Token
func Run(args []string) {
for _, a := range args {
if a == "-h" || a == "--help" {
printHelp()
return
}
}
// 使用内部 OpenAPI 客户端(自动获取服务器地址和 Token)
client := imc.GetOpenAPIClient()
fmt.Fprintf(os.Stderr, "[taskpool-mcp] stdio mode, url=%s token=%s\n", client.BaseURL, maskToken(client.Token))
s := mcp.GetServer()
// 设置外部客户端(用于连接远程服务器)
if client.Token != "" {
mcp.SetExternalClient(client)
}
if err := mcp.ServeStdio(s); err != nil {
fmt.Fprintf(os.Stderr, "[taskpool-mcp] error: %v\n", err)
os.Exit(1)
}
}
func maskToken(t string) string {
t = strings.TrimSpace(t)
if t == "" {
return "(empty)"
}
if len(t) <= 8 {
return "****"
}
return t[:4] + "****" + t[len(t)-4:]
}
func printHelp() {
fmt.Fprintf(os.Stderr, `
TaskPool MCP Server
MCP Server 已内置在后端服务中:
HTTP 端点: http://your-server:8052/mcp
此命令仅用于 stdio 模式(Claude Desktop / Cursor 等)。
用法:
taskpool mcp
环境变量(可选):
TASKPOOL_URL 面板地址(默认使用本机)
TASKPOOL_TOKEN OpenAPI Token(默认从系统设置读取)
Agent 配置:
HTTP 模式(Hermes / OpenClaw:
{
"mcpServers": {
"taskpool": {
"url": "http://your-server:8052/mcp",
"headers": {
"Authorization": "Bearer 你的Token"
}
}
}
}
stdio 模式(Claude Desktop / Cursor:
{
"mcpServers": {
"taskpool": {
"command": "taskpool",
"args": ["mcp"]
}
}
}
前置条件:
系统设置 → 启用 OpenAPI → 生成 Token
`)
}