顺序思维服务器

一个支持多种传输协议的智能服务器,用于逐步分析和解决复杂问题。

  • by ad
  • Go
  • 本地部署
  • 7 星标
  • 更新于
在 GitHub 查看 ad/sequentialthinking

使用说明

顺序思维MCP服务器

🧠 智能MCP服务器 使用强大的工具逐步分析和解决复杂问题 mcp走 图书馆。

支持 多种传输协议:

  • 标准输入输出 -适用于MCP客户端(VS Code、Claude Desktop)
  • SSE(服务器发送事件) -用于实时web应用程序
  • 流式HTTP -用于传统的web服务和类似REST的交互

⚡ 快速开始

1.建设项目

# Clone repository
git clone https://github.com/ad/sequentialthinking.git
cd sequentialthinking

# Install dependencies
go mod tidy

# Local build using Go
go build -o sequentialthinking-server main.go

# Or using Make
make build-local

# Docker build
make build

2.运行服务器

📡 对于MCP客户端(VS Code、Claude Desktop)-STDIO模式

./sequentialthinking-server -transport stdio
# Or using Make
make run-stdio

🌐 对于实时web应用程序-SSE模式

./sequentialthinking-server -transport sse
# Or with custom port
./sequentialthinking-server -transport sse -port 3000

🔗 对于传统web服务-HTTP模式

./sequentialthinking-server -transport http
# Or with custom port
./sequentialthinking-server -transport http -port 9090

🐳 使用Docker

# Run in Docker (default STDIO mode)
make run
# Or manually
docker run --rm danielapatin/sequentialthinking:latest

# Run with HTTP mode on port 8080
docker run --rm -p 8080:8080 danielapatin/sequentialthinking:latest -transport http -port 8080

3.测试

# Go unit tests
go test -v
# Or using Make
make test

# Test build
make build-local

# Test different transport modes
./sequentialthinking-server -transport stdio   # Test STDIO mode
./sequentialthinking-server -transport sse     # Test SSE mode on port 8080
./sequentialthinking-server -transport http    # Test HTTP mode on port 8080

🚀 用法

与VS代码集成

使用VS代码

要快速安装,请单击下面的安装按钮。..

或添加到 ~/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集成

增添 claude_desktop_config.json:

{
  "mcpServers": {
    "sequentialthinking": {
      "command": "/absolute/path/to/sequentialthinking-server",
      "args": ["-transport", "stdio"],
    }
  }
}

Web集成(SSE/HTTP模式)

对于web应用程序,您可以使用SSE或HTTP传输:

// SSE Client Example
const eventSource = new EventSource('http://localhost:8080/sse');
eventSource.onmessage = function(event) {
    const data = JSON.parse(event.data);
    console.log('Received:', data);
};

// HTTP Client Example
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: 'Analyzing the problem step by step',
                thoughtNumber: 1,
                totalThoughts: 3,
                nextThoughtNeeded: true
            }
        }
    })
});

Docker部署

# Build image
docker build -t danielapatin/sequentialthinking:latest .
# Or using Make
make build

# Run container (STDIO mode)
docker run --rm danielapatin/sequentialthinking:latest -transport stdio

# Run container (HTTP mode with port mapping)
docker run --rm -p 8080:8080 danielapatin/sequentialthinking:latest -transport http -port 8083

# Run container (SSE mode with port mapping)
docker run --rm -p 8080:8080 danielapatin/sequentialthinking:latest -transport sse -port 8084

发出命令

make help                 # Show all available commands
make build               # Build Docker image
make build-local         # Build local binary
make run                 # Run in Docker
make run-local           # Run locally (HTTP mode)
make run-stdio           # Run in stdio mode
make test                # Run tests in Docker

🔍 测试和调试

自动化测试

# Run all tests
./test.sh

# Run Go unit tests
go test -v
# Or using Make
make test

# Manual stdio mode testing
echo '{"id": "1", "method": "tools/list"}' | ./sequentialthinking-server -transport stdio

HTTP API测试

# Start server in background
PORT=8083 ./sequentialthinking-server &

