Skip to main content

Persistent memory layer for AI agents โ€” survives sessions, learns patterns, enables continuity

Project description

๐Ÿง  Cognex

Persistent memory layer for AI agents โ€” survives sessions, learns patterns, enables continuity.

Give your AI coding assistant long-term memory, decision tracking, and trust management.

Python MCP Tests


Why Use It?

You: "Remember I prefer pytest over unittest"

Next session:
AI: "Got it โ€” I'll use pytest for your tests instead."

Your AI forgets everything between sessions. Cognex fixes that.

Features

Feature What It Does
๐Ÿง  Persistent Memory Remembers preferences, facts, patterns across sessions
๐Ÿ“ Decision Ledger Tracks choices made and their outcomes
๐Ÿ›ก๏ธ Trust Engine Learns which tools you approve vs deny
๐Ÿ”„ Teleportation Export your brain, load it on another machine
๐Ÿ Swarm Mode Turn natural language into multi-agent plans

Supported AI Tools

Tool Works?
Claude Code โœ…
Claude Desktop โœ…
OpenCode โœ…
Cursor โœ…
Codex โœ…
Any MCP-compatible tool โœ…

Installation (Choose One)

Option 1: uvx (Recommended โ€” no install needed)

uvx cognex

Option 2: pipx (isolated environment)

pipx install cognex

Option 3: pip (system-wide install)

pip install cognex

Option 4: Install from this folder (development)

cd D:\COGNITIVE\cognitive-substrate
pip install -e .

Configuration by CLI Tool

OpenCode

Config location: %USERPROFILE%\.config\opencode\opencode.json

With uvx (no install):

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "cognex": {
      "type": "local",
      "command": ["uvx", "cognex"],
      "enabled": true
    }
  }
}

With pipx:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "cognex": {
      "type": "local",
      "command": ["pipx", "run", "cognex"],
      "enabled": true
    }
  }
}

With pip (simplest):

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "cognex": {
      "type": "local",
      "command": ["cognex"],
      "enabled": true
    }
  }
}

Claude Code / Claude Desktop

Config location (Windows): %APPDATA%\Claude\claude_desktop_config.json

Config location (Mac): ~/Library/Application Support/Claude/claude_desktop_config.json

With pip:

{
  "mcpServers": {
    "cognex": {
      "command": "cognex"
    }
  }
}

With uvx:

{
  "mcpServers": {
    "cognex": {
      "command": "uvx",
      "args": ["cognex"]
    }
  }
}

Cursor

Config location (Windows): %USERPROFILE%\.cursor\mcp.json

Config location (Mac): ~/.cursor/mcp.json

With pip:

{
  "mcpServers": {
    "cognex": {
      "command": "cognex"
    }
  }
}

VS Code (with MCP extension)

Create .vscode/mcp.json in your project:

{
  "servers": {
    "cognex": {
      "command": "uvx",
      "args": ["cognex"]
    }
  }
}

Codex

Add to your Codex config (~/.codex/config.json):

{
  "mcpServers": {
    "cognex": {
      "command": "cognex"
    }
  }
}

Restart Your AI Tool

After adding the config, completely close and reopen your AI tool. You should see 18 new tools available.


The 18 Tools

๐Ÿ—“๏ธ Session Management

Tool Description
substrate_start_session Start a new work session
substrate_end_session End session with summary/metrics
substrate_process_transcript Extract memories from conversation
substrate_report Get memory health report

๐Ÿ’พ Memory

Tool Description
memory_add Add a memory (fact, preference, decision, pattern)
memory_search Search memories with filters
memory_get_context Get relevant context for current work
memory_decay Age memories (auto-cleanup old ones)

๐Ÿ›ก๏ธ Trust Engine

Tool Description
trust_check Check if tool needs approval
trust_record Record approval/denial/violation
trust_get Get trust score for a tool
trust_summary Get trust overview

๐Ÿ“– Decision Ledger

Tool Description
ledger_record Record a decision made
ledger_outcome Record what happened after
ledger_find_similar Find similar past decisions

๐Ÿš€ Teleportation

Tool Description
teleport_create_bundle Export your brain to JSON
teleport_rehydrate Import brain from another machine

๐Ÿ Swarm

Tool Description
swarm_compile_intent Turn "build me an API" into a multi-agent plan

Example Usage

Remember a Preference

You: "I prefer using type hints everywhere"
AI: (calls memory_add)
โ†’ Saved to your memory bank

Get Context Next Session

You: (start new session)
AI: (calls memory_get_context with "coding style")
โ†’ Returns: "I prefer using type hints everywhere"
AI: "Got it โ€” I'll add type hints throughout."

Track a Decision

You: "FastAPI or Flask?"
AI: "FastAPI has better type safety."
AI: (calls ledger_record)

