🧠 使用强大的 mcp-go 库进行逐步分析和解决复杂问题的智能 MCP 服务器。
支持多种传输协议:
# 克隆仓库
git clone https://github.com/ad/sequentialthinking.git
cd sequentialthinking
# 安装依赖
go mod tidy
# 使用 Go 进行本地构建
go build -o sequentialthinking-server main.go
# 或者使用 Make
make build-local
# Docker 构建
make build
./sequentialthinking-server -transport stdio
# 或者使用 Make
make run-stdio
./sequentialthinking-server -transport sse
# 或者自定义端口
./sequentialthinking-server -transport sse -port 3000
./sequentialthinking-server -transport http
# 或者自定义端口
./sequentialthinking-server -transport http -port 9090
# 在 Docker 中运行(默认 STDIO 模式)
make run
# 或者手动
docker run --rm danielapatin/sequentialthinking:latest
# 在 HTTP 模式下运行,端口 8080
docker run --rm -p 8080:8080 danielapatin/sequentialthinking:latest -transport http -port 8080
# Go 单元测试
go test -v
# 或者使用 Make
make test
# 测试构建
make build-local
# 测试不同的传输模式
./sequentialthinking-server -transport stdio # 测试 STDIO 模式
./sequentialthinking-server -transport sse # 测试 SSE 模式在端口 8080
./sequentialthinking-server -transport http # 测试 HTTP 模式在端口 8080
对于快速安装,请点击下面的安装按钮...
或者添加到 ~/Library/Application Support/Code/User/settings.json:
{
"mcp": {
"servers": {
"sequentialthinking": {
"type": "stdio",
"command": "/absolute/path/to/sequentialthinking-server",
"args": ["-transport", "stdio"]
}
}
}
}
或者使用 Docker:
{
"mcp": {
"servers": {
"sequentialthinking": {
"type": "stdio",
"command": "docker",
"args": ["run", "--rm", "-i", "danielapatin/sequentialthinking:latest", "-transport", "stdio"]
}
}
}
}
添加到 claude_desktop_config.json:
{
"mcpServers": {
"sequentialthinking": {
"command": "/absolute/path/to/sequentialthinking-server",
"args": ["-transport", "stdio"],
}
}
}
对于 Web 应用程序,可以使用 SSE 或 HTTP 传输:
// SSE 客户端示例
const eventSource = new EventSource('http://localhost:8080/sse');
eventSource.onmessage = function(event) {
const data = JSON.parse(event.data);
console.log('收到:', data);
};
// HTTP 客户端示例
fetch('http://localhost:8080/mcp', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'tools/call',
params: {
name: 'sequentialthinking',
arguments: {
thought: '逐步分析问题',
thoughtNumber: 1,
totalThoughts: 3,
nextThoughtNeeded: true
}
}
})
});
# 构建镜像
docker build -t danielapatin/sequentialthinking:latest .
# 或者使用 Make
make build
# 运行容器(STDIO 模式)
docker run --rm danielapatin/sequentialthinking:latest -transport stdio
# 运行容器(HTTP 模式并映射端口)
docker run --rm -p 8080:8080 danielapatin/sequentialthinking:latest -transport http -port 8083
# 运行容器(SSE 模式并映射端口)
docker run --rm -p 8080:8080 danielapatin/sequentialthinking:latest -transport sse -port 8084
make help # 显示所有可用命令
make build # 构建 Docker 镜像
make build-local # 构建本地二进制文件
make run # 在 Docker 中运行
make run-local # 本地运行(HTTP 模式)
make run-stdio # 运行在 stdio 模式
make test # 在 Docker 中运行测试
# 运行所有测试
./test.sh
# 运行 Go 单元测试
go test -v
# 或者使用 Make
make test
# 手动 stdio 模式测试
echo '{"id": "1", "method": "tools/list"}' | ./sequentialthinking-server -transport stdio
# 在后台启动服务器
PORT=8083 ./sequentialthinking-server &
# 列出可用工具
curl -X POST http://localhost:8083/mcp \
-H "Content-Type: application/json" \
-d '{"id": "1", "method": "tools/list"}'
# 调用顺序思维
curl -X POST http://localhost:8083/mcp \
-H "Content-Type: application/json" \
-d '{
"id": "2",
"method": "tools/call",
"params": {
"name": "sequentialthinking",
"arguments": {
"thought": "逐步分析这个问题",
"thoughtNumber": 1,
"totalThoughts": 3,
"nextThoughtNeeded": true
}
}
}'
# 连接到 SSE 流
curl -N http://localhost:8083/sse
打开 http://localhost:8080 进行具有视觉界面的互动测试。
提供一种通过逐步思考来解决复杂问题的结构化方法。
thought (字符串):当前思考步骤thoughtNumber (整数):当前思考编号(从 1 开始)totalThoughts (整数):预计总步数nextThoughtNeeded (布尔值):是否需要下一步isRevision (布尔值):此思考是否修订了之前的思考revisesThought (整数):被修订的思考编号branchFromThought (整数):分支点以供替代方案branchId (字符串):分支标识符needsMoreThoughts (布尔值):需要额外步骤的指示器{
"thought": "开始分析排序算法",
"thoughtNumber": 1,
"totalThoughts": 5,
"nextThoughtNeeded": true
}
{
"thought": "鉴于性能需求重新考虑数据结构选择",
"thoughtNumber": 3,
"totalThoughts": 6,
"nextThoughtNeeded": true,
"isRevision": true,
"revisesThought": 2
}
./sequentialthinking-server -transport stdio./sequentialthinking-server -transport sse(默认端口 8080)POST /sse - SSE 实时事件流./sequentialthinking-server -transport http(默认端口 8080)POST /mcp - JSON 格式的 MCP 请求✅ 灵活性:一个服务器用于不同使用场景 ✅ 调试:Web 界面用于测试和监控 ✅ 兼容性:完全支持 MCP 标准 ✅ 可扩展性:HTTP 模式支持多个连接
sequentialthinking/
├── main.go # 主服务器代码
├── main_test.go # 单元测试
├── go.mod # Go 模块
├── go.sum # Go 依赖项
├── Makefile # 构建自动化
├── test.sh # 测试脚本
├── Dockerfile # Docker 配置
└── README.md # 文档
# 克隆并构建
git clone https://github.com/ad/sequentialthinking.git
cd sequentialthinking
# 本地构建
go build -o sequentialthinking-server main.go
# 或者使用 Make
make build-local
# Docker 构建
make build
# 跨平台构建
GOOS=linux GOARCH=amd64 go build -o sequentialthinking-linux main.go
GOOS=windows GOARCH=amd64 go build -o sequentialthinking.exe main.go
GOOS=darwin GOARCH=arm64 go build -o sequentialthinking-macos main.go
-port 8080 变量(默认 8080)-transport stdio 标志决定📝 许可证:MIT 许可证
如果您有疑问或遇到问题: