scorpiox-bot-plugin-seqthink

scorpiox-bot-plugin-seqthink

main1 branch · 0 tags
VS Code
HTTPS
ForkDelete
Recent Commits
README

plugin_seqthink — Sequential Thinking (SCORPIOX BOT plugin)

seqthink is a clean-room, zero-dependency, pure C99 MCP connector plugin

for SCORPIOX BOT. One small static binary serves the

sequentialthinking tool over MCP JSON-RPC 2.0 stdio and ships a

bot-themed thought-chain viewer, so structured step-by-step reasoning,

revisions and branches made by an agent are inspectable on the node.

It is a clean-room C port of the behaviour of the reference

modelcontextprotocol/servers sequential-thinking server: the same

parameter validation and error strings, the same "raise totalThoughts when

thoughtNumber exceeds it" rule, the same per-connection history with a

MAX_THOUGHT_HISTORY cap (oldest evicted, its branch shrunk with it, an

emptied branch dropped), the same branch semantics (a branch exists only once a

thought carries both branchFromThought and branchId), and the same

five-field result.

Slug seqthink
Binary plugin_seqthink (plugin_seqthink.exe on Windows)
--meta {"name":"seqthink","desc":"Thought chains","kind":"mcp","mcp":true,"daemon":false,"menus":false,"verified":"live"}
Category devtools
Dependencies none — vendored yyjson (MIT) is compiled in
Network zero outbound requests (no TLS, no sockets, no popen)
State its own connector directory only (see below)

The four modes of one binary

Mode Trigger Contract
Discovery --meta or SX_PLUGIN_META=1 one line of JSON, exit 0, never authenticated
MCP server --mcp JSON-RPC 2.0 over stdio: initialize, notifications/*, ping, tools/list, tools/call
Node API ?action=... or a POST JSON body Content-Type: application/json, behind require_node_auth()
Viewer UI GET (default) responsive dark/light HTML (?embed=1, &theme=, sx-theme handoff), zero <script src=>, behind require_node_auth()
./plugin_seqthink --meta
./plugin_seqthink --schema
printf '%s\n' \
 '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' \
 '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' \
 '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"sequentialthinking","arguments":{"thought":"first step","nextThoughtNeeded":true,"thoughtNumber":1,"totalThoughts":3}}}' \
 | ./plugin_seqthink --mcp

The sequentialthinking tool

Input schema (exact parity with the reference server):

Field Type Req Notes
thought string yes the current thinking step (non-empty, ≤ 64 KB)
nextThoughtNeeded boolean yes a "true" / "false" string is accepted, like upstream
thoughtNumber integer ≥ 1 yes numbers or numeric strings (z.coerce parity)
totalThoughts integer ≥ 1 yes estimate; raised automatically when exceeded
isRevision boolean no this thought revises earlier thinking
revisesThought integer ≥ 1 no which thought number is reconsidered
branchFromThought integer ≥ 1 no branching point
branchId string no branch identifier (with branchFromThought, opens the branch)
needsMoreThoughts boolean no reached the end but more thoughts are needed

Every accepted thought returns exactly:

{"thoughtNumber":1,"totalThoughts":3,"nextThoughtNeeded":true,"branches":[],"thoughtHistoryLength":1}

as result.content[0].text and as result.structuredContent. A validation

failure returns {"error":"...","status":"failed"} with isError: true, using

the upstream messages (Invalid thought: must be a string,

Invalid thoughtNumber: must be a number, `Invalid nextThoughtNeeded: must be

a boolean`, ...).

Persistence (so the viewer can see agent reasoning)

One --mcp process is one chain (a server lives as long as its client's

connection, exactly like upstream). Each accepted thought additionally

snapshots the chain to:

<state_dir>/chains.json

where <state_dir> is, in order: $SEQTHINK_STATE_DIR,

/workspace/.scorpiox/connectors/plugin_seqthink (when /workspace exists and

is writable — persists across container restarts),

%LOCALAPPDATA%\scorpiox\connectors\plugin_seqthink on Windows, else

$HOME/.scorpiox/connectors/plugin_seqthink.

The file is merged by chain id (other chains are never clobbered), bounded to

50 chains × 1000 thoughts each, and always written .tmp → rename(), so an

interrupted write can never truncate it. A malformed file degrades to a clean

start instead of crashing. DISABLE_THOUGHT_LOGGING=1|true (upstream parity)

silences the stderr line and the persistence. MAX_THOUGHT_HISTORY caps the

in-memory history (default 1000; a non-positive-integer value is reported on

stderr and replaced by the default).

Node API (behind require_node_auth())

X-Bot-Password, Authorization: Bearer or ?pwd=; a no-op when the node has

no BOT_PASSWORD. --meta and --mcp are never gated. The viewer page shares

this gate: bot-web appends ?pwd= when it opens the plugin, a bare LAN curl of

/plugin_seqthink without a credential answers 401, like every other node

plugin.

Action Result
?action=chains every chain: id, started/updated, thought count, branch list, last thought head
?action=chain&id= one chain's full thought list (id validated: [A-Za-z0-9_-]{1,64})
?action=stats chains / thoughts / branches / revisions / last activity
?action=info plugin + tool schema + caps + state dir
?action=clear&confirm=1 delete the store (also accepts a POST JSON body)

Build

make            # native -> ./plugin_seqthink
make musl       # static musl x86_64  (the universal Linux artifact)
make arm64      # static aarch64
make win64      # static PE via MinGW-w64
make macos      # Apple clang (run on macOS)
make asan       # -fsanitize=address
make fortify    # -D_FORTIFY_SOURCE=2
make test       # native + asan + fortify, then tests/run.sh
make ui         # regenerate src/ui_html.h from src/ui.html

Or through the release CLI (builds all six dist targets + manifest):

scorpiox-cli-botplugin build .

Tests

sh tests/run.sh        # 190+ offline assertions: all 4 modes, MCP parity,
                       # validation errors, caps, auth, HTML invariants,
                       # ASan + fortify, clean-room audit
python3 tests/e2e.py   # Playwright 1440 / 1024 / 390 dark + light (skips
                       # cleanly without Playwright)

Install on a node

Install it from SCORPIOX BOT: Settings → Plugins → Marketplace → seqthink

(1-click prebuilt with SHA-256 verification, or compile-from-source), or let

your agent clone, audit and compile this repository. Then register it as an MCP

server through the SCORPIOX BOT connector router:

{ "mcpServers": { "seqthink": { "command": "/path/to/plugin_seqthink",
                                "args": ["--mcp"] } } }

Open the viewer at Settings → Plugins → Open, or directly at

/plugin_seqthink on the node.

Security posture

  • Runs as a normal plugin binary with the node user's permissions — auditable:

this whole repository is the source, and source.tar.gz next to every

published binary is the exact git archive of the pinned commit.

  • Opens no sockets and spawns no child processes; the only files it

writes are inside its own connector directory.

  • Chain ids are validated before use; every JSON response is built in one

buffer and emitted once; thought text and branch ids are length-capped.

  • MIT licensed. Vendored yyjson is MIT (see vendor/LICENSE.yyjson.txt).