Later...
You: "Did that work out?"
AI: (calls ledger_outcome with success: true)

Tool Trust Check

AI wants to run: rm -rf /
AI: (calls trust_check)
โ†’ {requires_approval: true, trust_level: 0.2}
AI asks: "Can I delete everything?"

Where Data is Stored

All data stays local on your machine in SQLite:

%USERPROFILE%\.cognex\
โ””โ”€โ”€ cognex.db
    โ”œโ”€โ”€ memories      (your persistent memories)
    โ”œโ”€โ”€ sessions      (session history)
    โ”œโ”€โ”€ trust_records (tool approval history)
    โ””โ”€โ”€ decisions     (decision ledger)

Troubleshooting

"command not found" or "cognex" not recognized

Fix: Make sure you installed it:

pip install cognex

Or use uvx in your config:

"command": ["uvx", "cognex"]

Tools not appearing

  1. Check the AI tool's developer console for errors
  2. Try restarting the AI tool completely
  3. Verify your JSON config is valid (use a JSON validator)

Development

# Run tests
cd D:\COGNITIVE\cognitive-substrate
python tests/test_mcp_server.py

# Run pytest
python -m pytest tests/ -v -k "not mcp_server"

# Run demo
python demo/run_demo.py

File Structure

D:\COGNITIVE\cognitive-substrate\
โ”œโ”€โ”€ README.md              โ† You are here!
โ”œโ”€โ”€ mcp.json               โ† MCP config ready to copy
โ”œโ”€โ”€ pyproject.toml         โ† Package config (name: cognex)
โ”œโ”€โ”€ demo/
โ”‚   โ”œโ”€โ”€ run_demo.py        โ† Simple demo
โ”‚   โ””โ”€โ”€ run_full_demo.py   โ† Full workflow demo
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ substrate/         โ† Core memory system
โ”‚   โ”‚   โ”œโ”€โ”€ substrate.py   โ† Main orchestrator
โ”‚   โ”‚   โ”œโ”€โ”€ store.py       โ† SQLite storage
โ”‚   โ”‚   โ”œโ”€โ”€ extractor.py   โ† Memory extraction
โ”‚   โ”‚   โ”œโ”€โ”€ retriever.py   โ† Memory retrieval
โ”‚   โ”‚   โ”œโ”€โ”€ ledger.py      โ† Decision tracking
โ”‚   โ”‚   โ”œโ”€โ”€ trust.py       โ† Trust engine
โ”‚   โ”‚   โ”œโ”€โ”€ teleport.py    โ† State export/import
โ”‚   โ”‚   โ””โ”€โ”€ swarm.py       โ† Multi-agent planning
โ”‚   โ””โ”€โ”€ substrate_mcp/     โ† MCP server
โ”‚       โ”œโ”€โ”€ server.py      โ† MCP server entry
โ”‚       โ””โ”€โ”€ tools/         โ† 18 tool implementations
โ””โ”€โ”€ tests/
    โ”œโ”€โ”€ test_substrate.py  โ† Core tests
    โ”œโ”€โ”€ test_layers.py     โ† Layer tests
    โ””โ”€โ”€ test_mcp_server.py โ† Tool tests

License

MIT โ€” free to use, modify, and distribute.


Need Help?

  • ๐Ÿ“‚ Source code: D:\COGNITIVE\cognitive-substrate\src\
  • ๐Ÿงช Run tests: python tests/test_mcp_server.py
  • ๐Ÿ”ง Tool implementations: src\substrate_mcp\tools\

Project details


Download files

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

Source Distribution

cognex-0.1.0.tar.gz (40.2 kB view details)

Uploaded Source

Built Distribution

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

cognex-0.1.0-py3-none-any.whl (43.1 kB view details)

Uploaded Python 3

File details

Details for the file cognex-0.1.0.tar.gz.

File metadata

  • Download URL: cognex-0.1.0.tar.gz
  • Upload date:
  • Size: 40.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cognex-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2436f228a9b8198ffa54a8a30e5fbddb7a797c9987b861065f5233c5322f4e3a
MD5 9e9ee2c74b7756bc8293ca519c579125
BLAKE2b-256 33c892eedaa1f6a4e7b7687ae60849d2a7bf80a1d77fae6a3a85e16da4b9dc6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for cognex-0.1.0.tar.gz:

Publisher: publish.yml on Gaurav7974/cognex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cognex-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cognex-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 43.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cognex-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a469cec9c83552a8177f13f29ef7f72d86fd1889676cc1cf82c69beea773c660
MD5 bb8d20a7826e35ee57fee5c7c108fac7
BLAKE2b-256 cc9cfaa6f662d51f0a4dd1fd40df525e05a5fd7cb04b7bacf3a5f86f712b7b5c

See more details on using hashes here.

Provenance

The following attestation bundles were made for cognex-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Gaurav7974/cognex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page