agent_mcp_thoughtflow
Unifies structured reasoning (Tree of Thoughts) with reliable task execution, enabling LLM agents to think, commit, execute, and trace cognitive provenance through a single MCP server.
README
agent_mcp_thoughtflow
Unified Cognitive Scaffold MCP Server — Bridging Deep Reasoning and Reliable Execution for LLM Agents
Overview
agent_mcp_thoughtflow is a production-ready Model Context Protocol (MCP) server that unifies structured task execution with systematic reasoning.
Modern LLM agents are excellent at planning (using techniques like Tree of Thoughts) but frequently fail at execution — they explore ideas, then jump straight into implementation while skipping proper task tracking, dependency management, and auditability.
This server solves that gap by providing a single, cohesive cognitive scaffold where:
- Strategy — Top-level organizer that groups related reasoning trees and execution workflows
- Tree of Thoughts handles divergent exploration and evaluation
- Task Orchestrator handles convergent execution with dependencies and workflows
- Cognitive Bridge Layer enables seamless, bidirectional conversion between thoughts and executable tasks
The result: agents can think deeply, commit reasoning to structured work, execute reliably, and — when blocked — spawn new reasoning trees from existing tasks.
The Core Problem It Solves
Many agents follow this broken pattern:
- Use ToT / reasoning tools to explore approaches
- Directly implement changes without creating tracked tasks
- Lose provenance, auditability, and the ability to resume or delegate work
agent_mcp_thoughtflow makes the correct workflow the easiest path:
Think → Promote to Tasks → Execute with Tracking → (If blocked) Spawn new reasoning from task
Key Features
Cognitive Bridge Layer (The Killer Feature)
promote_thought_to_tasks— Convert a thought (or entire subtree) into executable tasks with full provenance metadataspawn_tot_from_task— When a task is blocked, spawn a fresh Tree of Thoughts from it for deeper analysislink_thought_to_task— Create soft bidirectional links between thoughts and tasks for "inspired by" or "related to" relationshipsget_cognitive_provenance— Trace the complete reasoning → execution chain
All bridge operations automatically maintain metadata.cognitive and create auditable cognitiveLinks.
Task Orchestrator
- Rich task model with hard/soft dependencies
- Hierarchical tasks (
parentTaskId+order) - Workflow creation and execution engine with automatic dependency resolution
startWorkflowExecution+advanceWorkflowRunfor controlled executiongetReadyTasksfor just-in-time task dispatching
Tree of Thoughts
- Full hierarchical thought trees with depth control
- Multi-criteria evaluation (
score,creativity,risk, custom criteria) - Pruning, backtracking, verification, and selection
- Strategy grouping for organizing related reasoning sessions
Strategy Model (Top-Level Organizer)
- Strategy groups related Trees of Thoughts and Workflows into cohesive units
- Each Strategy can own multiple
treeIdsandworkflowIds - Enables organizing complex projects by linking reasoning and execution
- Tools:
add_tree_to_strategy,add_workflow_to_strategy,remove_tree_from_strategy,remove_workflow_from_strategy
Visualization & Introspection
- ASCII tree visualization (
visualize_tree_ascii) - Tree visualization with cognitive links (
visualize_tree_with_links) - SVG workflow diagrams with dependency layout
- SVG task and strategy visualizations
get_cognitive_statsfor high-level metrics
Architecture & Extensibility
- Clean service-oriented design with
BaseService - Dependency injection between services
- Pluggable LLM providers (Grok, Ollama, Mock)
- JSON storage (SQLite planned)
- Centralized
ToolRegistryfor maintainable tool definitions
Installation
npm install agent_mcp_thoughtflow
Or run directly with npx:
npx agent_mcp_thoughtflow
Quick Start
1. Start the Server
npx agent_mcp_thoughtflow
The server uses JSON file storage by default (./thoughtflow-state.json).
2. Basic Hybrid Workflow Example
// 1. Create a reasoning tree
create_tree({
"goal": "Design a robust caching strategy for our API",
"rootContent": "Start with a simple in-memory cache"
})
// 2. Explore and evaluate thoughts...
// 3. Promote the best approach to tasks
promote_thought_to_tasks({
"treeId": "...",
"thoughtId": "...",
"includeDescendants": true,
"workflowId": "optional-existing-workflow"
})
// 4. Start executing the workflow
start_workflow_execution({ "workflowId": "..." })
// 5. If a task gets blocked, spawn new reasoning
spawn_tot_from_task({
"taskId": "...",
"goal": "Investigate why the cache invalidation is failing",
"rootContent": "The cache is not being invalidated on write operations"
})
Tool Reference
Bridge Layer Tools
| Tool | Purpose |
|---|---|
promote_thought_to_tasks |
Convert reasoning into tracked executable work |
spawn_tot_from_task |
Spawn fresh reasoning from a blocked task |
link_thought_to_task |
Create soft bidirectional links for "inspired by" or "related to" relationships |
get_cognitive_provenance |
Trace full reasoning → execution history |
Task Orchestrator Tools
| Category | Tools |
|---|---|
| Tasks | create_task, get_task, list_tasks, update_task, delete_task |
| Workflows | create_workflow, get_workflow, list_workflows, addTasksToWorkflow |
| Execution | start_workflow_execution, advance_workflow_run, getReadyTasks |
| Hierarchy | get_subtasks, move_task |
| Strategies | create_strategy, get_strategy, list_strategies, add_tree_to_strategy, remove_tree_from_strategy |
Tree of Thoughts Tools
| Category | Tools |
|---|---|
| Trees | create_tree, get_tree, list_trees, delete_tree |
| Thoughts | add_idea, get_thought, evaluate_thought, verify_thought, select_thought, backtrack, prune_tree |
| Strategies | create_strategy, get_strategy, list_strategies, add_workflow_to_strategy, remove_workflow_from_strategy |
Visualization Tools
visualize_tree_asciivisualize_tree_with_linksvisualize_workflow_svgvisualize_task_svgvisualize_strategy_svgget_cognitive_stats
Recommended Agent Workflow
The intended usage pattern for LLM agents:
- Explore — Use
create_tree+add_idea+evaluate_thoughtto explore solution space - Commit — Use
promote_thought_to_taskson the most promising branch - Execute — Use
start_workflow_execution+advance_workflow_run(orgetReadyTasks) - Reflect — If blocked, use
spawn_tot_from_taskon the stuck task - Audit — Use
get_cognitive_provenancewhen traceability is required
This pattern turns ad-hoc reasoning into auditable, resumable, delegable work.
Relationship Model
The system uses a hierarchical relationship model for organizing cognitive work:
Strategy (Top-Level Organizer)
├── treeIds: string[] → Trees of Thoughts (reasoning)
├── workflowIds: string[] → Workflows (execution)
└── metadata: Record<string, any>
Idea (Thought) ↔ Task (Soft Bidirectional Links)
├── Thought.metadata.cognitive.linkedTaskIds
├── Task.metadata.cognitive.linkedThoughtIds
├── syncStatus: 'synced' | 'outdated' | 'conflict'
└── provenanceChain: ProvenanceEntry[]
Key Relationships
- Strategy → Trees + Workflows: Strategies organize related reasoning and execution into cohesive units
- Idea ↔ Task: Soft bidirectional links enable "inspired by" or "related to" relationships without full promotion
- Promotion: Full conversion from thought subtree to executable tasks with provenance tracking
- Spawning: Create new reasoning trees from blocked tasks for deeper analysis
Architecture
┌─────────────────────────────────────────────────────────────┐
│ Thoughtflow MCP Server │
├─────────────────────────────────────────────────────────────┤
│ CognitiveBridgeService ←→ TaskOrchestratorService │
│ ↑ ↑ │
│ │ │ │
│ ToTService Workflow Execution Engine │
│ │ │ │
│ └──────────┬───────────────┘ │
│ │ │
│ VisualizationService │
└─────────────────────────────────────────────────────────────┘
All services extend BaseService for unified state management, auto-save, and shutdown behavior.
Storage
- Default: JSON file (
thoughtflow-state.json) - Future: SQLite support (planned in v1.1)
The storage layer is abstracted via IStorageAdapter, making it easy to add new backends.
LLM Provider Support
The ToT system supports multiple LLM backends:
- Grok (
GrokLLMProvider) — Recommended for high-quality structured evaluation - Ollama (
OllamaLLMProvider) — Local/private models - Mock (
MockLLMProvider) — Testing and development
Development
# Install dependencies
npm install
# Run in development mode
npm run dev
# Build
npm run build
Roadmap
- [ ] SQLite storage adapter
- [ ] Richer workflow visualization and Gantt-style views
- [ ] Built-in retry policies and task timeout handling
- [ ] Multi-agent collaboration primitives
- [ ] Web UI for inspecting cognitive provenance
Contributing
Contributions are welcome! Please open an issue first to discuss major changes.
Focus areas:
- Improving the Bridge Layer ergonomics
- Additional visualization formats
- Performance on large thought trees / workflows
License
MIT © 2026
Acknowledgments
This project was born from the observation that reasoning without execution tracking is incomplete, and execution without reasoning provenance is fragile.
agent_mcp_thoughtflow exists to make the full cognitive loop first-class in agent systems.
Built with ❤️ for agents that need to think and ship.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。