@j0hanz/thinkseq-mcp 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,85 +1,92 @@
1
1
  # ThinkSeq MCP Server
2
2
 
3
- <img src="docs/logo.png" alt="ThinkSeq MCP Server Logo" width="175" />
3
+ [![npm version](https://img.shields.io/npm/v/@j0hanz/thinkseq-mcp)](https://www.npmjs.com/package/@j0hanz/thinkseq-mcp) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D24-green)](https://nodejs.org) [![TypeScript](https://img.shields.io/badge/TypeScript-5.9%2B-blue)](https://www.typescriptlang.org) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-%5E1.26-purple)](https://modelcontextprotocol.io)
4
4
 
5
- An MCP server for structured, sequential thinking with revision support.
5
+ [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0078d7?logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22thinkseq%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fthinkseq-mcp%40latest%22%5D%7D) [![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install_Server-24bfa5?logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Amcp%2Finstall%3F%7B%22name%22%3A%22thinkseq%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fthinkseq-mcp%40latest%22%5D%7D)
6
6
 
7
- [![npm version](https://img.shields.io/npm/v/@j0hanz/thinkseq-mcp.svg)](https://www.npmjs.com/package/@j0hanz/thinkseq-mcp)
7
+ A thinking and reasoning engine for the Model Context Protocol (MCP). Enables AI assistants to capture structured, sequential reasoning chains with full revision (destructive rewind) support, session isolation, and progress tracking.
8
8
 
9
- ## One-click install
10
-
11
- [![Install with NPX in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=thinkseq&inputs=%5B%5D&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fthinkseq-mcp%40latest%22%5D%7D) [![Install with NPX in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=thinkseq&inputs=%5B%5D&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fthinkseq-mcp%40latest%22%5D%7D&quality=insiders)
12
-
13
- [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/install-mcp?name=thinkseq&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBqMGhhbnovdGhpbmtzZXEtbWNwQGxhdGVzdCJdfQ==)
9
+ ---
14
10
 
15
11
  ## Overview
16
12
 
17
- ThinkSeq exposes a single MCP tool, `thinkseq`, for structured, sequential thinking. The server runs over stdio and stores an in-memory thought history so it can return progress, active-path context, and revision metadata on each call.
13
+ ThinkSeq provides an MCP server that exposes a single `thinkseq` tool for recording concise thinking steps. Each step is stored in-memory within isolated sessions, and the engine supports revising earlier steps superseding the target and all subsequent active thoughts while preserving the full audit trail. The server communicates exclusively over **stdio** transport.
18
14
 
19
- ## Quick start
15
+ ---
20
16
 
21
- ```bash
22
- npx -y @j0hanz/thinkseq-mcp@latest
23
- ```
17
+ ## Key Features
24
18
 
25
- ## CLI options
19
+ - **Sequential thinking steps** — Record atomic reasoning steps (up to 8,000 characters each) in order
20
+ - **Destructive revision (rewind)** — Revise any active thought; the target and all later thoughts are superseded, continuing from the corrected step
21
+ - **Session isolation** — Multiple independent thought histories via session IDs with pinned LRU eviction (default: 50 sessions)
22
+ - **Progress tracking** — Automatic `progress` (0–1) and `isComplete` signals returned with every response
26
23
 
27
- ```bash
28
- thinkseq --max-thoughts 500 --max-memory-mb 100
29
- ```
24
+ ---
30
25
 
31
- Available flags:
26
+ ## Tech Stack
32
27
 
33
- - `--max-thoughts <number>`: Max thoughts to keep in memory.
34
- - `--max-memory-mb <number>`: Max memory (MB) for stored thoughts.
35
- - `--shutdown-timeout-ms <number>`: Graceful shutdown timeout.
36
- - `--package-read-timeout-ms <number>`: Package.json read timeout.
37
- - `-h, --help`: Show help.
28
+ | Component | Technology |
29
+ | --------------- | ---------------------------------------- |
30
+ | Runtime | Node.js 24 |
31
+ | Language | TypeScript 5.9+ |
32
+ | MCP SDK | `@modelcontextprotocol/sdk` ^1.26.0 |
33
+ | Validation | `zod` ^4.3.6 |
34
+ | Test framework | Native Node.js Test Runner (`node:test`) |
35
+ | Package manager | npm |
38
36
 
39
- Defaults and limits:
37
+ ---
40
38
 
41
- - `maxThoughts` default: 500 (cap 10000).
42
- - `maxMemoryBytes` default: 100 MB (derived from `--max-memory-mb`).
43
- - `packageReadTimeoutMs` default: 2000 ms.
44
- - `shutdownTimeoutMs` default: 5000 ms.
39
+ ## Architecture
45
40
 
46
- ## MCP client configuration
41
+ 1. **CLI** parses arguments (`--max-thoughts`, `--max-memory-mb`, etc.)
42
+ 2. **`run()`** resolves dependencies and reads `package.json` for server identity
43
+ 3. **McpServer** is created with embedded instructions, the `thinkseq` tool, `internal://instructions` resource, and `get-help` prompt
44
+ 4. **StdioServerTransport** connects the server (stdio only)
45
+ 5. **Stdio guards** are installed: initialization enforcement, invalid message rejection, parse error responder
46
+ 6. **Shutdown handlers** listen for `SIGTERM`/`SIGINT` and gracefully close server, engine, and transport within a configurable timeout
47
47
 
48
- Add this to your MCP client settings:
48
+ ---
49
+
50
+ ## Repository Structure
49
51
 
50
- ```json
51
- {
52
- "mcpServers": {
53
- "thinkseq": {
54
- "command": "npx",
55
- "args": ["-y", "@j0hanz/thinkseq-mcp@latest"]
56
- }
57
- }
58
- }
52
+ ```
53
+ thinkseq-mcp/
54
+ ├── src/
55
+ │ ├── appConfig/ # Environment, run dependencies, shutdown, types
56
+ │ ├── engine/ # Revision logic, thought queries, thought store
57
+ │ ├── lib/ # CLI, context, diagnostics, errors, MCP logging, stdio guards
58
+ │ ├── schemas/ # Zod input/output schemas
59
+ │ ├── tools/ # MCP tool registration (thinkseq)
60
+ │ ├── app.ts # Core application wiring and lifecycle
61
+ │ ├── engine.ts # ThinkingEngine class (session management, processing)
62
+ │ ├── engineConfig.ts # Engine constants and defaults
63
+ │ ├── index.ts # Entry point (CLI → run)
64
+ │ └── instructions.md # Server instructions (bundled as resource/prompt)
65
+ ├── tests/ # Unit and integration tests
66
+ ├── scripts/
67
+ │ └── tasks.mjs # Custom build/test task runner
68
+ ├── assets/
69
+ │ └── logo.svg # Server icon
70
+ ├── package.json
71
+ └── tsconfig.json
59
72
  ```
60
73
 
61
- <details>
62
- <summary><b>VS Code</b></summary>
74
+ ---
63
75
 
64
- Add to your `mcp.json` (command palette: "MCP: Open Settings"):
76
+ ## Requirements
65
77
 
66
- ```json
67
- {
68
- "mcpServers": {
69
- "thinkseq": {
70
- "command": "npx",
71
- "args": ["-y", "@j0hanz/thinkseq-mcp@latest"]
72
- }
73
- }
74
- }
75
- ```
78
+ - **Node.js** ≥ 24
79
+ - **npm** (included with Node.js)
76
80
 
77
- </details>
81
+ ---
78
82
 
79
- <details>
80
- <summary><b>Claude Desktop</b></summary>
83
+ ## Quickstart
81
84
 
82
- Add to your `claude_desktop_config.json`:
85
+ ```bash
86
+ npx -y @j0hanz/thinkseq-mcp@latest
87
+ ```
88
+
89
+ Add to your MCP client configuration:
83
90
 
84
91
  ```json
85
92
  {
@@ -92,111 +99,99 @@ Add to your `claude_desktop_config.json`:
92
99
  }
93
100
  ```
94
101
 
95
- </details>
96
-
97
- <details>
98
- <summary><b>Cursor</b></summary>
102
+ ---
99
103
 
100
- 1. Go to **Cursor Settings** > **General** > **MCP**.
101
- 2. Click **Add New MCP Server**.
102
- 3. Fill in the details:
103
- - **Name:** `thinkseq`
104
- - **Type:** `command`
105
- - **Command:** `npx -y @j0hanz/thinkseq-mcp@latest`
104
+ ## Installation
106
105
 
107
- </details>
106
+ ### NPX (recommended)
108
107
 
109
- <details>
110
- <summary><b>Windsurf</b></summary>
108
+ ```bash
109
+ npx -y @j0hanz/thinkseq-mcp@latest
110
+ ```
111
111
 
112
- Add to your `~/.codeium/windsurf/mcp_config.json`:
112
+ ### Global Install
113
113
 
114
- ```json
115
- {
116
- "mcpServers": {
117
- "thinkseq": {
118
- "command": "npx",
119
- "args": ["-y", "@j0hanz/thinkseq-mcp@latest"]
120
- }
121
- }
122
- }
114
+ ```bash
115
+ npm install -g @j0hanz/thinkseq-mcp
116
+ thinkseq
123
117
  ```
124
118
 
125
- </details>
119
+ ### From Source
126
120
 
127
- ## Tool: `thinkseq`
121
+ ```bash
122
+ git clone https://github.com/j0hanz/thinkseq-mcp-server.git
123
+ cd thinkseq-mcp-server
124
+ npm install
125
+ npm run build
126
+ npm start
127
+ ```
128
128
 
129
- Record a concise thinking step. Be brief: capture only the essential insight, calculation, or decision-like a minimal draft, not a verbose explanation.
129
+ ---
130
130
 
131
- ### Input
131
+ ## Configuration
132
132
 
133
- | Field | Type | Required | Description |
134
- | :--------------- | :----- | :------: | :----------------------------------------------------------------- |
135
- | `thought` | string | yes | Current thinking step (1-8000 chars). |
136
- | `sessionId` | string | no | Optional session identifier to isolate thought histories. |
137
- | `totalThoughts` | number | no | Estimated total thoughts (1-25, default: 3). |
138
- | `revisesThought` | number | no | Revise a previous thought by number. Original preserved for audit. |
133
+ ### CLI Arguments
139
134
 
140
- ### Output
135
+ | Flag | Type | Description |
136
+ | ------------------------------------ | ------ | ----------------------------------- |
137
+ | `--max-thoughts <number>` | number | Max thoughts to keep in memory |
138
+ | `--max-memory-mb <number>` | number | Max memory (MB) for stored thoughts |
139
+ | `--shutdown-timeout-ms <number>` | number | Graceful shutdown timeout (ms) |
140
+ | `--package-read-timeout-ms <number>` | number | Package.json read timeout (ms) |
141
+ | `-h`, `--help` | flag | Show help text |
141
142
 
142
- The tool returns `structuredContent` with an `ok` flag. On success, `result` is populated; on error, `error` is populated.
143
+ ### Engine Defaults
143
144
 
144
- Envelope fields:
145
+ | Parameter | Default | Max |
146
+ | ------------------------- | -------- | ------ |
147
+ | Max thoughts per session | 500 | 10,000 |
148
+ | Max memory | 100 MB | — |
149
+ | Thought overhead estimate | 200 B | — |
150
+ | Max sessions (LRU) | 50 | 10,000 |
151
+ | Default total thoughts | 3 | 25 |
152
+ | Default shutdown timeout | 5,000 ms | — |
153
+ | Package read timeout | 2,000 ms | — |
145
154
 
146
- | Field | Type | Description |
147
- | :------- | :------ | :----------------------------------- |
148
- | `ok` | boolean | `true` on success, `false` on error. |
149
- | `result` | object | Present when `ok` is true. |
150
- | `error` | object | Present when `ok` is false. |
155
+ ### Environment Variables
151
156
 
152
- Result fields:
157
+ | Variable | Default | Description |
158
+ | ------------------------------- | ------- | ------------------------------------------------------------------------------ |
159
+ | `THINKSEQ_INCLUDE_TEXT_CONTENT` | `true` | Set to `0`, `false`, `no`, or `off` to omit JSON string content from responses |
153
160
 
154
- | Field | Type | Description |
155
- | :--------------------- | :------- | :--------------------------------------------------- |
156
- | `thoughtNumber` | number | Auto-incremented thought number. |
157
- | `totalThoughts` | number | Effective total thoughts (at least `thoughtNumber`). |
158
- | `progress` | number | `thoughtNumber / totalThoughts` (0 to 1). |
159
- | `isComplete` | boolean | `true` when `thoughtNumber >= totalThoughts`. |
160
- | `thoughtHistoryLength` | number | Stored thought count after pruning. |
161
- | `hasRevisions` | boolean | `true` if any thought has been revised. |
162
- | `activePathLength` | number | Count of non-superseded thoughts. |
163
- | `revisableThoughts` | number[] | Thought numbers available for revision. |
164
- | `context` | object | Recent context summary (see below). |
161
+ ---
165
162
 
166
- Context fields:
163
+ ## Usage
167
164
 
168
- | Field | Type | Description |
169
- | :--------------- | :----- | :---------------------------------------------------------------------- |
170
- | `recentThoughts` | array | Up to the last 5 active thoughts with `stepIndex`, `number`, `preview`. |
171
- | `revisionInfo` | object | Present when revising: `revises` (number) and `supersedes` (number[]). |
165
+ ### stdio (default and only transport)
172
166
 
173
- Notes:
167
+ ```bash
168
+ # Direct
169
+ npx -y @j0hanz/thinkseq-mcp@latest
174
170
 
175
- - `recentThoughts` previews are truncated to 100 characters.
176
- - Revisions are a destructive rewind: they supersede the target thought and any later active thoughts in the active chain.
177
- - `recentThoughts[].stepIndex` is a contiguous 1-based index in the current active chain (useful when thought numbers become non-contiguous after revisions).
171
+ # With options
172
+ npx -y @j0hanz/thinkseq-mcp@latest --max-thoughts 1000 --max-memory-mb 200
173
+ ```
178
174
 
179
- Error fields:
175
+ ---
180
176
 
181
- | Code | Description |
182
- | :----------------------------- | :---------------------------------------------- |
183
- | `E_REVISION_TARGET_NOT_FOUND` | The requested thought number does not exist. |
184
- | `E_REVISION_TARGET_SUPERSEDED` | The requested thought was already superseded. |
185
- | `E_THINK` | Unexpected tool failure while processing input. |
177
+ ## MCP Surface
186
178
 
187
- ### Example
179
+ ### Tools
188
180
 
189
- **Basic usage:**
181
+ #### `thinkseq`
190
182
 
191
- Input:
183
+ Record a concise thinking step. Supports sequential appending and destructive revision of prior steps.
192
184
 
193
- ```json
194
- {
195
- "thought": "3 steps: parse -> validate -> transform"
196
- }
197
- ```
185
+ **Parameters:**
198
186
 
199
- Output (success):
187
+ | Name | Type | Required | Default | Description |
188
+ | ---------------- | ------ | -------- | ----------- | -------------------------------------------------------------------------- |
189
+ | `thought` | string | Yes | — | Your current thinking step (1–8,000 characters) |
190
+ | `sessionId` | string | No | `"default"` | Session identifier to isolate thought histories (1–200 chars) |
191
+ | `totalThoughts` | number | No | `3` | Estimated total thoughts (1–25) |
192
+ | `revisesThought` | number | No | — | Revise a previous thought by number (≥ 1). Original is preserved for audit |
193
+
194
+ **Returns** (structured output):
200
195
 
201
196
  ```json
202
197
  {
@@ -204,18 +199,19 @@ Output (success):
204
199
  "result": {
205
200
  "thoughtNumber": 1,
206
201
  "totalThoughts": 3,
207
- "progress": 0.3333333333333333,
202
+ "progress": 0.333,
208
203
  "isComplete": false,
209
204
  "thoughtHistoryLength": 1,
210
205
  "hasRevisions": false,
211
206
  "activePathLength": 1,
212
207
  "revisableThoughts": [1],
208
+ "revisableThoughtsTotal": 1,
213
209
  "context": {
214
210
  "recentThoughts": [
215
211
  {
216
212
  "stepIndex": 1,
217
213
  "number": 1,
218
- "preview": "3 steps: parse -> validate -> transform"
214
+ "preview": "First step of reasoning..."
219
215
  }
220
216
  ]
221
217
  }
@@ -223,128 +219,225 @@ Output (success):
223
219
  }
224
220
  ```
225
221
 
226
- **Revising a thought:**
222
+ **Revision example:**
227
223
 
228
- If you realize an earlier step was wrong, use `revisesThought` to correct it:
224
+ ```json
225
+ {
226
+ "thought": "Better approach: use caching instead",
227
+ "revisesThought": 2
228
+ }
229
+ ```
229
230
 
230
- Input:
231
+ Returns additional `revisionInfo` in `context`:
231
232
 
232
233
  ```json
233
234
  {
234
- "thought": "Better approach: validate first, then parse",
235
- "revisesThought": 1
235
+ "context": {
236
+ "recentThoughts": [...],
237
+ "revisionInfo": {
238
+ "revises": 2,
239
+ "supersedes": [2, 3],
240
+ "supersedesTotal": 2
241
+ }
242
+ }
236
243
  }
237
244
  ```
238
245
 
239
- Output:
246
+ **Error codes:**
247
+
248
+ | Code | Description |
249
+ | ------------------------------ | ------------------------------------------ |
250
+ | `E_THINK` | General processing error |
251
+ | `E_REVISION_MISSING` | `revisesThought` required but not provided |
252
+ | `E_REVISION_TARGET_NOT_FOUND` | Target thought number does not exist |
253
+ | `E_REVISION_TARGET_SUPERSEDED` | Target thought was already superseded |
254
+
255
+ ### Resources
256
+
257
+ | URI | MIME Type | Description |
258
+ | ------------------------- | --------------- | ------------------------- |
259
+ | `internal://instructions` | `text/markdown` | Server usage instructions |
260
+
261
+ ### Prompts
262
+
263
+ | Name | Description |
264
+ | ---------- | -------------------------------------- |
265
+ | `get-help` | Get usage instructions for this server |
266
+
267
+ ---
268
+
269
+ ## Client Configuration Examples
270
+
271
+ <details>
272
+ <summary>VS Code / VS Code Insiders</summary>
273
+
274
+ Add to your VS Code MCP settings (`.vscode/mcp.json` or User Settings):
240
275
 
241
276
  ```json
242
277
  {
243
- "ok": true,
244
- "result": {
245
- "thoughtNumber": 2,
246
- "totalThoughts": 3,
247
- "progress": 0.6666666666666666,
248
- "isComplete": false,
249
- "thoughtHistoryLength": 2,
250
- "hasRevisions": true,
251
- "activePathLength": 1,
252
- "revisableThoughts": [2],
253
- "context": {
254
- "recentThoughts": [
255
- {
256
- "stepIndex": 1,
257
- "number": 2,
258
- "preview": "Better approach: validate first, then parse"
259
- }
260
- ],
261
- "revisionInfo": {
262
- "revises": 1,
263
- "supersedes": [1]
264
- }
278
+ "mcpServers": {
279
+ "thinkseq": {
280
+ "command": "npx",
281
+ "args": ["-y", "@j0hanz/thinkseq-mcp@latest"]
265
282
  }
266
283
  }
267
284
  }
268
285
  ```
269
286
 
270
- ## Behavior and validation
287
+ </details>
271
288
 
272
- - Inputs are validated with Zod and unknown keys are rejected.
273
- - `thoughtNumber` is auto-incremented (1, 2, 3...).
274
- - `totalThoughts` defaults to 3, must be in 1-25, and is adjusted up to at least `thoughtNumber`.
275
- - The engine stores thoughts in memory and prunes when limits are exceeded:
276
- - `maxThoughts` default: 500 (cap 10000). When exceeded, prunes the oldest 10% (minimum excess).
277
- - `maxMemoryBytes` default: 100 MB. When exceeded and history is large, prunes roughly 20% of history.
278
- - `estimatedThoughtOverheadBytes` default: 200.
289
+ <details>
290
+ <summary>Claude Desktop</summary>
279
291
 
280
- ## Diagnostics
292
+ Add to `claude_desktop_config.json`:
281
293
 
282
- This server publishes events via `node:diagnostics_channel`:
294
+ ```json
295
+ {
296
+ "mcpServers": {
297
+ "thinkseq": {
298
+ "command": "npx",
299
+ "args": ["-y", "@j0hanz/thinkseq-mcp@latest"]
300
+ }
301
+ }
302
+ }
303
+ ```
283
304
 
284
- - `thinkseq:tool` for `tool.start` and `tool.end` (includes duration, errors, and request context).
285
- - `thinkseq:lifecycle` for `lifecycle.started` and `lifecycle.shutdown`.
305
+ </details>
286
306
 
287
- ## Configuration
307
+ <details>
308
+ <summary>Cursor</summary>
288
309
 
289
- No environment variables or CLI flags are required for basic operation. The server runs over stdio, enforces MCP initialization order, and validates protocol versions. Invalid JSON-RPC message shapes and parse errors are surfaced as JSON-RPC errors on stdio.
310
+ Add to Cursor MCP settings:
290
311
 
291
- ## Development
312
+ ```json
313
+ {
314
+ "mcpServers": {
315
+ "thinkseq": {
316
+ "command": "npx",
317
+ "args": ["-y", "@j0hanz/thinkseq-mcp@latest"]
318
+ }
319
+ }
320
+ }
321
+ ```
292
322
 
293
- ### Prerequisites
323
+ Or use the deeplink:
294
324
 
295
- - Node.js >= 20.0.0
325
+ ```
326
+ cursor://anysphere.cursor-deeplink/mcp/install?name=thinkseq&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBqMGhhbnovdGhpbmtzZXEtbWNwQGxhdGVzdCJdfQ==
327
+ ```
296
328
 
297
- ### Scripts
329
+ </details>
330
+
331
+ <details>
332
+ <summary>Windsurf</summary>
298
333
 
299
- | Command | Description |
300
- | :----------------------- | :------------------------------- |
301
- | `npm run build` | Compile TypeScript to `dist/`. |
302
- | `npm run dev` | Run the server in watch mode. |
303
- | `npm start` | Run `dist/index.js`. |
304
- | `npm run test` | Run the test suite. |
305
- | `npm run test:ci` | Build, then run the test suite. |
306
- | `npm run test:coverage` | Run tests with coverage output. |
307
- | `npm run lint` | Lint with ESLint. |
308
- | `npm run format` | Format with Prettier. |
309
- | `npm run format:check` | Check formatting with Prettier. |
310
- | `npm run type-check` | Type-check without emitting. |
311
- | `npm run inspector` | Launch the MCP inspector. |
312
- | `npm run clean` | Remove `dist/`. |
313
- | `npm run prepublishOnly` | Lint, type-check, and build. |
314
- | `npm run benchmark` | Run `benchmark/engine.bench.ts`. |
315
-
316
- Benchmark environment variables:
317
-
318
- - `THINKSEQ_BENCH_SAMPLES` (default: 1)
319
- - `THINKSEQ_BENCH_NEW_ITERATIONS` (default: 10000)
320
- - `THINKSEQ_BENCH_REV_ITERATIONS` (default: 1000)
321
- - `THINKSEQ_BENCH_WARMUP` (default: 1000)
322
- - `THINKSEQ_BENCH_PIN` (optional CPU affinity mask)
323
-
324
- ### Project structure
325
-
326
- ```text
327
- src/
328
- app.ts # Application setup and MCP wiring
329
- appConfig.ts # Dependency wiring and shutdown handling
330
- engine.ts # Core thinking engine
331
- engineConfig.ts # Defaults and limits
332
- engine/ # Revision and query helpers
333
- lib/ # CLI, diagnostics, errors, protocol, stdio utilities
334
- schemas/ # Zod input/output schemas
335
- tools/ # MCP tool definitions (thinkseq)
336
- tests/ # Node.js tests
337
- benchmark/ # Benchmark targets
338
- docs/ # Assets (logo)
339
- dist/ # Build output
340
- scripts/ # Quality gates and metrics helpers
341
- metrics/ # Generated metrics outputs
334
+ Add to `~/.codeium/windsurf/mcp_config.json`:
335
+
336
+ ```json
337
+ {
338
+ "mcpServers": {
339
+ "thinkseq": {
340
+ "command": "npx",
341
+ "args": ["-y", "@j0hanz/thinkseq-mcp@latest"]
342
+ }
343
+ }
344
+ }
345
+ ```
346
+
347
+ </details>
348
+
349
+ ---
350
+
351
+ ## Security
352
+
353
+ ### stdio Transport
354
+
355
+ - **stdout protection:** `console.log` and `console.warn` are bridged to MCP logging messages to prevent polluting the JSON-RPC stdio channel.
356
+ - **Initialization enforcement:** The server rejects any request before a valid `initialize` handshake and requires `notifications/initialized` before accepting tool calls.
357
+ - **Invalid message rejection:** Non-object and batch JSON-RPC messages are rejected with proper error codes.
358
+ - **Parse error handling:** Malformed JSON on stdin receives a JSON-RPC Parse Error response.
359
+
360
+ ### Process Safety
361
+
362
+ - Unhandled rejections and uncaught exceptions are caught and result in a clean process exit.
363
+ - Graceful shutdown on `SIGTERM`/`SIGINT` with configurable timeout (default: 5 seconds).
364
+
365
+ ---
366
+
367
+ ## Development Workflow
368
+
369
+ ### Install Dependencies
370
+
371
+ ```bash
372
+ npm install
342
373
  ```
343
374
 
375
+ ### Scripts
376
+
377
+ | Script | Command | Purpose |
378
+ | --------------- | -------------------------------------------- | ----------------------------------------------------------------- |
379
+ | `dev` | `tsc --watch --preserveWatchOutput` | Watch mode TypeScript compilation |
380
+ | `dev:run` | `node --env-file=.env --watch dist/index.js` | Run built server with auto-reload |
381
+ | `build` | `node scripts/tasks.mjs build` | Full build pipeline (clean → compile → validate → assets → chmod) |
382
+ | `start` | `node dist/index.js` | Run the built server |
383
+ | `test` | `node scripts/tasks.mjs test` | Run all tests (builds first) |
384
+ | `test:coverage` | `node scripts/tasks.mjs test --coverage` | Run tests with coverage |
385
+ | `type-check` | `node scripts/tasks.mjs type-check` | TypeScript type checking |
386
+ | `lint` | `eslint .` | Run ESLint |
387
+ | `lint:fix` | `eslint . --fix` | Auto-fix lint issues |
388
+ | `format` | `prettier --write .` | Format code with Prettier |
389
+ | `clean` | `node scripts/tasks.mjs clean` | Remove dist and build info files |
390
+ | `inspector` | `npx @modelcontextprotocol/inspector` | Launch MCP Inspector for debugging |
391
+ | `knip` | `knip` | Detect unused exports/dependencies |
392
+
393
+ ---
394
+
395
+ ## Build and Release
396
+
397
+ The build pipeline (`npm run build`) executes:
398
+
399
+ 1. **Clean** — Remove `dist/` and `.tsbuildinfo` files
400
+ 2. **Compile** — TypeScript compilation via `tsconfig.build.json`
401
+ 3. **Validate** — Ensure `src/instructions.md` exists
402
+ 4. **Copy assets** — Bundle `instructions.md` and `assets/` (including `logo.svg`) into `dist/`
403
+ 5. **Make executable** — Set `dist/index.js` to mode `755`
404
+
405
+ ### Publishing
406
+
407
+ Publishing is automated via GitHub Actions (`.github/workflows/publish.yml`):
408
+
409
+ - Triggered on GitHub release publication
410
+ - Pipeline: lint → type-check → test → coverage → build → `npm publish --access public`
411
+ - Uses npm Trusted Publishing (OIDC) for authentication
412
+
413
+ ---
414
+
344
415
  ## Troubleshooting
345
416
 
346
- - CI workflow references `npm run maintainability` and `npm run duplication`, but these scripts are not defined in `package.json`.
417
+ ### MCP Inspector
418
+
419
+ Use the MCP Inspector to debug and test the server interactively:
420
+
421
+ ```bash
422
+ npx @modelcontextprotocol/inspector
423
+ ```
424
+
425
+ ### Common Issues
426
+
427
+ | Issue | Solution |
428
+ | -------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
429
+ | Server not responding | Ensure Node.js ≥ 24 is installed; check `node --version` |
430
+ | `initialize must be first request` | Client must send `initialize` before any other request |
431
+ | `notifications/initialized must follow initialize` | Client must send `notifications/initialized` after successful `initialize` |
432
+ | Thoughts disappearing | Check `--max-thoughts` and `--max-memory-mb` limits; old thoughts are pruned when limits are reached |
433
+ | Session not found | Sessions are in-memory only; they reset on server restart. Max 50 sessions by default (LRU eviction) |
434
+
435
+ ### stdout/stderr Guidance
436
+
437
+ When running as a stdio MCP server, **never write directly to stdout** from custom code — this would corrupt the JSON-RPC protocol. The server automatically bridges `console.log`/`console.warn` to MCP logging. Use `console.error` for debug output that bypasses MCP.
438
+
439
+ ---
347
440
 
348
- ## Contributing
441
+ ## License
349
442
 
350
- Contributions are welcome. Please open a pull request with a clear description and include relevant tests.
443
+ [MIT](https://opensource.org/licenses/MIT)