Skip to main content

mcp-cognitive-substrate

A 28-layer cognitive substrate with cross-session Tree-of-Thoughts (ToT) evolutionary memory, conditional self-telemetry, and A2A tools for MCP agents.

Lets agents reason through a validated 28-layer substrate, evolve memory across sessions, and communicate with peer agents — all in one pip-installable package.

Features

  • 28-layer cognitive substrate with Pydantic validationCognitiveSubstrate validates reasoning through 6 families / 28 layers.
  • Cross-session ToT evolutionary memory — SQLite-backed tree-of-thoughts nodes + substrate history; pruned branches become lessons for future sessions.
  • Robust stack-based JSON parser — no regex; handles nested brackets, escaped strings, embedded code fences (robust_slice / robust_json_slice).
  • Self-telemetry toolget_cognitive_tree_state returns active paths and pruned branches for a session.
  • Post-execution storage loopstore_5key_telemetry auto-saves compact 5-key telemetry (foundations, metacognition, defensive, resource, utility).
  • 7 reasoning paradigms — deductive, inductive, abductive, analogical, causal, syllogistic, falsification.
  • A2A tools — list, discover, call, and orchestrate peer agents.
  • MCP server — exposes everything as tools via the cognitive-substrate CLI.

Install

pip install mcp-cognitive-substrate

Or install from source:

git clone https://github.com/JaysonAIOnline/mcp-cognitive-substrate.git
cd mcp-cognitive-substrate
pip install -e .[test]

Requires Python >= 3.11.

Quick Start

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"])

Usage

28-layer substrate

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}))

Cross-session ToT evolutionary memory

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"])

Stack-based JSON parser

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 reasoning paradigms + 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"))

As an MCP server

cognitive-substrate          # starts stdio MCP server
cognitive-substrate --info   # prints package summary

All of the above — substrate paradigms, extraction/evaluation, memory store/recall, ToT lessons, tree-state telemetry, JSON parsing, reasoning plans, and A2A — are exposed as MCP tools.

Testing

pip install -e .[test]
python -m pytest src/tests -q     # 16 tests

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_cognitive_substrate-1.0.0.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_cognitive_substrate-1.0.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file mcp_cognitive_substrate-1.0.0.tar.gz.

File metadata

  • Download URL: mcp_cognitive_substrate-1.0.0.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for mcp_cognitive_substrate-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b24db21b127d650b8d9794c5211544741029b2abf78cccc46d74818e4c3f48e7
MD5 7251b360d48c1ba24452c83098f251fb
BLAKE2b-256 858da61feb03c623f51b7a82785d18ba6c6519e991a433a7e47e057b958fa25e

See more details on using hashes here.

File details

Details for the file mcp_cognitive_substrate-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_cognitive_substrate-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad8a52dd0a00a0d23e3aaa68137a4081917c2d8a1bd6d776e6759d2129d62705
MD5 6a77fc731768603ec2dcdded3ea0ece0
BLAKE2b-256 b1502c0164cf11aa4d1fdd570b61398c38e81bcb2e664650f0ed0bcab7f04b64

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.1

2 files

This release

1.0.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page