Skip to main content
Glama

Sequential Thinking Tool API

by bta4935

シーケンシャル思考ツールAPI

Zod による堅牢な入力検証とシンプルなメモリ内セッション ストアを備えた、順次的な思考セッションと思考を管理するための Node.js/TypeScript バックエンドです。

目次


インストール

  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. 最初に考えたセッションを作成する

  • エンドポイント: 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エンドポイントは、Server-Sent Events(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 の例:

    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 の例:

    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 バックエンド。ユーザーはセッションを作成し、構造化されたシーケンスで思考を投稿することができ、Server-Sent Events によるリアルタイム更新もサポートされます。

  1. 目次
    1. インストール
      1. サーバーの実行
        1. ts-node (開発版)の使用
        2. npm スクリプトを使用する(利用可能な場合)
        3. コンパイルされたJavaScriptの使用
      2. APIエンドポイント
        1. 最初に考えたセッションを作成する
        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