CogniLayer
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@CogniLayersearch memory for the checkout payment flow and past bugs"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
๐ง CogniLayer v4
Stop re-explaining your codebase to AI.
Infinite speed memory ยท Code graph ยท 200K+ tokens saved
Without CogniLayer, your AI agent starts every session blind. It re-reads files, re-discovers architecture, re-learns decisions you explained last week. On a 50-file project, that's 80-100K tokens burned before real work begins.
With CogniLayer, it already knows. Three things your agent doesn't have today:
๐ Persistent knowledge across agents - facts, decisions, error fixes, gotchas survive across sessions, crashes, and agents. Start in Claude Code, continue in Codex CLI - zero context loss
๐ Code intelligence - who calls what, what depends on what, what breaks if you rename a function. Tree-sitter AST parsing across 10+ languages, not grep
๐ค Subagent context compression - research subagents write findings to DB instead of dumping 40K+ tokens into parent context. Parent gets a 500-token summary + on-demand memory_search retrieval
โก 80-200K+ tokens saved per session - semantic search replaces file reads, subagent findings go to DB instead of context. Longer sessions with subagents save more
See the Difference
Without CogniLayer
You: "Fix the login bug"
Claude: Let me read the project structure...
Let me read src/auth/login.ts...
Let me read src/auth/middleware.ts...
Let me read src/config/database.ts...
Let me understand your auth flow...
(8 files read, 45K tokens burned, 2 minutes spent on orientation)
Claude: "Ok, I see the issue..."With CogniLayer
You: "Fix the login bug"
Claude: [memory_search โ "login auth flow"] โ 3 facts loaded (200 tokens)
[code_context โ "handleLogin"] โ caller/callee map in 0.2s
Already knows: Express + Passport, JWT in httpOnly cookies,
last login bug was a race condition in session refresh (fixed 2 weeks ago)
Claude: "This looks like the same pattern as the session refresh issue
from March 1st. The fix is..."That's not a small improvement. That's the difference between an agent that guesses and one that knows.
Related MCP server: Heimdall MCP Server
Real-World Examples
Debugging: "Why is checkout failing?"
Without CogniLayer, Claude reads 15 files to understand your e-commerce flow. With it:
memory_search("checkout payment flow")
โ fact: "Stripe webhook hits /api/webhooks/stripe, validates signature
with STRIPE_WEBHOOK_SECRET, then calls processOrder()"
โ gotcha: "Stripe sends webhooks with 5s timeout - processOrder must
complete within 5s or webhook retries cause duplicate orders"
โ error_fix: "Fixed duplicate orders on 2026-02-20 by adding
idempotency key check in processOrder()"
code_impact("processOrder")
โ depth 1: createOrderRecord, sendConfirmationEmail, updateInventory
โ depth 2: InventoryService.reserve, EmailQueue.push
โ "Changing processOrder will affect 6 functions across 4 files"Claude already knows the architecture, the past bugs, and what will break if it touches the wrong thing. Instead of 15 file reads (~60K tokens), it uses 3 targeted queries (~800 tokens).
Code Intelligence: "What happens if I change processOrder?"
Without CogniLayer, Claude greps for the function name and hopes for the best. With it:
code_context("processOrder")
โ definition: src/services/order.ts:42
โ incoming (who calls it): StripeWebhookHandler.handle, OrderController.retry,
AdminPanel.reprocessOrder
โ outgoing (what it calls): createOrderRecord, sendConfirmationEmail,
updateInventory, PaymentLog.write
code_impact("processOrder")
โ depth 1 (WILL BREAK): StripeWebhookHandler, OrderController, AdminPanel
โ depth 2 (LIKELY AFFECTED): WebhookRouter, RetryQueue, AdminRoutes
โ depth 3 (NEED TESTING): 3 test files, 1 integration test
โ "Changing processOrder will affect 9 symbols across 7 files"Before touching a single line, Claude knows the full blast radius - which files will break, which need testing, and which callers depend on the current behavior. No more surprise failures after a refactor.
Refactoring: "Rename UserService to AccountService"
code_search("UserService")
โ class UserService in src/services/user.ts (line 14)
โ 12 references across 8 files
code_impact("UserService")
โ depth 1: AuthController, ProfileController, AdminPanel (WILL BREAK)
โ depth 2: LoginRoute, RegisterRoute, middleware/auth (LIKELY AFFECTED)
โ depth 3: 4 test files (NEED UPDATING)
memory_search("UserService")
โ decision: "UserService handles both auth and profile - planned split
into AuthService + ProfileService (decided 2026-02-15, not yet done)"Claude doesn't just find-and-replace. It knows there's a planned split and can suggest doing both changes at once - saving you a future refactoring session.
New session after a crash: "What was I working on?"
[SessionStart hook fires automatically]
โ bridge loaded: "Progress: Migrated 3/5 API endpoints to v2 format.
Done: /users, /products, /orders. Open: /payments, /shipping.
Blocker: /payments needs Stripe SDK v12 upgrade first."
memory_search("stripe sdk upgrade")
โ gotcha: "Stripe SDK v12 changed webhook signature verification -
verify() is now async, breaks all sync handlers"Zero re-explanation. Claude picks up exactly where it left off, including the blocker you hadn't mentioned yet.
Subagent research: "What MCP frameworks exist?"
Without CogniLayer, the subagent returns a 40K-token dump into parent context:
Parent (200K context):
โ spawn subagent: "Research community MCP servers"
โ subagent returns: 40K tokens about 15 projects
โ all 40K crammed into parent context
โ remaining: 160K โ next subagent โ 120K โ next โ 80K...With CogniLayer's Subagent Memory Protocol:
Parent (200K context):
โ spawn subagent: "Research MCP servers, save to memory"
โ subagent writes details to DB, returns: "Saved 3 facts,
search 'MCP server ecosystem'. Summary: Python dominates,
FastMCP most popular, 3 architectural patterns."
โ parent context: ~500 tokens
โ need details? memory_search("MCP server ecosystem") โ targeted pull40K tokens compressed to 500. The findings persist in DB across sessions - not just for this conversation, but forever.
Killer Features
Feature | What it means |
Code Intelligence |
|
Semantic Search | Hybrid FTS5 + vector search finds the right fact even with different wording. Sub-millisecond response |
18 MCP Tools | Memory, code analysis, safety, project context - Claude uses them automatically, no commands needed |
Token Savings | 3 targeted queries (~800 tokens) replace 15 file reads (~60K tokens). Typical session saves 80-200K+ tokens |
Subagent Protocol | Research subagents save findings to DB instead of flooding parent context. 40K โ 500 tokens per subagent task |
Crash Recovery | Session dies? Next one auto-recovers from the change log. Works across both agents |
Cross-Project Knowledge | Solved a CORS issue in project A? Search it from project B. Your experience compounds |
14 Fact Types | Not dumb notes - error_fix, gotcha, api_contract, decision, pattern, procedure, and more |
Heat Decay | Hot facts surface first, cold facts fade. Each search hit boosts relevance |
Safety Gates | Identity Card system blocks deploy to wrong server. Audit trail on every safety change |
Agent Interop | Claude Code and Codex CLI share the same brain. Switch agents mid-task, zero context loss |
Session Bridges | Every session starts with a summary of what happened last time |
TUI Dashboard | Visual memory browser with 8 tabs - see everything at a glance |
How It Works
You start a session
โ
SessionStart hook fires โ injects project DNA, last session bridge, crash recovery
โ
You work normally - Claude saves facts, decisions, gotchas automatically via MCP tools
โ
You ask about code โ code_context / code_impact answer in milliseconds from AST index
โ
Session ends (or crashes)
โ
Next session starts with full context - no re-reading, no re-explainingZero effort after install. No commands to learn, no workflow changes. CogniLayer runs in the background via hooks and MCP tools. Claude knows how to use it automatically.
Quick Start
1. Install (30 seconds)
git clone https://github.com/LakyFx/CogniLayer.git
cd CogniLayer
python install.pyThat's it. Next time you start Claude Code, CogniLayer is active.
2. Optional: Turbocharge search
# AI-powered vector search (recommended - finds facts even with different wording)
pip install fastembed sqlite-vec3. Optional: Add Codex CLI support
python install.py --codex # Codex CLI only
python install.py --both # Claude Code + Codex CLI4. Verify
python ~/.cognilayer/mcp-server/server.py --test
# โ "OK: All 18 tools registered."Troubleshooting
MCP server not connecting? Run the diagnostic tool:
python diagnose.py # Check everything
python diagnose.py --fix # Check + auto-fix missing dependenciesRequirements
Python 3.11+
Claude Code and/or Codex CLI
pip packages:
mcp,pyyaml,textual(installed automatically),fastembed,sqlite-vec(optional),tree-sitter-language-pack(optional, for code intelligence)
Slash Commands (Claude Code only)
Once installed, use these in Claude Code:
Command | What it does |
| Show memory stats and project health |
| Search memory for specific knowledge |
| Extract and save knowledge from current session |
| Scan your project and build initial memory |
| Batch onboard all projects in your workspace |
| Delete specific facts from memory |
| Manage deployment Identity Card |
| Organize memory - cluster, detect contradictions, assign tiers |
| Launch the visual dashboard |
| Show all available commands |
Codex CLI users: Slash commands are not available in Codex. Instead, CogniLayer uses AGENTS.md instructions + MCP tools directly. See Codex CLI Integration below.
TUI Dashboard
A visual memory browser right in your terminal. 8 tabs, keyboard navigation, works on Windows, Mac, and Linux.
cognilayer # All projects
cognilayer --project my-app # Specific project
cognilayer --demo # Demo mode with sample data (try it!)Overview - stats at a glance

