🧠 GOT MCP
Graph of Thoughts MCP Server — Bounded, Auditable Reasoning for AI Agents
⚡ Quick Start • 🛠 Tools • 🧬 How It Thinks • 🔒 Governance • 📊 Visualizer
______________________________________________________________________
这是什么?
思维链 原因排成一行。 思想之树 可以分支。 思想图谱 可以分支、合并、反驳、修剪死胡同,并在获胜的道路上趋同。
思维图谱是一个 模型上下文协议(MCP) 提供AI代理的服务器 非线性推理 --一种有向无环图,其中思想可以分支成备选方案,与证据相矛盾,并通过加权聚合收敛。
Traditional AI: A → B → C → D (linear, no backtracking)
Tree of Thought: A → B₁, B₂ (branching, no merging)
Graph of Thoughts: A → B₁ ←contradiction→ C₁, B₂ →aggregate→ D ← THIS🔗 Chain of Thought Linear • No backtrack 🌲 Tree of Thoughts Branching • No merge 🧠 Graph of Thoughts Branch • Merge • Prune • Converge
______________________________________________________________________
⚡ 快速开始
选项1:从npm安装
npm install -g @abderraouf-yt/got-mcp选项2:克隆和构建
git clone https://github.com/Abderraouf-yt/got-mcp.git
cd got-mcp
npm install && npm run build配置IDE
添加到MCP配置(~/.gemini/settings.json,VS代码 mcp.json等等):
{
"got-mcp": {
"command": "npx",
"args": ["-y", "@abderraouf-yt/got-mcp"],
"env": { "THOUGHT_GRAPH_HTTP_PORT": "3001" }
}
}______________________________________________________________________
🎬 现场演示
问题: *“我们应该使用CRDT还是运营转型作为协作编辑?”*
该代理探索了3个分支,评估了13个节点,拒绝了死角,并收敛到一个混合解决方案上——所有这些都在图中可见:
graph TD
classDef validated fill:#00ff88,stroke:#00ff88,color:#000
classDef rejected fill:#ff4444,stroke:#ff4444,color:#fff
classDef active fill:#00e5ff,stroke:#00e5ff,color:#000
classDef winner fill:#ffd700,stroke:#ffd700,color:#000
N1["🎯 CRDTs vs OT?
80%"]:::validated
N2["📖 CRDT Research
85%"]:::validated
N3["📖 OT Research
70%"]:::active
N4["🌿 Branch A: Yjs
90%"]:::validated
N5["❌ Branch B: ShareDB
40%"]:::rejected
N11["🌿 Branch C: Hybrid
95%"]:::validated
N6["✅ TypeScript + ProseMirror
sub-100ms sync · 95%"]:::validated
N7["⚠️ Memory overhead
10x state size · 65%"]:::active
N8["❌ MongoDB persistence
50%"]:::rejected
N9["💀 Cannot work offline
90%"]:::validated
N10["🔧 Y.Doc compaction
90% size reduction · 92%"]:::validated
N12["✅ Liveblocks + Tiptap
+ Hocuspocus · 88%"]:::validated
N13["🏆 WINNER: Yjs +
y-websocket + Hocuspocus
100%"]:::winner
N1 -->|refinement| N2
N1 -->|refinement| N3
N1 -->|branch| N11
N2 -->|branch| N4
N3 -->|branch| N5
N4 -->|support| N6
N4 -->|contradiction| N7
N5 -->|support| N8
N5 -->|contradiction| N9
N7 -->|refinement| N10
N11 -->|support| N12
N11 -->|refinement| N13结果: OT分支被拒绝(脱机失败)。CRDT内存问题矛盾,然后通过压缩解决。混合路径以100%获胜。
🔁 Load this demo yourself
cp docs/assets/demo-state.json thought-graph-state.json
npm run start
# Open visualizer → http://localhost:5173演示状态随回购一起发布 docs/assets/demo-state.json.
______________________________________________________________________
🛠 工具(16)
ToolWhat it doesCategory propose_thoughtAdd a reasoning node with optional parent + relation🧠 Core evaluate_thoughtScore (0.0–1.0) + critique. Omit score → autonomous LLM audit🧠 Core get_thought_graphRetrieve the full DAG state🧠 Core reset_graphClear graph for new session🧠 Core aggregate_thoughtsMerge 2+ nodes → weighted synthesis Σ(score×weight)/Σ(weights)⚡ GoT prune_branchHard (reject+zero) or Soft (score decay) pruning⚡ GoT find_winning_pathGreedy DFS or beam search (k-best paths) with threshold gating⚡ GoT get_graph_metricsNode count, max depth, prune ratio, avg score, status breakdown📊 Ops export_snapshotFull graph serialization for replay/recovery🔁 Replay restore_snapshotRestore from previously exported snapshot🔁 Replay reflect_and_refineSelf-reflection: 4-axis confidence + auto-critique + branch🔬 v4.0 context_setWrite key-value to shared context store with provenance📦 v4.0 context_getRead value + source from shared context store📦 v4.0 context_listList all context store entries and their sources📦 v4.0 export_reasoning_traceExport winning path as Long CoT trace (DeepSeek-R1/o3 format)📤 v4.0 run_controller_loopAutonomous GoT orchestrator: seed → evaluate → branch → reflect → prune → converge🔄 v4.0
边缘关系
refinement · contradiction · support · branch · aggregation · reflection
节点状态
active · validated · rejected · branching
______________________________________________________________________
🧬 它是怎么想的
Agent: I need to decide between PostgreSQL and MongoDB.
→ propose_thought("PostgreSQL vs MongoDB for user data store?")
→ propose_thought("PostgreSQL: ACID, strong schema", parent: "node_1", relation: "branch")
→ propose_thought("MongoDB: flexible schema, horizontal scaling", parent: "node_1", relation: "branch")
→ propose_thought("Our data has relational patterns: user→orders→items", parent: "node_2", relation: "support")
→ propose_thought("MongoDB can't enforce referential integrity", parent: "node_3", relation: "contradiction")
→ evaluate_thought("node_3", score: 0.3, status: "rejected")
→ prune_branch("node_3", reason: "Relational data needs relational DB")
→ find_winning_path(beamWidth: 2, scoreThreshold: 0.5)
↳ Winner: node_1 → node_2 → node_4 (PostgreSQL path, score: 2.75)______________________________________________________________________
🔒 治理
引擎级保护——在图形引擎中强制执行,而不是在工具层:
| 保护 | 默认 | 强制执行 |
|---|---|---|
| 节点帽 | 200 | addNode() 投掷极限 |
| 深度盖 | 15 | addEdge() 验证深度 |
| 分行上限 | 5个孩子/节点 | addEdge() 限制分支 |
| 循环检测 | 始终打开 | BFS可达性 addEdge() |
| 思想长度 | 5000个字符 | addNode() +Zod模式 |
| 聚合限制 | 10个输入 | aggregateNodes() |
| 李瀑布 | 50个节点 | pruneFromNode() |
| 信心夹 | \[0, 1\] | aggregateNodes() |
⚙️ Custom Limits
通过构造函数覆盖默认值:
const graph = new ThoughtGraph(persistPath, {
maxNodes: 500,
maxDepth: 25,
maxBranchFactor: 8,
maxThoughtLength: 10000,
maxAggregationInputs: 20,
maxPruneCascade: 100,
});会话隔离
每个会话都有自己的独立图,具有单独的持久性:
const alice = getGraphInstance("user-alice"); // → thought-graph-state-user-alice.json
const bob = getGraphInstance("user-bob"); // → thought-graph-state-user-bob.json
// Alice and Bob never share state并发安全
所有突变都在异步互斥体下运行:
await graph.withLock(async () => {
graph.addNode("Safe concurrent mutation");
});快照回放
const snapshot = graph.exportSnapshot();
// { nodes, edges, nodeCounter, timestamp, version: "3.0.0", stateVersion: 42 }
graph.restoreSnapshot(snapshot); // Deterministic replay______________________________________________________________________
📊 可视化工具
React 19+Vite仪表板 网络工业用户界面 --通过React Flow+Dagre布局进行实时图形渲染。
| 功能 | 详细信息 |
|---|---|
| 布局 今天的层次结构。 | |
| 实时同步 | SWR轮询(间隔2秒) |
| 节点颜色 | 🟢 已验证·🔵 活跃·🔴 拒绝·🟣 分支机构 |
| 边类型 | 动画(分支)·虚线(矛盾)·实线(支持)·点线(聚合) |
| 分数条 | 每个节点的置信度(0-100%) |
| 小地图 | 右下角概述 |
cd visualizer && npm install && npm run dev
# → http://localhost:5173建筑
┌─────────────────┐ Stdio ┌──────────────────┐
│ AI Agent │ ◄────────────► │ MCP Server │
│ (Gemini/Cursor) │ │ (index.ts) │
└─────────────────┘ │ │
│ Session Registry │
┌─────────────────┐ HTTP:3001 │ ThoughtGraph[] │
│ Visualizer │ ◄────────────► │ │
│ React + Vite │ /api/graph │ Express Bridge │
│ :5173 │ └──────────────────┘
└─────────────────┘ │
thought-graph-state-{session}.json
(per-session file persistence)______________________________________________________________________
🔬 GoT合规性
| 原始 | 实现 | 版本 |
|---|---|---|
| 生成 | propose_thought | v1.0 |
| 评估 | evaluate_thought | v1.0 |
| 回溯 | evaluate_thought(status: rejected) | v1.0 |
| 聚合 | aggregate_thoughts --加权综合 | v3.0 |
| 修剪 | prune_branch --硬+软模式 | v3.0 |
| 汇聚 | find_winning_path --波束搜索 | v3.0 |
| 治理 | 引擎级防护+会话隔离 | v3.0 |
| 回放 | export_snapshot / restore_snapshot | v3.0 |
| 自我反思 | reflect_and_refine --四轴置信度 | v4.0 |
| 上下文存储 | context_set / context_get / context_list | v4.0 |
| 推理轨迹 | export_reasoning_trace --长CoT导出 | v4.0 |
| 控制器回路 | run_controller_loop --自主编排器 | v4.0 |
______________________________________________________________________
🏗 技术栈
| 层 | 技术 |
|---|---|
| 运行时 | TypeScript·Node.js v20+ |
| 协议 | @modelcontextprotocol/sdk ^1.26 |
| 验证 | Zod模式 .max() 长度防护装置 |
| 治理 | 引擎级别:节点/深度/分支上限,循环检测 |
| HTTP网桥 | Express |
| 可视化工具 | React 19·Vite· @xyflow/react ·Dagre·SWR |
| 持久性 | 会话范围的JSON fs.watchFile 同步 |
| 并发 | 异步互斥(withLock)每节课 |
📁 结构
thought-graph/
├── src/
│ ├── index.ts # Bootstrap (Stdio + HTTP)
│ ├── server/
│ │ ├── mcp.ts # 16 MCP tool registrations
│ │ └── http.ts # Express bridge (minimal inline CORS)
│ ├── graph/
│ │ ├── ThoughtGraph.ts # Core DAG engine + governance
│ │ └── index.ts # Session registry exports
│ ├── context/
│ │ ├── ContextStore.ts # Shared context store (CA-MCP)
│ │ └── index.ts # Context singleton export
│ └── types.ts # GraphLimits, ConfidenceVector, ReasoningTrace
├── visualizer/ # React + Vite dashboard (local only)
├── evaluations/ # XML evaluation framework
├── tests/ # Unit tests
├── docs/assets/ # Demo screenshots & state
└── dist/ # Compiled output📜 许可证
麻省理工学院
______________________________________________________________________
Evolution of sequential thinking — because the best ideas don't come in a straight line.
