Multi-level reasoning MCP server with configurable depth levels
A multi-level reasoning Model Context Protocol (MCP) server with configurable depth levels. This server provides advanced model-context processing capabilities, enabling structured reasoning across multiple depth levels and flexible configuration.
🛠️ Key Features
Multi-level reasoning MCP server with configurable depth levels
Model-context protocol oriented for dynamic thought structuring
Multi-level reasoning MCP server with configurable depth levels, session-based state management, structured thought input, and real-time trace resources.
Overview
Cortex MCP is a stdio-only MCP server for stateful, depth-controlled reasoning. The runtime entrypoint in src/index.ts connects createServer() to StdioServerTransport, and the server surface in src/server.ts enables tools, prompts, completions, logging, and subscribable resources around a single session-based reasoning engine.
The live MCP surface confirmed by Inspector is 1 tool, 6 concrete resources, 4 resource templates, and 7 prompts. Sessions are stored in memory, exposed as MCP resources, and cleared on process restart.
Key Features
reasoning_think supports step-by-step sessions, run_to_completion batches, rollback, early conclusion, and structured observation / hypothesis / evaluation input.
Four depth levels are built into the engine: basic, normal, high, and expert, each with bounded thought ranges and token budgets.
Use reasoning.basic, reasoning.normal, reasoning.high, or reasoning.expert when the client wants a prompt-first entrypoint, or call reasoning_think directly with query, level, and the first thought. Each response returns the current session state plus a summary string that tells the client how to continue.
Relevant tool: reasoning_think
Related prompts: reasoning.basic, reasoning.normal, reasoning.high, reasoning.expert
Continue, retry, or batch an active session
Reuse sessionId to continue a prior trace, switch to runMode="run_to_completion" when you already have the remaining thought inputs, or use the continuation and retry prompts to generate the next call payload. The handler also supports rollbackToStep and isConclusion for revising or ending a trace early.
Relevant tool: reasoning_think
Related prompts: reasoning.continue, reasoning.retry
Inspect live traces without re-running the tool
Read reasoning://sessions for the active session list, reasoning://sessions/{sessionId} for the JSON detail view, reasoning://sessions/{sessionId}/trace for the markdown transcript, or reasoning://sessions/{sessionId}/thoughts/{thoughtName} for a single thought. This lets a client present progress or audit a session independently from the next tool call.
Stateful reasoning tool for creating and continuing multi-step sessions. It supports one-step interactive calls, run_to_completion batches, structured observation/hypothesis/evaluation input, rollback, and early conclusion while returning structured session state.
Parameter
Type
Required
Description
query
string
no
Question or problem to analyze.
level
string
no
Depth level. Required for new sessions. basic (1–3 steps, 2K budget), normal (4–8 steps, 8K budget), high (10–15 steps, 32K budget), expert (20–25 steps, 128K budget).
targetThoughts
integer
no
Exact step count. Must fit level range.
sessionId
string
no
Session ID to continue.
runMode
string
no
"step" (default) or "run_to_completion".
thought
any
no
Reasoning text. Stored verbatim. String for step mode, string[] for batch.
isConclusion
boolean
no
End session early at final answer.
rollbackToStep
integer
no
0-based index to rollback to. Discards later thoughts.
reasoning_think declares outputSchema and returns structuredContent, with an embedded trace resource when the trace is small enough. Evidence: src/tools/reasoning-think.ts:498, src/lib/mcp.ts:97-114.
The source does not define any HTTP host/port configuration. The only other environment-related signal is NODE_ENV=production in the Docker image and --env-file=.env in the local dev:run script.
Run the fast direct test command without the task wrapper.
format
prettier --write .
Format the repository.
inspector
npm run build && npx -y @modelcontextprotocol/inspector node dist/index.js
Build the server and open it in the MCP Inspector.
prepublishOnly
npm run lint && npm run type-check && npm run build
Enforce release checks before publishing.
Additional helper scripts for diagnostics, coverage, asset copying, and knip are defined in package.json.
Build and Release
.github/workflows/release.yml bumps package.json and server.json, then runs npm run lint, npm run type-check, npm run test, and npm run build before tagging and creating a GitHub release.
The same workflow publishes the package to npm with Trusted Publishing, publishes to the MCP Registry with mcp-publisher, and pushes a multi-arch Docker image to ghcr.io.
Dockerfile uses a multi-stage Node 24 Alpine build, prunes dev dependencies, and runs the released container as the mcp user.
Troubleshooting
Sessions are in memory and expire after 30 minutes by default. If you receive E_SESSION_NOT_FOUND, start a new session or increase CORTEX_SESSION_TTL_MS.
runMode="run_to_completion" requires enough thought entries to cover the remaining steps. If you want the server to return after each step, keep the default step mode.
For stdio transport, do not add custom stdout logging around the server process. This server routes logs through MCP logging and falls back to stderr on failures.