# List available tools
curl -X POST http://localhost:8083/mcp \
  -H "Content-Type: application/json" \
  -d '{"id": "1", "method": "tools/list"}'

# Call sequential thinking
curl -X POST http://localhost:8083/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "id": "2", 
    "method": "tools/call",
    "params": {
      "name": "sequentialthinking",
      "arguments": {
        "thought": "Analyzing this problem step by step",
        "thoughtNumber": 1,
        "totalThoughts": 3,
        "nextThoughtNeeded": true
      }
    }
  }'

# Connect to SSE stream
curl -N http://localhost:8083/sse

web界面

打开 http://localhost:8080 用于可视化界面的交互式测试。

🧠 顺序思维工具

提供了一种结构化的方法,通过逐步思考来解决复杂问题。

主要参数:

  • thought (字符串):当前思维步骤
  • thoughtNumber (整数):当前思维数(从1开始)
  • totalThoughts (整数):估计步骤总数
  • nextThoughtNeeded (布尔值):是否需要下一步

附加参数:

  • isRevision *(布尔值)*这个想法是否修正了以前的想法
  • revisesThought (整数):正在修改的想法数量
  • branchFromThought (整数):备选方法的分支点
  • branchId (字符串):分支标识符
  • needsMoreThoughts (布尔值):需要采取额外步骤的指标

使用示例:

基本顺序思维:

{
  "thought": "Starting analysis of the sorting algorithm",
  "thoughtNumber": 1,
  "totalThoughts": 5, 
  "nextThoughtNeeded": true
}

修改之前的解决方案:

{
  "thought": "Reconsidering the data structure choice given performance requirements",
  "thoughtNumber": 3,
  "totalThoughts": 6,
  "nextThoughtNeeded": true,
  "isRevision": true,
  "revisesThought": 2
}

🔧 操作模式和架构

📡 标准模式(MCP兼容性)

  • 目的:与MCP客户端集成(VS Code、Claude Desktop)
  • 协议:通过标准输入/标准输出的JSON-RPC
  • 发射: ./sequentialthinking-server -transport stdio
  • 特性:与MCP规范2025-03-26完全兼容

🌐 SSE模式

  • 目的:调试、测试、web集成
  • 协议:服务器发送的事件
  • 发射: ./sequentialthinking-server -transport sse (默认端口8080)
  • 端点:
    • POST /sse -SSE实时事件流

🌐 HTTP模式

  • 目的:调试、测试、web集成
  • 协议:HTTP API
  • 发射: ./sequentialthinking-server -transport http (默认端口8080)
  • 端点:
    • POST /mcp -JSON格式的MCP请求

双模架构优势:

✅ 灵活性:一台服务器用于不同的使用场景
✅ 调试:用于测试和监控的Web界面
✅ 兼容性:完全支持MCP标准
✅ 可扩展性:HTTP模式支持多个连接

🛠️ 技术细节

系统要求

  • 去:1.24或更高版本
  • 操作系统:Linux、macOS、Windows
  • 依赖项:仅Go标准库(无外部包)

项目结构

sequentialthinking/
├── main.go              # Main server code
├── main_test.go         # Unit tests  
├── go.mod               # Go module
├── go.sum               # Go dependencies
├── Makefile             # Build automation
├── test.sh              # Testing script
├── Dockerfile           # Docker configuration
└── README.md            # Documentation

构建和部署

# Clone and build
git clone https://github.com/ad/sequentialthinking.git
cd sequentialthinking

# Local build
go build -o sequentialthinking-server main.go
# Or using Make
make build-local

# Docker build
make build

# Cross-platform builds
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

配置

  • HTTP服务器端口: -port 8080 变量(默认8080)
  • 运行模式:由以下因素决定 -transport stdio 旗帜
  • 日志记录:所有日志输出到stderr

📝 许可证:MIT许可证


📚 额外资源

🤝 支持

如果您有任何疑问或问题:

  1. 检查此存储库中的文档
  2. 查看stderr中的服务器日志
  3. 尝试使用web界面进行调试
  4. 在项目存储库中创建问题