@j0hanz/cortex-mcp 0.1.2 → 1.0.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,6 +1,6 @@
1
1
  # Cortex MCP
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/cortex-mcp?style=flat-square)](https://www.npmjs.com/package/cortex-mcp) [![Generic badge](https://img.shields.io/badge/Node.js->=24-3c873a?style=flat-square)](https://nodejs.org) [![Generic badge](https://img.shields.io/badge/TypeScript-5.9+-3178c6?style=flat-square)](https://www.typescriptlang.org) [![Generic badge](https://img.shields.io/badge/MCP_SDK-1.26+-ff6600?style=flat-square)](https://modelcontextprotocol.io) [![License](https://img.shields.io/badge/License-MIT-blue?style=flat-square)](LICENSE)
3
+ [![npm version](https://img.shields.io/npm/v/@j0hanz/cortex-mcp?style=flat-square)](https://www.npmjs.com/package/@j0hanz/cortex-mcp) [![Docker](https://img.shields.io/badge/Docker-ghcr.io-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/j0hanz/cortex-mcp/pkgs/container/cortex-mcp) [![Generic badge](https://img.shields.io/badge/Node.js->=24-3c873a?style=flat-square)](https://nodejs.org) [![Generic badge](https://img.shields.io/badge/TypeScript-5.9+-3178c6?style=flat-square)](https://www.typescriptlang.org) [![Generic badge](https://img.shields.io/badge/MCP_SDK-1.26+-ff6600?style=flat-square)](https://modelcontextprotocol.io) [![License](https://img.shields.io/badge/License-MIT-blue?style=flat-square)](LICENSE)
4
4
 
5
5
  [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](vscode:mcp/install?config=%7B%22name%22%3A%22cortex-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22cortex-mcp%40latest%22%5D%7D) [![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](vscode-insiders:mcp/install?config=%7B%22name%22%3A%22cortex-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22cortex-mcp%40latest%22%5D%7D) [![Install in Cursor](https://img.shields.io/badge/Cursor-Install-000000?style=flat-square&logo=cursor&logoColor=white)](https://cursor.com/install-mcp?name=cortex-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImNvcnRleC1tY3BAbGF0ZXN0Il19)
6
6
 
@@ -74,6 +74,13 @@ npx -y cortex-mcp@latest
74
74
  npx -y cortex-mcp@latest
75
75
  ```
76
76
 
77
+ ### Docker
78
+
79
+ ```bash
80
+ docker pull ghcr.io/j0hanz/cortex-mcp:latest
81
+ docker run --rm -i ghcr.io/j0hanz/cortex-mcp:latest
82
+ ```
83
+
77
84
  ### From Source
78
85
 
79
86
  ```bash
@@ -226,6 +233,22 @@ Add to your Cursor MCP settings:
226
233
 
227
234
  </details>
228
235
 
236
+ <details>
237
+ <summary><strong>Docker</strong></summary>
238
+
239
+ ```json
240
+ {
241
+ "mcpServers": {
242
+ "cortex-mcp": {
243
+ "command": "docker",
244
+ "args": ["run", "--rm", "-i", "ghcr.io/j0hanz/cortex-mcp:latest"]
245
+ }
246
+ }
247
+ }
248
+ ```
249
+
250
+ </details>
251
+
229
252
  ## Security
230
253
 
231
254
  - **Stdio Isolation**: The server writes all logs to `stderr` to avoid corrupting the JSON-RPC stream on `stdout`.
@@ -258,6 +281,75 @@ The project uses a custom task runner (`scripts/tasks.mjs`) for build orchestrat
258
281
  - **Build**: `npm run build` generates artifacts in `dist/`.
259
282
  - **Publish**: `npm run prepublishOnly` ensures linting, type-checking, and building before publish.
260
283
 
284
+ ### Automated Releases
285
+
286
+ Releases are fully automated via a single GitHub Actions workflow (`release.yml`). No manual version edits are needed.
287
+
288
+ **Trigger a release:**
289
+
290
+ ```bash
291
+ # Via GitHub CLI
292
+ gh workflow run release.yml -f bump=patch # or minor / major
293
+
294
+ # Custom pre-release version
295
+ gh workflow run release.yml -f custom_version=2.0.0-beta.1
296
+ ```
297
+
298
+ Or use the GitHub UI: **Actions** → **Release** → **Run workflow** → select bump type.
299
+
300
+ **What the workflow does:**
301
+
302
+ ```text
303
+ workflow_dispatch (patch/minor/major)
304
+
305
+
306
+ release ── bump versions → validate → commit → tag → GitHub Release
307
+
308
+ ├──► publish-npm ──► publish-mcp (sequential: MCP Registry needs npm package)
309
+
310
+ └──► publish-docker (parallel with npm)
311
+ ```
312
+
313
+ 1. **Bump** — Updates `package.json`, `package-lock.json`, and `server.json` atomically
314
+ 2. **Validate** — Runs lint, type-check, tests, and build
315
+ 3. **Tag & Release** — Commits, creates a git tag, and a GitHub Release with auto-generated notes
316
+ 4. **Publish to npm** — Uses OIDC Trusted Publishing (no `NPM_TOKEN` secret needed), with `--provenance` for signed SLSA attestations
317
+ 5. **Publish to MCP Registry** — Registers the new version via `mcp-publisher` with GitHub OIDC
318
+ 6. **Publish to Docker** — Builds and pushes a multi-platform image (`linux/amd64`, `linux/arm64`) to `ghcr.io/j0hanz/cortex-mcp`
319
+
320
+ ### Docker Image
321
+
322
+ The project includes a multi-stage `Dockerfile` optimized for MCP servers:
323
+
324
+ - **Builder stage**: Installs dependencies with `--ignore-scripts` (avoids `prepare` running before source is copied), rebuilds native modules, compiles TypeScript, then prunes dev dependencies
325
+ - **Release stage**: Minimal `node:24-alpine` image running as non-root `mcp` user
326
+
327
+ ```bash
328
+ # Build locally
329
+ docker build -t cortex-mcp .
330
+
331
+ # Run locally
332
+ docker run --rm -i cortex-mcp
333
+
334
+ # Or use docker-compose
335
+ docker compose up --build
336
+ ```
337
+
338
+ ### Verify a release
339
+
340
+ ```bash
341
+ # npm
342
+ npm view @j0hanz/cortex-mcp dist-tags
343
+
344
+ # Docker
345
+ docker pull ghcr.io/j0hanz/cortex-mcp:latest
346
+
347
+ # MCP protocol handshake
348
+ echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' \
349
+ | npx -y @j0hanz/cortex-mcp@latest 2>/dev/null \
350
+ | head -1 | jq .result.serverInfo
351
+ ```
352
+
261
353
  ## Troubleshooting
262
354
 
263
355
  - **No output**: The server uses `stdio`. Ensure your client is capturing `stdout` correctly. Check `stderr` for logs.
@@ -1,49 +1,49 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-width="1.2" stroke-linecap="round"
2
- stroke-linejoin="round" role="img" aria-label="brain">
3
- <style>
4
- path,
5
- circle,
6
- rect,
7
- line,
8
- polyline,
9
- polygon {
10
- stroke: #000000;
11
- }
12
-
13
- @media (prefers-color-scheme: dark) {
14
-
15
- path,
16
- circle,
17
- rect,
18
- line,
19
- polyline,
20
- polygon {
21
- stroke: #FFFFFF;
22
- }
23
- }
24
- </style>
25
-
26
- <g>
27
- <!-- Outer silhouette -->
28
- <path d="M9 4.2c-2.2 0-4 1.7-4 4v1.1c-1 .6-1.7 1.7-1.7 3 0 1.6 1 2.9 2.4 3.3v.9c0 2.2 1.8 4 4 4h2.3" />
29
- <path d="M15 4.2c2.2 0 4 1.7 4 4v1.1c1 .6 1.7 1.7 1.7 3 0 1.6-1 2.9-2.4 3.3v.9c0 2.2-1.8 4-4 4H12" />
30
-
31
- ```
32
- <!-- Midline split (subtle) -->
33
- <path d="M12 5.1v15.1" />
34
-
35
- <!-- Left hemisphere folds -->
36
- <path d="M8.8 7c-1.2.1-2.2 1.1-2.2 2.4" />
37
- <path d="M9.3 10.1c-1.4 0-2.6 1.1-2.6 2.6" />
38
- <path d="M9.6 13.4c-1.2.2-2.1 1.2-2.1 2.5" />
39
- <path d="M10.3 16.4c-1.1 0-2 .7-2.4 1.7" />
40
-
41
- <!-- Right hemisphere folds -->
42
- <path d="M15.2 7c1.2.1 2.2 1.1 2.2 2.4" />
43
- <path d="M14.7 10.1c1.4 0 2.6 1.1 2.6 2.6" />
44
- <path d="M14.4 13.4c1.2.2 2.1 1.2 2.1 2.5" />
45
- <path d="M13.7 16.4c1.1 0 2 .7 2.4 1.7" />
46
- ```
47
-
48
- </g>
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-width="1.2" stroke-linecap="round"
2
+ stroke-linejoin="round" role="img" aria-label="brain">
3
+ <style>
4
+ path,
5
+ circle,
6
+ rect,
7
+ line,
8
+ polyline,
9
+ polygon {
10
+ stroke: #000000;
11
+ }
12
+
13
+ @media (prefers-color-scheme: dark) {
14
+
15
+ path,
16
+ circle,
17
+ rect,
18
+ line,
19
+ polyline,
20
+ polygon {
21
+ stroke: #FFFFFF;
22
+ }
23
+ }
24
+ </style>
25
+
26
+ <g>
27
+ <!-- Outer silhouette -->
28
+ <path d="M9 4.2c-2.2 0-4 1.7-4 4v1.1c-1 .6-1.7 1.7-1.7 3 0 1.6 1 2.9 2.4 3.3v.9c0 2.2 1.8 4 4 4h2.3" />
29
+ <path d="M15 4.2c2.2 0 4 1.7 4 4v1.1c1 .6 1.7 1.7 1.7 3 0 1.6-1 2.9-2.4 3.3v.9c0 2.2-1.8 4-4 4H12" />
30
+
31
+ ```
32
+ <!-- Midline split (subtle) -->
33
+ <path d="M12 5.1v15.1" />
34
+
35
+ <!-- Left hemisphere folds -->
36
+ <path d="M8.8 7c-1.2.1-2.2 1.1-2.2 2.4" />
37
+ <path d="M9.3 10.1c-1.4 0-2.6 1.1-2.6 2.6" />
38
+ <path d="M9.6 13.4c-1.2.2-2.1 1.2-2.1 2.5" />
39
+ <path d="M10.3 16.4c-1.1 0-2 .7-2.4 1.7" />
40
+
41
+ <!-- Right hemisphere folds -->
42
+ <path d="M15.2 7c1.2.1 2.2 1.1 2.2 2.4" />
43
+ <path d="M14.7 10.1c1.4 0 2.6 1.1 2.6 2.6" />
44
+ <path d="M14.4 13.4c1.2.2 2.1 1.2 2.1 2.5" />
45
+ <path d="M13.7 16.4c1.1 0 2 .7 2.4 1.7" />
46
+ ```
47
+
48
+ </g>
49
49
  </svg>
package/dist/index.js CHANGED
File without changes
@@ -1,131 +1,131 @@
1
- # CORTEX-MCP INSTRUCTIONS
2
-
3
- These instructions are available as a resource (internal://instructions) or prompt (get-help). Load them when unsure about tool usage.
4
-
5
- ---
6
-
7
- ## CORE CAPABILITY
8
-
9
- - Domain: Multi-level reasoning engine that decomposes queries into structured thought chains at configurable depth levels (basic, normal, high).
10
- - Primary Resources: Reasoning sessions (in-memory, 30-minute TTL), thought chains, progress notifications.
11
- - Tools: `reasoning.think` (WRITE — creates/extends sessions with generated thoughts).
12
-
13
- ---
14
-
15
- ## PROMPTS
16
-
17
- - `get-help`: Returns these instructions for quick recall.
18
- - `reasoning.basic`: Prepare a basic-depth reasoning request (3–5 thoughts).
19
- - `reasoning.normal`: Prepare a normal-depth reasoning request (6–10 thoughts).
20
- - `reasoning.high`: Prepare a high-depth reasoning request (15–25 thoughts).
21
- - `reasoning.continue`: Continue an existing reasoning session with a follow-up query.
22
-
23
- ---
24
-
25
- ## RESOURCES & RESOURCE LINKS
26
-
27
- - `internal://instructions`: This document.
28
- - `reasoning://sessions`: List all active reasoning sessions with metadata (JSON).
29
- - `reasoning://sessions/{sessionId}`: Inspect a specific session's thoughts and metadata (JSON). Supports auto-completion on `sessionId`.
30
-
31
- ### Resource Subscriptions
32
-
33
- - The server supports `resources/subscribe` for real-time change notifications on individual resources.
34
- - Subscribe to `reasoning://sessions/{sessionId}` to receive `notifications/resources/updated` when thoughts are added or revised.
35
- - Use subscriptions to monitor session progress without polling.
36
-
37
- ---
38
-
39
- ## PROGRESS & TASKS
40
-
41
- - Include `_meta.progressToken` in requests to receive `notifications/progress` updates during reasoning.
42
- - Task-augmented tool calls are supported for `reasoning.think`:
43
- - `execution.taskSupport: "optional"` — invoke normally or as a task.
44
- - Send `tools/call` with `task` to get a task id.
45
- - Poll `tasks/get` and fetch results via `tasks/result`.
46
- - Use `tasks/cancel` to abort a running task.
47
- - For `high` level, progress is emitted every 2 steps to reduce noise; `basic` and `normal` emit after every step.
48
-
49
- ---
50
-
51
- ## THE "GOLDEN PATH" WORKFLOWS (CRITICAL)
52
-
53
- ### WORKFLOW A: Sequential Reasoning
54
-
55
- 1. Call `reasoning.think` with `{ query: "...", level: "basic" | "normal" | "high" }`.
56
- 2. Read `result.thoughts` for the accumulated reasoning chain (each call appends at most one new thought).
57
- 3. Repeat calls with the same `sessionId` until `result.totalThoughts` is reached.
58
- NOTE: Choose level based on query complexity — `basic` for straightforward questions, `high` for multi-faceted analysis.
59
-
60
- ### WORKFLOW B: Multi-Turn Reasoning (Session Continuation)
61
-
62
- 1. Call `reasoning.think` with `{ query: "initial question", level: "normal" }` — note the returned `sessionId`.
63
- 2. Call `reasoning.think` with `{ query: "follow-up", level: "normal", sessionId: "<id>" }` to append the next thought.
64
- 3. Repeat until `result.totalThoughts` is reached, then read `reasoning://sessions/{sessionId}` for the full chain.
65
- NOTE: The `level` MUST match the original session level. Mismatches return `E_SESSION_LEVEL_MISMATCH`.
66
-
67
- ### WORKFLOW C: Controlled Depth Reasoning
68
-
69
- 1. Call `reasoning.think` with `{ query: "...", level: "normal", targetThoughts: 8 }` to set the session's planned step count.
70
- 2. Repeat calls with the returned `sessionId` until `result.totalThoughts` is reached.
71
- NOTE: `targetThoughts` must fall within the level range (basic: 3–5, normal: 6–10, high: 15–25). Out-of-range values return `E_INVALID_THOUGHT_COUNT`.
72
-
73
- ### WORKFLOW D: Async Task Execution
74
-
75
- 1. Call `reasoning.think` as a task (send `tools/call` with `task` field) for long-running `high`-level reasoning.
76
- 2. Poll `tasks/get` until status is `completed` or `failed`.
77
- 3. Retrieve the result via `tasks/result`.
78
- 4. Use `tasks/cancel` to abort if needed.
79
-
80
- ---
81
-
82
- ## TOOL NUANCES & GOTCHAS
83
-
84
- `reasoning.think`
85
-
86
- - Purpose: Generate a multi-step reasoning chain for a given query at a specified depth level.
87
- - Input:
88
- - `query` (string, 1–10,000 chars): The question or problem to reason about.
89
- - `level` (enum: `basic` | `normal` | `high`): Controls reasoning depth and token budget.
90
- - `targetThoughts` (int, 1–25, optional): Override automatic step count. Must fit within the level range.
91
- - `sessionId` (string, 1–128 chars, optional): Continue an existing session. Level must match.
92
- - Output: `{ ok, result: { sessionId, level, thoughts[], generatedThoughts, requestedThoughts, totalThoughts, tokenBudget, tokensUsed, ttlMs, expiresAt, createdAt, updatedAt, summary } }`
93
- - Side effects: Creates or modifies an in-memory session. Sessions expire after 30 minutes of inactivity.
94
- - Gotcha: Each call appends at most one thought. When continuing a session, `generatedThoughts` reflects only the newly added thought (0 or 1), not the cumulative total.
95
- - Gotcha: `requestedThoughts` is the effective requested count for this run: it equals `targetThoughts` when provided, otherwise `totalThoughts`.
96
- - Gotcha: Token counting is approximate (UTF-8 byte length ÷ 4), not true tokenization.
97
- - Gotcha: Without `targetThoughts`, the planned step count (`totalThoughts`) is determined by a heuristic based on query length and structural complexity (punctuation markers, keywords like "compare", "analyse", "trade-off").
98
- - Limits: Level ranges — basic: 3–5 thoughts (2K token budget), normal: 6–10 (8K), high: 15–25 (32K).
99
-
100
- ---
101
-
102
- ## CROSS-FEATURE RELATIONSHIPS
103
-
104
- - Use `reasoning.basic` / `reasoning.normal` / `reasoning.high` prompts to construct a correctly parameterized `reasoning.think` call.
105
- - Use `reasoning.continue` prompt to construct a session-continuation call — it enforces `sessionId` and `level` pairing.
106
- - After calling `reasoning.think`, read `reasoning://sessions/{sessionId}` to retrieve the full session state including all accumulated thoughts.
107
- - Use `reasoning://sessions` to discover active sessions before attempting continuation — avoids `E_SESSION_NOT_FOUND`.
108
-
109
- ---
110
-
111
- ## CONSTRAINTS & LIMITATIONS
112
-
113
- - Sessions are in-memory — all data is lost on process restart.
114
- - Session TTL: 30 minutes from last update. Expired sessions cannot be recovered.
115
- - Maximum query length: 10,000 characters.
116
- - Token budget enforcement is approximate (character-based proxy, not true tokenization).
117
- - stdio transport only — no HTTP endpoint available.
118
- - Reasoning steps are structural decompositions, not LLM-generated content.
119
- - `targetThoughts` must be an integer within the level's min/max range.
120
-
121
- ---
122
-
123
- ## ERROR HANDLING STRATEGY
124
-
125
- - `E_SESSION_NOT_FOUND`: Session expired or never existed. Call `reasoning://sessions` to list active sessions, or start a new session without `sessionId`.
126
- - `E_SESSION_LEVEL_MISMATCH`: Requested level differs from the existing session. Use the same level as the original session, or start a new session.
127
- - `E_INVALID_THOUGHT_COUNT`: `targetThoughts` is outside the level range. Check ranges: basic (3–5), normal (6–10), high (15–25).
128
- - `E_ABORTED`: Reasoning was cancelled via abort signal or task cancellation. Retry with a new request if needed.
129
- - `E_REASONING`: Unexpected engine error. Check the error `message` field for details and retry.
130
-
131
- ---
1
+ # CORTEX-MCP INSTRUCTIONS
2
+
3
+ These instructions are available as a resource (internal://instructions) or prompt (get-help). Load them when unsure about tool usage.
4
+
5
+ ---
6
+
7
+ ## CORE CAPABILITY
8
+
9
+ - Domain: Multi-level reasoning engine that decomposes queries into structured thought chains at configurable depth levels (basic, normal, high).
10
+ - Primary Resources: Reasoning sessions (in-memory, 30-minute TTL), thought chains, progress notifications.
11
+ - Tools: `reasoning.think` (WRITE — creates/extends sessions with generated thoughts).
12
+
13
+ ---
14
+
15
+ ## PROMPTS
16
+
17
+ - `get-help`: Returns these instructions for quick recall.
18
+ - `reasoning.basic`: Prepare a basic-depth reasoning request (3–5 thoughts).
19
+ - `reasoning.normal`: Prepare a normal-depth reasoning request (6–10 thoughts).
20
+ - `reasoning.high`: Prepare a high-depth reasoning request (15–25 thoughts).
21
+ - `reasoning.continue`: Continue an existing reasoning session with a follow-up query.
22
+
23
+ ---
24
+
25
+ ## RESOURCES & RESOURCE LINKS
26
+
27
+ - `internal://instructions`: This document.
28
+ - `reasoning://sessions`: List all active reasoning sessions with metadata (JSON).
29
+ - `reasoning://sessions/{sessionId}`: Inspect a specific session's thoughts and metadata (JSON). Supports auto-completion on `sessionId`.
30
+
31
+ ### Resource Subscriptions
32
+
33
+ - The server supports `resources/subscribe` for real-time change notifications on individual resources.
34
+ - Subscribe to `reasoning://sessions/{sessionId}` to receive `notifications/resources/updated` when thoughts are added or revised.
35
+ - Use subscriptions to monitor session progress without polling.
36
+
37
+ ---
38
+
39
+ ## PROGRESS & TASKS
40
+
41
+ - Include `_meta.progressToken` in requests to receive `notifications/progress` updates during reasoning.
42
+ - Task-augmented tool calls are supported for `reasoning.think`:
43
+ - `execution.taskSupport: "optional"` — invoke normally or as a task.
44
+ - Send `tools/call` with `task` to get a task id.
45
+ - Poll `tasks/get` and fetch results via `tasks/result`.
46
+ - Use `tasks/cancel` to abort a running task.
47
+ - For `high` level, progress is emitted every 2 steps to reduce noise; `basic` and `normal` emit after every step.
48
+
49
+ ---
50
+
51
+ ## THE "GOLDEN PATH" WORKFLOWS (CRITICAL)
52
+
53
+ ### WORKFLOW A: Sequential Reasoning
54
+
55
+ 1. Call `reasoning.think` with `{ query: "...", level: "basic" | "normal" | "high" }`.
56
+ 2. Read `result.thoughts` for the accumulated reasoning chain (each call appends at most one new thought).
57
+ 3. Repeat calls with the same `sessionId` until `result.totalThoughts` is reached.
58
+ NOTE: Choose level based on query complexity — `basic` for straightforward questions, `high` for multi-faceted analysis.
59
+
60
+ ### WORKFLOW B: Multi-Turn Reasoning (Session Continuation)
61
+
62
+ 1. Call `reasoning.think` with `{ query: "initial question", level: "normal" }` — note the returned `sessionId`.
63
+ 2. Call `reasoning.think` with `{ query: "follow-up", level: "normal", sessionId: "<id>" }` to append the next thought.
64
+ 3. Repeat until `result.totalThoughts` is reached, then read `reasoning://sessions/{sessionId}` for the full chain.
65
+ NOTE: The `level` MUST match the original session level. Mismatches return `E_SESSION_LEVEL_MISMATCH`.
66
+
67
+ ### WORKFLOW C: Controlled Depth Reasoning
68
+
69
+ 1. Call `reasoning.think` with `{ query: "...", level: "normal", targetThoughts: 8 }` to set the session's planned step count.
70
+ 2. Repeat calls with the returned `sessionId` until `result.totalThoughts` is reached.
71
+ NOTE: `targetThoughts` must fall within the level range (basic: 3–5, normal: 6–10, high: 15–25). Out-of-range values return `E_INVALID_THOUGHT_COUNT`.
72
+
73
+ ### WORKFLOW D: Async Task Execution
74
+
75
+ 1. Call `reasoning.think` as a task (send `tools/call` with `task` field) for long-running `high`-level reasoning.
76
+ 2. Poll `tasks/get` until status is `completed` or `failed`.
77
+ 3. Retrieve the result via `tasks/result`.
78
+ 4. Use `tasks/cancel` to abort if needed.
79
+
80
+ ---
81
+
82
+ ## TOOL NUANCES & GOTCHAS
83
+
84
+ `reasoning.think`
85
+
86
+ - Purpose: Generate a multi-step reasoning chain for a given query at a specified depth level.
87
+ - Input:
88
+ - `query` (string, 1–10,000 chars): The question or problem to reason about.
89
+ - `level` (enum: `basic` | `normal` | `high`): Controls reasoning depth and token budget.
90
+ - `targetThoughts` (int, 1–25, optional): Override automatic step count. Must fit within the level range.
91
+ - `sessionId` (string, 1–128 chars, optional): Continue an existing session. Level must match.
92
+ - Output: `{ ok, result: { sessionId, level, thoughts[], generatedThoughts, requestedThoughts, totalThoughts, tokenBudget, tokensUsed, ttlMs, expiresAt, createdAt, updatedAt, summary } }`
93
+ - Side effects: Creates or modifies an in-memory session. Sessions expire after 30 minutes of inactivity.
94
+ - Gotcha: Each call appends at most one thought. When continuing a session, `generatedThoughts` reflects only the newly added thought (0 or 1), not the cumulative total.
95
+ - Gotcha: `requestedThoughts` is the effective requested count for this run: it equals `targetThoughts` when provided, otherwise `totalThoughts`.
96
+ - Gotcha: Token counting is approximate (UTF-8 byte length ÷ 4), not true tokenization.
97
+ - Gotcha: Without `targetThoughts`, the planned step count (`totalThoughts`) is determined by a heuristic based on query length and structural complexity (punctuation markers, keywords like "compare", "analyse", "trade-off").
98
+ - Limits: Level ranges — basic: 3–5 thoughts (2K token budget), normal: 6–10 (8K), high: 15–25 (32K).
99
+
100
+ ---
101
+
102
+ ## CROSS-FEATURE RELATIONSHIPS
103
+
104
+ - Use `reasoning.basic` / `reasoning.normal` / `reasoning.high` prompts to construct a correctly parameterized `reasoning.think` call.
105
+ - Use `reasoning.continue` prompt to construct a session-continuation call — it enforces `sessionId` and `level` pairing.
106
+ - After calling `reasoning.think`, read `reasoning://sessions/{sessionId}` to retrieve the full session state including all accumulated thoughts.
107
+ - Use `reasoning://sessions` to discover active sessions before attempting continuation — avoids `E_SESSION_NOT_FOUND`.
108
+
109
+ ---
110
+
111
+ ## CONSTRAINTS & LIMITATIONS
112
+
113
+ - Sessions are in-memory — all data is lost on process restart.
114
+ - Session TTL: 30 minutes from last update. Expired sessions cannot be recovered.
115
+ - Maximum query length: 10,000 characters.
116
+ - Token budget enforcement is approximate (character-based proxy, not true tokenization).
117
+ - stdio transport only — no HTTP endpoint available.
118
+ - Reasoning steps are structural decompositions, not LLM-generated content.
119
+ - `targetThoughts` must be an integer within the level's min/max range.
120
+
121
+ ---
122
+
123
+ ## ERROR HANDLING STRATEGY
124
+
125
+ - `E_SESSION_NOT_FOUND`: Session expired or never existed. Call `reasoning://sessions` to list active sessions, or start a new session without `sessionId`.
126
+ - `E_SESSION_LEVEL_MISMATCH`: Requested level differs from the existing session. Use the same level as the original session, or start a new session.
127
+ - `E_INVALID_THOUGHT_COUNT`: `targetThoughts` is outside the level range. Check ranges: basic (3–5), normal (6–10), high (15–25).
128
+ - `E_ABORTED`: Reasoning was cancelled via abort signal or task cancellation. Retry with a new request if needed.
129
+ - `E_REASONING`: Unexpected engine error. Check the error `message` field for details and retry.
130
+
131
+ ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@j0hanz/cortex-mcp",
3
- "version": "0.1.2",
3
+ "version": "1.0.0",
4
4
  "mcpName": "io.github.j0hanz/cortex-mcp",
5
5
  "author": "Johanz",
6
6
  "license": "MIT",