Facts - searchable, filterable, color-coded by heat

Heatmap - see which knowledge is hot, warm, or cold

Clusters - related facts organized into groups

Timeline - full session history with outcomes

Screenshots show demo mode (cognilayer --demo) with sample data.
Upgrading
The upgrade is safe and non-destructive. Your memory is never lost:
git pull
python install.pyWhat happens under the hood:
Code files are replaced with the latest versions
config.yamlis never overwritten (your settings are safe)memory.dbis backed up automatically before any migrationSchema migration is purely additive (new columns/tables, never deletions)
CLAUDE.md blocks update automatically on next session start
Rollback
If something goes wrong:
# Your backup is timestamped
cp ~/.cognilayer/memory.db.backup-YYYYMMDD-HHMMSS ~/.cognilayer/memory.db
# Restore old code
git checkout <previous-commit> && python install.pyConfiguration
Edit ~/.cognilayer/config.yaml:
# Language - "en" (default) or "cs" (Czech)
language: "en"
# Your projects directory
projects:
base_path: "~/projects"
# Indexer settings
indexer:
scan_depth: 3
chunk_max_chars: 2000
# Search defaults
search:
default_limit: 5
max_limit: 10Known Limitations
Concurrent CLIs: Running Claude Code and Codex CLI simultaneously on the same project may cause session tracking conflicts. Use one CLI at a time per project.
Codex file tracking: Codex CLI has no hooks, so automatic file change tracking is not available for Codex sessions.
Code intelligence: Requires
tree-sitter-language-pack(~20MB). Without it, all other 14 tools work normally.TUI: Requires
textualpackage. Read-only except for resolving contradictions.
Architecture (for the curious)
Everything below is for developers who want to understand how CogniLayer works under the hood.
System Overview
Claude Code / Codex CLI Session
โ
โโโ SessionStart hook (Claude Code) / session_init tool (Codex)
โ โโโ Injects Project DNA + last session bridge into CLAUDE.md
โ
โโโ MCP Server (18 tools)
โ โโโ memory_search - Hybrid FTS5 + vector search with staleness detection
โ โโโ memory_write - Store facts (14 types, deduplication, auto-embedding)
โ โโโ memory_delete - Remove outdated facts by ID
โ โโโ memory_link - Bidirectional Zettelkasten-style fact linking
โ โโโ memory_chain - Causal chains (caused, led_to, blocked, fixed, broke)
โ โโโ file_search - Search indexed project docs (chunked, not full files)
โ โโโ file_index - Index project docs (README, configs, PRD) into file_chunks
โ โโโ project_context - Get project DNA + health metrics
โ โโโ session_bridge - Save/load session continuity summaries
โ โโโ session_init - Initialize session for Codex CLI (replaces hooks)
โ โโโ decision_log - Query append-only decision history
โ โโโ verify_identity - Safety gate before deploy/SSH/push
โ โโโ identity_set - Configure project Identity Card
โ โโโ recommend_tech - Suggest tech stacks from similar projects
โ โโโ code_index - Index codebase via tree-sitter AST parsing
โ โโโ code_search - Find symbols (functions, classes, methods) by name
โ โโโ code_context - 360ยฐ view: callers, callees, child methods
โ โโโ code_impact - Blast radius analysis (BFS traversal of references)
โ
โโโ PostToolUse hook (Claude Code only)
โ โโโ Logs every file Write/Edit to changes table (<1ms overhead)
โ
โโโ PreCompact hook (Claude Code only)
โ โโโ Saves comprehensive bridge before context compaction
โ
โโโ SessionEnd hook / session_bridge(save)
โโโ Closes session, builds emergency bridge if neededFile Structure
~/.cognilayer/
โโโ memory.db # SQLite (WAL mode, FTS5, 17 tables)
โโโ config.yaml # Configuration (never overwritten by installer)
โโโ active_session.json # Current session state (runtime)
โโโ mcp-server/
โ โโโ server.py # MCP entry point (18 tools)
โ โโโ db.py # Shared DB helper (WAL, busy_timeout, lazy vec loading)
โ โโโ i18n.py # Translations (EN + CS)
โ โโโ init_db.py # Schema creation + migration
โ โโโ embedder.py # fastembed wrapper (BAAI/bge-small-en-v1.5, 384-dim)
โ โโโ register_codex.py # Codex CLI config.toml registration
โ โโโ indexer/ # File scanning and chunking
โ โโโ search/ # FTS5 + vector hybrid search
โ โโโ code/ # Code Intelligence (tree-sitter parsers, indexer, resolver)
โ โโโ tools/ # 18 MCP tool implementations
โโโ hooks/
โ โโโ on_session_start.py # Project detection, DNA injection, crash recovery
โ โโโ on_session_end.py # Session close, emergency bridge, episode building
โ โโโ on_file_change.py # PostToolUse file change logger + context monitoring
โ โโโ on_pre_compact.py # PreCompact bridge preservation
โ โโโ generate_agents_md.py # Codex AGENTS.md generator
โ โโโ register.py # Claude Code settings.json registration
โโโ tui/ # TUI Dashboard (Textual)
โ โโโ app.py # Main application (8 tabs, keyboard nav)
โ โโโ data.py # Read-only SQLite data access layer
โ โโโ styles.tcss # CSS stylesheet
โ โโโ screens/ # 8 tab screen modules
โ โโโ widgets/ # Heat cell, stats card widgets
โโโ logs/
โโโ cognilayer.logDatabase Schema (17 tables)
Table | Purpose |
| Registered projects with auto-generated DNA |
| 14 types of atomic knowledge units with heat scores |
| FTS5 fulltext index on facts |
| Indexed project documentation (PRDs, READMEs, configs) |
| FTS5 fulltext index on chunks |
| Append-only decision log |
| Session records with bridges, episodes, and outcomes |
| Automatic file change log (PostToolUse) |
| Identity Card (SSH, ports, domains, safety locks) |
| Safety field change audit trail |
| Reusable tech stack templates |
| Zettelkasten bidirectional links between facts |
| Tracked weak/failed searches |
| Memory consolidation output clusters |
| Detected conflicting facts |
| Cause โ effect relationship tracking |
| Search quality tracking (queries, hit counts, latency) |
| Indexed source files with hash-based change detection |
| AST-parsed symbols (functions, classes, methods, interfaces) |
| Symbol cross-references (calls, imports, inheritance) |
| Vector embeddings (sqlite-vec, optional) |
Hybrid Search
Two search engines combined for maximum recall:
FTS5 - SQLite fulltext search for exact keyword matching
Vector embeddings - fastembed (BAAI/bge-small-en-v1.5, 384-dim, CPU-only ONNX) with sqlite-vec for cosine similarity
Hybrid ranker - 40% FTS5 + 60% vector similarity, with heat score boosting
Vector search is optional - FTS5 works standalone without any extra dependencies.
Heat Decay
Facts have a "temperature" that models relevance over time:
Range | Label | Meaning |
0.7 - 1.0 | Hot | Recently accessed, high relevance |
0.3 - 0.7 | Warm | Moderately recent |
0.05 - 0.3 | Cold | Old, rarely accessed |
Decay rates vary by fact type - error_fix and gotcha facts decay slower (they stay relevant longer) than task facts. Each search hit boosts a fact's heat score.
Code Intelligence
Powered by tree-sitter AST parsing with language-pack support for 10+ languages:
Tool | What it does |
| Scans project files, parses AST, extracts symbols and references into SQLite. Incremental - only re-indexes changed files |
| FTS5 search over symbol names. Find any function, class, or method by name or partial match |
| 360ยฐ view of a symbol: definition, who calls it (incoming), what it calls (outgoing), child methods |
| Blast radius analysis - BFS traversal of incoming references. Shows what breaks at depth 1/2/3 |
Indexing runs with a configurable time budget (default 30s). Partial results are usable immediately. Unresolved references are re-resolved on the next incremental run.
Subagent Memory Protocol
When Claude spawns research subagents, the raw findings can be 40K+ tokens. Without the protocol, all of that goes into the parent's context window. The Subagent Memory Protocol uses the CogniLayer database as a side channel:
Subagent Parent
โ โ
โโโ research (WebSearch, Read...) โ
โโโ synthesize findings โ
โโโ memory_write(consolidated facts) โ โ data goes to DB, not context
โโโ return: 500-token summary โโโโโโโโโค โ only summary enters context
โ
memory_search() โโโค โ parent pulls details on demandKey design decisions:
Synthesis over granularity - subagents group related findings into cohesive facts, not one-per-discovery
Task-specific tags - each subagent gets a unique tag (e.g.
tags="subagent,auth-review") for filtering viamemory_search(tags="auth-review")Keywords inside facts - each fact ends with
Search: keyword1, keyword2so retrieval works even after context compactionWrite-last pattern - all
memory_writecalls happen as the last step before return, saving subagent turns and tokensForeground-first - subagents launch as foreground (reliable MCP access), user can Ctrl+B to background
Graceful fallback - if MCP tools are unavailable, findings go directly in return text
The protocol is injected into CLAUDE.md automatically and requires no user configuration.
Codex CLI Integration
Codex CLI has no hook system, so CogniLayer adapts:
Aspect | Claude Code | Codex CLI |
Config |
|
|
Hooks | SessionStart/End/PreCompact/PostToolUse | None - uses MCP tools + AGENTS.md instructions |
Instructions |
|
|
Session init | Automatic via hook |
|
Onboarding |
|
|
File tracking | Automatic via PostToolUse | Not available (acceptable limitation) |
Same memory database shared between both CLIs.
Codex onboarding workflow
AGENTS.md includes a FIRST RUN section that instructs Codex to:
session_init()- register project, load DNA + bridgefile_index()- index documentation files sofile_searchworkscode_index()- index source code socode_search/context/impactworkRead key files and save findings via
memory_write()(the AI does intelligent analysis)
This matches what /onboard does in Claude Code, but through AGENTS.md instructions instead of a slash command.
Project Identity Card
Deployment safety system that prevents "oops, wrong server" incidents:
Safety locking - locked fields require explicit update + audit log entry
Hash verification - SHA-256 detects tampering of safety-critical fields
Required field checks -
verify_identityblocks deploy if critical fields are missingAudit trail - every safety field change is logged with timestamp and reason
Contributing
Contributions are welcome! Please open an issue first to discuss what you'd like to change.
License
Elastic License 2.0 - Free to use, modify, and distribute. You may not provide it as a managed/hosted service.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Shared memory for coding agents. Stop re-explaining your codebase every session.
Give your AI agent a persistent map of your project's structure, dependencies, and bugs.
Persistent memory and knowledge graphs for AI agents. Hybrid search, context checkpoints, and more.
- vibsyncOAuthcom.vibsync
One shared brain for your AI coding agents: team memory, agent Q&A, tasks, and file claims.
Related MCP Servers
- AlicenseCqualityAmaintenanceProvides AI assistants with persistent memory and code intelligence across all tools and conversations. Features semantic search, knowledge graphs, decision tracking, and impact analysis with 60+ tools for universal context preservation.3685241MIT
- AlicenseNot gradedqualityDmaintenanceProvides AI coding assistants with persistent, context-rich memory of a codebase, including documentation and git history, enabling recall across sessions.104Apache 2.0
- AlicenseAqualityAmaintenanceProvides persistent memory and a codebase knowledge graph for AI coding assistants, enabling shared context across multiple tools like Claude, Cursor, and ChatGPT, with significant token reduction.525MIT
- AlicenseNot gradedqualityCmaintenanceProvides AI coding agents with persistent, graph-connected memory across projects, enabling cross-project context retrieval via synaptic connections and hybrid search.156MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/CyberdaemonAI/CogniLayer'
If you have feedback or need assistance with the MCP directory API, please join our Discord server