Sequential Thinking Tool API

by bta4935
Integrations
  • Provides examples for interacting with the Sequential Thinking Tool API, demonstrating how to create sessions and post thoughts using curl commands.

  • Built as a Node.js backend service, providing the runtime environment for the Sequential Thinking Tool API.

  • Utilizes npm for package management and running predefined scripts for development and server execution.

顺序思维工具 API

Node.js/TypeScript 后端用于管理连续思考会话和想法,具有使用 Zod 进行强大输入验证和简单的内存会话存储的功能。

目录


安装

  1. 克隆存储库:
    git clone <your-repo-url> cd SQ
  2. 安装依赖项:
    npm install

运行服务器

使用 ts-node(开发)

npx ts-node src/api/httpServer.ts

使用 npm 脚本(如果可用)

npm run dev

使用已编译的 JavaScript

npx tsc node dist/api/httpServer.js

默认情况下,服务器将在端口3000上启动,或者在PORT环境变量中指定的端口上启动。


API 端点

1. 使用 First Thought 创建会话

  • 端点: POST /api/sessions
  • **描述:**创建一个新的会话,并将提供的想法存储为该会话中的第一个想法。返回新的会话 ID 和已处理的想法信息。
  • 请求正文:
    { "thought": "string (required)", "thoughtNumber": 1, "totalThoughts": 3, "nextThoughtNeeded": true, "isRevision": false, // optional "revisesThought": 2, // optional "branchFromThought": 1, // optional "branchId": "string", // optional "needsMoreThoughts": false // optional }
  • 回复:
    { "sessionId": "<uuid>", "thoughtNumber": 1, "totalThoughts": 3, "nextThoughtNeeded": true, "branches": [], "thoughtHistoryLength": 1, "processedThought": "This is my first thought." }

2. 发表补充思考

  • 端点: POST /api/sessions/:sessionId/thoughts
  • **描述:**向指定会话添加一个想法。输入使用 Zod 进行验证。
  • 请求正文:
    { "thought": "string (required)", "thoughtNumber": 2, "totalThoughts": 3, "nextThoughtNeeded": true, "isRevision": false, // optional "revisesThought": 1, // optional "branchFromThought": 1, // optional "branchId": "string", // optional "needsMoreThoughts": false // optional }
  • 回复:
    { "thoughtNumber": 2, "totalThoughts": 3, "nextThoughtNeeded": true, "branches": [], "thoughtHistoryLength": 2, "processedThought": "This is my second thought." }

MCP SSE(服务器发送事件)

概述

MCP SSE 端点支持使用服务器发送事件 (SSE) 将服务器事件实时、单向地传输到客户端。这对于希望在不轮询服务器的情况下接收会话或思维处理更新的客户端非常有用。

端点

  • 获取/api/mcp/sse
  • **描述:**建立持久的 SSE 连接。服务器会在事件发生时将其推送至客户端。
  • 回复:
    • 内容类型: text/event-stream
    • 事件以data:开头的行发送,后跟 JSON 编码的事件对象。

示例 curl 命令

curl -N http://localhost:3000/api/mcp/sse

事件响应示例

data: {"event":"thoughtProcessed","sessionId":"...","thoughtNumber":1,"message":"Thought processed successfully."}

使用说明

  • 保持连接打开以继续接收事件。
  • 每个事件都是一个 JSON 对象。当每个事件到达客户端时,对其进行处理。
  • 如果您需要监听特定会话的事件,请包含您的实现所支持的查询参数(例如, /api/mcp/sse?sessionId=... )。

验证

所有发送至/thoughts POST 请求均使用 Zod 进行验证。无效请求将返回 400 状态码和验证错误列表。


用户流程:一念之间创建会话

  1. 用户将他们的第一个想法发送到/api/sessions
    • 服务器创建一个新的会话并存储第一个想法。
    • 返回新的sessionId和已处理的思想信息。

    卷曲示例:

    curl -X POST http://localhost:3000/api/sessions \ -H "Content-Type: application/json" \ -d '{ "thought": "This is my first thought.", "thoughtNumber": 1, "totalThoughts": 3, "nextThoughtNeeded": true }'

    响应示例:

    { "sessionId": "abc123", "thoughtNumber": 1, "totalThoughts": 3, "nextThoughtNeeded": true, "branches": [], "thoughtHistoryLength": 1, "processedThought": "This is my first thought." }
  2. 用户将其他想法发送至/api/sessions/:sessionId/thoughts
    • 服务器将该想法添加到现有会话中。

    卷曲示例:

    curl -X POST http://localhost:3000/api/sessions/abc123/thoughts \ -H "Content-Type: application/json" \ -d '{ "thought": "This is my second thought.", "thoughtNumber": 2, "totalThoughts": 3, "nextThoughtNeeded": true }'

    响应示例:

    { "thoughtNumber": 2, "totalThoughts": 3, "nextThoughtNeeded": true, "branches": [], "thoughtHistoryLength": 2, "processedThought": "This is my second thought." }

错误响应示例(无效输入)

{ "errors": [ { "path": ["thought"], "message": "Thought cannot be empty" } ] }

发展

  • TypeScript 配置在tsconfig.json中。
  • Zod 模式位于src/types.ts中。
  • 验证中间件位于src/api/validationMiddleware.ts中。
  • 主服务器逻辑位于src/api/httpServer.ts中。

执照

麻省理工学院

-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Node.js/TypeScript 后端用于管理顺序思考会话,允许用户创建会话并以结构化序列发布想法,并支持通过服务器发送事件进行实时更新。

  1. 目录
    1. 安装
      1. 运行服务器
        1. 使用 ts-node(开发)
        2. 使用 npm 脚本(如果可用)
        3. 使用已编译的 JavaScript
      2. API 端点
        1. 使用 First Thought 创建会话
        2. 发表补充思考
      3. MCP SSE(服务器发送事件)
        1. 概述
        2. 端点
        3. 示例 curl 命令
        4. 事件响应示例
        5. 使用说明
      4. 验证
        1. 用户流程:一念之间创建会话
          1. 错误响应示例(无效输入)
        2. 发展
          1. 执照

            Related MCP Servers

            • -
              security
              F
              license
              -
              quality
              This TypeScript-based server implements a simple notes system, allowing users to create and manage text notes and generate summaries, showcasing core MCP concepts.
              Last updated -
              2
              7
              TypeScript
              • Apple
            • A
              security
              F
              license
              A
              quality
              A TypeScript Model Context Protocol server that integrates with Google Tasks API, allowing users to create, list, update, delete, and toggle completion status of tasks.
              Last updated -
              4
              3
              JavaScript
            • A
              security
              A
              license
              A
              quality
              Node.js server implementing Model Context Protocol that enables interaction with TaskWarrior through natural language to view, filter, add, and complete tasks.
              Last updated -
              3
              13
              1
              JavaScript
              MIT License
            • -
              security
              F
              license
              -
              quality
              A Node.js and TypeScript server project that provides a simple starter example with Express.js web server, supporting hot-reload, testing, and modular structure.
              Last updated -
              TypeScript

            View all related MCP servers

            MCP directory API

            We provide all the information about MCP servers via our MCP API.

            curl -X GET 'https://glama.ai/api/mcp/v1/servers/bta4935/SQ-MCP'

            If you have feedback or need assistance with the MCP directory API, please join our Discord server