deep-think-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@deep-think-mcp think through the pros and cons of remote work"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
The Problem
Ask a capable model a hard question and it will often produce a fluent answer that sounds reasoned but skipped the hard parts — it assumed something it never checked, leaned on a weak analogy, ignored a stakeholder, or committed to the first framing that came to mind. The usual fixes ("think step by step," "critique your answer") work unevenly and leave nothing behind: the reasoning evaporates with the context window.
Three concrete gaps:
Reasoning is ephemeral. Once the conversation scrolls away, the chain of thought is gone. You can't revisit why a conclusion was reached, or resume a half-finished analysis tomorrow.
Self-critique is unstructured. "Critique yourself" gives a model too much latitude — it critiques what's easiest, not what's load-bearing. Nothing guarantees it stress-tests its evidence, its assumptions, and its blind spots in turn.
Local models make both worse. A 7B/8B model asked to run a multi-step reasoning protocol and remember where it is in that protocol and emit clean JSON at each step will drop one of those balls.
Related MCP server: crash-mcp
The Solution
deep-think-mcp is an MCP server that externalizes the reasoning protocol into a state machine the server runs on the model's behalf. A problem is worked in explicit stages (Problem Definition → Research → Analysis → Synthesis → Conclusion), and within each stage the model either sharpens one line of reasoning through rounds of structured self-critique, or spins up competing specialist perspectives that are scored and converged. Every intermediate step is scored on a shared 7-dimension utility matrix and saved to disk.
Because it targets local models — small context, weak instruction-following, no reliable JSON mode — every tool response is short, flat, and directive: it tells the model exactly which tool to call next. A single tool, next_action, answers "what do I do now?" from any state, so the model never has to hold the protocol in its head.
┌─ Problem Definition ─┐ ┌─ Analysis ─┐ ┌─ Synthesis ─┐ ┌─ Conclusion ─┐
│ draft ─▶ critique │ │ specialist │ │ specialist │ │ commit ─▶ │
│ ─▶ refine ─▶ score │ ▶ │ candidates │ ▶ │ candidates │ ▶ │ finalize ─▶ │
│ ─▶ (converged?) ─▶ │ │ ─▶ score │ │ ─▶ score │ │ move/keep │
│ commit │ │ ─▶ winner │ │ ─▶ winner │ │ │
└──────────────────────┘ └─────────────┘ └─────────────┘ └──────────────┘
every step scored, persisted to disk, and resumableFeatures
Two reasoning modes, one schema
Every session picks serial (one line of reasoning, sharpened by rotating critique lenses) or subagent (competing specialist perspectives, scored and converged) — fixed for the life of the session. Both emit the same stage machine, thoughts, and 7-dim utility scores, so you can run a question through both and compare.
Structured self-critique
Serial mode ships 8 bundled critique lenses — overconfidence, weak_evidence, missing_perspective, unstated_assumption, scope_creep, alternative_framing, steel_man, first_principles — each a directive prompt that hunts one specific failure mode. Drop your own .md lenses in to add or override by name.
Persistent by default
One JSON file per session, written under a Portalocker lock with a crash-safe .bak protocol, tracked in a central index. Finalize prompts you to move the artifact anywhere (a project folder, a synced drive) and it stays fully resumable there.
Built for weak models
Flat tool signatures, short directive responses, and next_action as an authoritative "what next?" resolver. Every input is accepted as JSON or tolerant plaintext (scores="correctness: 0.8, clarity: 0.7"). Nothing ever raises a traceback — failures return a retry_with_clarification directive naming the fix.
Local-first, offline-capable
Serial mode and the endpoint-free manual subagent engine need no GPU, no API key, and no network. Point the optional engines at any OpenAI-compatible endpoint (Ollama, llama.cpp, vLLM) only if you want to.
Honest hybrid engine
Subagent mode has two engines: necort drives a vendored Nash-equilibrium core against an endpoint; manual is endpoint-free, where the calling model plays each specialist and self-scores all 7 dimensions for real. (See the honest NECoRT story — most of the upstream PR turned out to be filler.)
Quick Start
Requires Python ≥ 3.11 and uv. The vendored NECoRT core is a git submodule, so clone recursively:
git clone --recurse-submodules <this-repo-url> deep-think-mcp
cd deep-think-mcp
uv sync # core deps; add --extra autopilot for the optional autopilot feature
uv run pytest # confirm a healthy install (tests never touch your real home dir)(Already cloned without submodules? git submodule update --init. The submodule is only needed for [subagent] engine = "necort"; everything else works without it.)
Launch the stdio server:
uv run python -m deep_think_mcp.serverThis is a dev-checkout tool — it reads config/default.toml from the repo root, so every client config points --directory at your clone (see docs/wiring.md).
Drive a serial session (every response carries a message and a next_tool — when unsure, call next_action(session_id)):
start_session(question="Should we cache API responses at the edge or origin?")
→ { "mode_required": true, "next_tool": "set_session_mode", "session_id": "…" }
set_session_mode(session_id, mode="serial")
begin_thought(session_id, content="Cache at the edge: lower latency for users…")
critique_current_thought(session_id) # server picks a stage-appropriate lens
→ { "lens": "weak_evidence", "draft_content": "…", "lens_template": "…", "next_tool": "submit_critique" }
submit_critique(session_id, text="No numbers back the latency claim…")
refine_current_thought(session_id, new_content="Cache at the edge (CDN PoPs) when…")
score_current_thought(session_id, scores="correctness: 0.8, clarity: 0.8, evidence: 0.7, …")
→ { "converged": false, "next_tool": "critique_current_thought" } # loop until converged or max_rounds
commit_thought(session_id)
advance_stage(session_id) # … repeat through the stages …
finalize_session(session_id) # → prompts you to move or keep the saved artifactNew here?
docs/GUIDE.mdis a complete, self-contained teaching document — the concepts, the architecture, both modes in depth, every tool and config key, and how to extend the system. This README is the map; the guide is the tutorial.
The Two Modes
A session's mode is chosen once at creation and is immutable — to use the other mode, start a new session. Creating a session without a mode returns a mode_required directive rather than silently defaulting, forcing the choice to surface.
Serial — one line of reasoning, critiqued
Within a stage, a thought cycles begin → critique → submit → refine → score and repeats with a new lens until it converges. Four convergence rules are checked in precedence order:
fixed_point— the refinement barely changed the text (normalized edit distance< edit_distance_epsilon, default0.05).diminishing_returns— two rounds in a row each improved the score by< score_threshold(default0.05).max_rounds— the round cap (default3) is hit.Otherwise keep going with the next lens.
Natural convergence outranks the ceiling, so you learn why it stopped. Lenses rotate through stage-appropriate defaults first (e.g. Analysis → weak_evidence, overconfidence), then the rest of the library.
Subagent — competing perspectives, converged
Specialists (default roster: Analysis, Creativity, Skeptic) propose competing candidates scored on the 7-dim matrix; the strongest wins. Two engines, same four tools (begin_subagent_thought, advance_subagent_round, inspect_utility_matrix, commit_subagent_thought):
|
| |
Needs an endpoint? | No — fully local & offline | Yes — any OpenAI-compatible |
Who plays the specialists? | The calling model itself | The vendored Nash core |
Utility scoring | All 7 dims, real self-scores | 3 dims real ( |
Commit gate | 7-dim mean ≥ | winner's |
Selection | highest mean wins, ties → earliest | Nash equilibrium |
With engine = "necort" but no endpoint configured (the shipped default), begin_subagent_thought doesn't fail opaquely — it returns a directive pointing at the endpoint-free manual path.
The honest NECoRT story
The original design imagined subagent mode as a full port of PhialsBasement/Chain-of-Recursive-Thoughts PR #7 — specialist agents, a native 7-dim utility matrix, bias detection, continuous learning. A code recon during the build found that most of that PR is disconnected filler: the files advertising those features are never imported, make zero LLM calls, and several aren't even valid Python. The one part that works is NashEquilibriumRecursiveChat. So this project vendors PR #7 in full (a faithful, re-pinnable submodule mirror) but imports only those two working files, wrapped by a single adapter (necort_adapter.py) that shims a real crash, a hardcoded endpoint, and a stdout-corrupts-the-transport bug — without editing a vendored line. Because a single blended Nash rating can honestly inform only 3 of 7 dimensions, genuine multi-perspective diversity comes from the second, from-scratch manual engine instead. The lesson is baked in: verify third-party code against reality before building on its advertised behavior.
Data & the Finalize/Move Lifecycle
Everything lives under one data root, ~/deep-think-mcp/ by default (override with DEEP_THINK_HOME):
~/deep-think-mcp/
├── config.toml seeded from config/default.toml on first use; edit freely
├── index.json session_id → { path, mode, status, created_at, updated_at }
├── sessions/ one JSON file per session
├── lenses/ optional: drop-in .md critique lenses (override by name)
└── logs/ reserved directory (unused in v1)finalize_session returns a human_prompt offering to relocate the artifact; move_session moves it atomically (write → verify → unlink, won't clobber without force) and keep_here records the decline. Sessions moved outside the root stay fully functional — list_sessions / resume_session find them via the index's absolute paths, and move_history tracks every hop.
Configuration
Layered, lowest to highest precedence: packaged defaults (config/default.toml) → user config (<root>/config.toml, seeded on first use) → per-session overrides (start_session(overrides={…})). Key settings:
Section | Key | Default | Notes |
|
|
| Overridden by |
|
|
| The convergence knobs. |
|
| the 8 bundled lens names | Rotation order after stage defaults. |
|
|
|
|
|
|
| Round cap and commit gate. |
|
|
| Specialist roster. |
|
|
| NECoRT engine target. Empty endpoint → the manual-path directive. |
|
|
| Per-session overridable via |
|
|
| Off by default; when off, no network code path is reachable. |
The full table with every key lives in docs/GUIDE.md.
Tolerant input. Every structured parameter accepts JSON or plaintext (tags="a, b, c", scores="correctness: 0.8, clarity: 0.7"). Unparseable input returns a retry_with_clarification payload naming the parameter, expected shape, and an example — never a raw error.
Autopilot (optional). With [autopilot].enabled = true (and uv sync --extra autopilot), two extra tools let the server drive a whole stage internally against a configured endpoint, stopping cleanly with a resumable partial-progress directive on any fault. Off by default, it imports zero networking code.
Tool Surface
25 tools always registered; 27 with autopilot enabled. All responses are flat objects with a message and usually a next_tool.
Group | Tools |
Session lifecycle |
|
Stage cursor |
|
Serial loop |
|
Subagent loop |
|
Meta / guidance / I-O |
|
Autopilot (when enabled) |
|
Full signatures, return fields, and every directive/error code are in docs/GUIDE.md.
Wiring Into an MCP Client
Copy-pasteable config for Claude Desktop, Claude Code, Cursor, Continue, and LibreChat is in docs/wiring.md. The mcpServers-style shape:
{
"mcpServers": {
"deep-think": {
"command": "uv",
"args": ["--directory", "/absolute/path/to/deep-think-mcp", "run", "python", "-m", "deep_think_mcp.server"],
"env": { "DEEP_THINK_HOME": "/absolute/path/to/your/data-root" }
}
}
}Sharing one server between clients (or tools keep vanishing from a long-lived host)? You can instead run deep-think as a single always-live Streamable HTTP daemon that multiple clients reach over a URL (
http://127.0.0.1:8182/mcp) rather than each spawning its own stdio process. This is also the fix when an agent host intermittently drops the tools from its cached schema. Seedocs/http-transport.md.
Documentation
Document | What it is |
The complete teaching guide — concepts, architecture, both modes in depth, full tool/config/directive/data-model references, extension, FAQ, glossary. | |
Exact client config for Claude Desktop, Claude Code, Cursor, Continue, LibreChat. | |
Running as a Streamable HTTP daemon — one always-live server shared by multiple clients (e.g. an agent host + a DAG), the systemd unit, security posture, and the fix for hosts that drop stdio tools from a cached schema. | |
Agent-runnable A/B/C test — does driving a model through the tool beat answering directly? Self-contained prompt, rubric, judge instructions, and report template. | |
The original design document (the "why" behind the architecture). | |
The task-by-task build breakdown with global constraints. | |
Why | |
How to re-pin the vendored NECoRT submodule. |
Architecture
The system is layered: a dispatch layer (server.py) that registers the tools, gates wrong-mode calls, parses tolerant input, and turns storage faults into directives; the engines (serial_engine, subagent_engine, manual_engine, necort_adapter, optional autopilot) that do the thinking; and a domain + persistence layer (session, stages, lens_loader, store, index, lifecycle, config, prompts, tolerant). Two invariants hold the design together: all model-facing wording lives in prompts.py, and necort_adapter.py is the only file that imports vendored code — the entire third-party surface is quarantined behind one boundary. Full diagram in the guide.
Testing
uv run pytest # full suite (423 tests)
uv run pytest -q -W error # the CI bar: pristine, warnings are errorsThe suite drives the real MCP SDK's in-memory client against the real server for every tool contract, plus one subprocess test that speaks real stdio MCP to the launched server. Every test injects a tmp_path data root, so running the suite never touches your real home directory.
How it was built. Implemented task-by-task with a fresh-implementer → adversarial spec+quality review → fix-loop discipline, closed out by a whole-branch multi-lens review with adversarial verification of every finding (including two real security fixes: import path traversal and credential exfiltration). Design docs are docs/build-plan.md and docs/execution-plan.md.
Benchmarks
Not yet run. A head-to-head of serial vs. subagent on three canonical prompts is planned but requires blind human rating to be meaningful, and is deliberately deferred rather than shipped as a self-graded number.
License
MIT — see LICENSE. This project vendors third-party source code (vendor/necort/, a git submodule of PhialsBasement/Chain-of-Recursive-Thoughts PR #7) under its own MIT license; see LICENSE-NOTICES for full attribution.
Available Tools
25 toolsadvance_stageA
Advance the session's stage cursor to the next stage in its
expected_stages. Fails cleanly with a directive payload pointing
at finalize_session if the session is already at its final
stage -- there is nowhere further to advance to.
Inputs: session_id (required). Returns: object
advance_subagent_roundA
Advance the subagent thought by one step.
`engine="necort"`: runs the next Nash round, re-seeding the current
best candidate (`candidate`/`scores` are ignored). `engine="manual"`
(T13): records the current specialist's `candidate` + 7-dim `scores`
(tolerant input -- JSON or "correctness: 0.8, ..." text) and hands the
next specialist's prompt, or -- when the roster is exhausted -- runs
the deterministic selection and returns the round result. Calling with
no `candidate` at a round boundary (re)starts the next round's first
specialist. The round budget (`subagent.max_rounds`) is enforced here.
Inputs: session_id (required), scores, candidate. Returns: object
begin_subagent_thoughtC
Start a subagent thought. With engine="necort" this runs the first
Nash equilibrium round via the vendored core over the configured
specialist framings (needs an endpoint; when none is configured it
points at the manual path). With engine="manual" (T13) this hands
back specialist #1's prompt for the calling model to voice itself --
no endpoint, no network, no NECoRT code. Fails with a directive if a
thought is already in progress.
Inputs: session_id (required), content, prompt_focus. Returns: object
begin_thoughtA
Draft a new thought in the session's current stage. Fails with a
directive if a thought is already in progress (commit it first).
tags/axioms accept a JSON array or a comma/newline list.
Inputs: content (required), session_id (required), tags, axioms. Returns: object
clear_sessionB
Wipe a session: deletes its file and removes it from the index.
Inputs: session_id (required). Returns: object
commit_subagent_thoughtA
Accept the current equilibrium: lock the winning candidate as the thought's content and clear the current-thought cursor. Fails with a directive if no Nash round has run yet.
Inputs: session_id (required). Returns: object
commit_thoughtB
Lock the current thought (writing its final refined content back as the thought's content) and clear the current-thought cursor. Fails with a directive if no critique round has completed yet.
Inputs: session_id (required). Returns: object
compress_historyA
Deterministic extractive digest of prior stages' committed
thoughts, capped at target_tokens (a cheap len(text)//4 heuristic
-- no tokenizer dependency). The current stage is left out; its
detail is already visible via the live loop tools/
summarize_session. For small-context local models that can't
hold a whole session's history.
Inputs: session_id (required), target_tokens. Returns: object
critique_current_thoughtB
Open a critique round and return the lens template to apply. Omit
lens to let the server pick a stage-appropriate one and rotate
through the library. The response places the current draft content
immediately before the lens template (adjacency contract).
Inputs: session_id (required), lens. Returns: object
export_sessionA
Return this session's complete state as a JSON-serializable
dict, suitable for handing straight to import_session.
Inputs: session_id (required). Returns: object
finalize_sessionB
Mark a session finalized. Returns the finalize+move payload:
where the session is saved, the canned human_prompt asking whether
to move it, and the two tools (move_session, keep_here) that
answer that question.
Inputs: session_id (required). Returns: object
import_sessionA
Recreate a session from a previous export_session payload (a
dict, or its JSON string form). Validated on the way in. If the
imported session's id collides with one already on this install, a
fresh id (and save path) is assigned automatically rather than
overwriting the existing session -- collision-safe import.
Inputs: data (required). Returns: object
inspect_utility_matrixA
Return the current Nash scoring state: the latest round's per-candidate utility vectors, equilibrium states, and selected winner. Read-only (no engine mutation, no network).
Inputs: session_id (required). Returns: object
keep_hereA
Record that the user declined to move the session. No filesystem change.
Inputs: session_id (required). Returns: object
list_modesA
Return both modes' descriptions + recommendations, for the model to relay to the user.
Inputs: no named parameters. Returns: object
list_sessionsA
List every session in the index.
Inputs: no named parameters. Returns: object
move_sessionA
Move a session's file to new_path.
`new_path` must be an absolute path (`~` is expanded). If it names
an existing directory, the session moves into that directory under
its current filename. Fails cleanly -- without touching the
session or the filesystem -- if the destination already exists
(unless `force=true`), isn't writable, or doesn't exist. `force`
accepts a real bool or a word ("true"/"yes"/...) -- tolerant input.
Inputs: new_path (required), session_id (required), force. Returns: object
next_actionA
Authoritative resolver: given this session's persisted state and mode, return the exact next tool to call and a one-line directive. Safe to call at any point in a session's lifecycle -- before a mode is set, mid-critique-loop, right after a thought commits, at the final stage, or once finalized.
Inputs: session_id (required). Returns: object
refine_current_thoughtA
Rewrite the thought to address the critique. The server records
the new version and its normalized edit distance vs. the prior one.
challenged_assumptions accepts a JSON array or a comma/newline list.
Inputs: session_id (required), new_content (required), challenged_assumptions. Returns: object
resume_sessionC
Return a session's persisted state.
Inputs: session_id (required). Returns: object
score_current_thoughtB
Self-score the refined thought across the 7 utility dimensions
(partial input is tolerated -- missing dims carry forward). scores
accepts a JSON object, fenced JSON, or "correctness: 0.8, ..." text.
Returns the convergence verdict: whether to commit or run another lens.
Inputs: session_id (required), scores. Returns: object
set_session_modeA
Set a session's mode. Only succeeds if no mode is set yet -- once set, mode is immutable for the life of the session.
Inputs: mode (required), session_id (required). Returns: object
start_sessionA
Create a new session. Bootstraps the data store on first use.
Without `mode`, returns a mode-required directive payload. With a
valid `mode`, the session is created with that mode already set and
the tool proceeds immediately -- no separate `set_session_mode`
call needed. `stages` accepts a JSON array or a comma/newline
list; `overrides` a JSON object or its string form (tolerant input,
Task 13).
Inputs: question (required), mode, stages, overrides. Returns: object
submit_critiqueC
Record the critique produced by applying the current lens.
Inputs: text (required), session_id (required). Returns: object
summarize_sessionA
Deterministic extractive digest of this session's committed
thoughts. scope="stage" (default) covers only the current stage;
scope="all" covers every stage. No LLM calls -- this is text
extraction, not summarization by inference.
Inputs: session_id (required), scope. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 25 tools
Most tools have distinct purposes, but the presence of begin_thought vs. begin_subagent_thought and commit_thought vs. commit_subagent_thought could cause confusion despite clear descriptions. Overall, the set is well-differentiated.
Tool names are almost all in consistent verb_noun snake_case. 'keep_here' deviates slightly, and 'next_action' is not a verb_noun pair, but the pattern is generally predictable.
25 tools is on the high side, bordering on heavy for an MCP server. While each tool appears justified for the complex workflow, the count could overwhelm agents.
The tool set covers the full lifecycle: session management, thought creation/critique/refinement/commit, subagent rounds, state inspection, export/import. Only minor gaps exist, such as the lack of a tool to directly delete a thought.
Maintenance
Related MCP Connectors
MCP server for building and testing AI agents with multi-model experimentation and insights.
AI Reasoning Cache & Consensus Layer with 11 MCP tools via Streamable HTTP.
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Persistent memory, knowledge graph, task management and more for AI agents via MCP.
Related MCP Servers
- AlicenseAqualityDmaintenanceA structured problem-solving MCP server that breaks down complex tasks into sequential steps, supports iterative refinement and branching, and helps maintain context and explore alternative reasoning paths.141MIT
- FlicenseAqualityDmaintenanceA structured reasoning and problem-solving MCP server that helps track step-by-step analysis with confidence levels, branching, and revisions, ideal for complex multi-step tasks like code optimization and debugging.1-
- FlicenseAqualityDmaintenanceAn MCP server that exposes tools for sub-agent style reasoning across multiple LLM providers, enabling delegation of prompts to various models and running critique loops, debates, red-teaming, and answer ranking.6-
- FlicenseNot gradedqualityBmaintenanceA self-hosted MCP server that provides tools for structured reasoning, confidence calibration, and detecting recurring gaps in AI outputs, aiming to reduce workload by improving verification and attention allocation.-