关于 cognitive-substrate
cognitive-substrate 是面向 Agent 的 MCP 服务和 Python 包,提供经验证的 28 层推理基底、跨会话 Tree-of-Thoughts 记忆,以及遥测和对等 Agent 工具。
主要功能
- 01经验证的 28 层推理基底
- 02跨会话 Tree-of-Thoughts 记忆
- 03七种推理范式
- 04会话树状态遥测
- 05对等 Agent 的发现与编排
适用场景
- 01按分层架构验证 Agent 推理
- 02复用已剪枝推理分支的经验
- 03查看会话中的活跃与剪枝路径
- 04发现并协调对等 Agent
MCP 相关
`cognitive-substrate` CLI 可启动 stdio MCP 服务。推理、记忆、遥测、解析和 A2A 能力均以工具形式提供。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
还没有获取到工具列表
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
mcp-cognitive-substrate
mcp-name: io.github.JaysonAIOnline/cognitive-substrate
一个包含 28 层认知基底、跨会话 思维树(ToT)演化记忆、条件式自我遥测功能和供 MCP Agent 使用的 A2A 工具的项目。
让 Agent 通过经过验证的 28 层基底进行推理、跨会话演化记忆,并与同伴 Agent 通信——所有功能都集成在一个可通过 pip 安装的包中。
功能
- 通过 Pydantic 验证的 28 层认知基底 —
CognitiveSubstrate通过 6 个类别 / 28 层验证推理。 - 跨会话 ToT 演化记忆 — 由 SQLite 提供支持的思维树节点 + 基底历史记录;经剪枝的分支会成为未来会话的经验。
- 稳健的基于栈的 JSON 解析器 — 不使用正则表达式;可处理嵌套括号、转义字符串和嵌入的代码围栏(
robust_slice/robust_json_slice)。 - 自我遥测工具 —
get_cognitive_tree_state返回会话的活动路径和经剪枝的分支。 - 执行后存储循环 —
store_5key_telemetry自动保存精简的 5 键遥测数据(基础、元认知、防御、资源、效用)。 - 7 种推理范式 — 演绎、归纳、溯因、类比、因果、三段论、证伪。
- A2A 工具 — 列出、发现、调用和编排同伴 Agent。
- MCP 服务 — 通过
cognitive-substrateCLI 将所有功能作为工具公开。
安装
pip install mcp-cognitive-substrate
或从源代码安装:
git clone https://github.com/JaysonAIOnline/mcp-cognitive-substrate.git
cd mcp-cognitive-substrate
pip install -e .[test]
需要 Python >= 3.11。
快速开始
from mcp_cognitive_substrate.substrate import CognitiveSubstrate
from mcp_cognitive_substrate.memory import get_cognitive_tree_state, store_5key_telemetry
substrate = CognitiveSubstrate()
response = substrate.run("Your user prompt here")
print(response["layers_applied"], "layers applied")
print(response["substrate_verdict"])
用法
28 层基底
from mcp_cognitive_substrate import substrate
# Layer count and schema
print(substrate.layer_count()) # 28
print(substrate.SUBSTRATE_SCHEMA) # the full 6-family schema
# Validate a prompt through the substrate
result = substrate.CognitiveSubstrate(session_id="s1").run("deploy safely")
print(result["substrate_verdict"]) # heuristic pruning verdict
# Run a single paradigm
from mcp_cognitive_substrate import run_paradigm
print(run_paradigm("14_idempotency_side_effect_audit", {"evaluate_branch": True}))
跨会话 ToT 演化记忆
from mcp_cognitive_substrate.memory import (
store_5key_telemetry,
get_cognitive_tree_state,
prune_failed_approach,
)
node_id = store_5key_telemetry(
session_id="session-a",
payload={
"foundations": {"premise_validation": "assuming deps", "state_hash": "h", "falsification_notes": "deps missing"},
"defensive": {"blast_radius": "unpredictable", "is_idempotent": True, "invariant_rule": "r"},
"resource": {"big_o": "o(n)", "latency_bottleneck": "none"},
"utility": {"load_summary": "pin versions to deploy", "checklist_verified": True},
"metacognition": {"self_critique": "c", "drift_pct": 0.1},
},
score_delta=-110.0,
)
prune_failed_approach(node_id)
state = get_cognitive_tree_state("session-a", include_pruned=True)
print(state["active_path_count"], state["pruned_branch_count"])
基于栈的 JSON 解析器
from mcp_cognitive_substrate.memory import robust_slice, robust_json_slice
cleaned, payload = robust_slice('prefix {"a": {"b": [1, 2]}, "c": "x"} suffix')
# payload == {"a": {"b": [1, 2]}, "c": "x"}; cleaned == "prefix suffix"
7 种推理范式 + A2A
from mcp_cognitive_substrate import reason, a2a_list, a2a_call, a2a_orchestrate
print(reason("Solve X", reasoning_type="abductive", depth=3)["steps"])
print(a2a_list())
print(a2a_call("peer-agent", "hello"))
print(a2a_orchestrate("hi", capability="memory"))
作为 MCP 服务
cognitive-substrate # starts stdio MCP server
cognitive-substrate --info # prints package summary
以上所有功能——基底范式、提取 / 评估、记忆存储 / 检索、ToT 经验、树状态遥测、JSON 解析、推理计划和 A2A——都作为 MCP 工具公开。
测试
pip install -e .[test]
python -m pytest src/tests -q # 16 tests
许可证
评论
支持 Markdown
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。