Skip to main content
Glama

Cortical

Zero-dependency MCP control plane for private, local-first AI agents.

ccancellieri/cortical MCP server License: Apache-2.0 Python 3.10+ Stdlib Only GitHub Stars Live Demo & Docs

Cortical is a zero-server, Python 3.10+ standard-library (dependencies = []) MCP server and declarative agent control plane. It protects private files before they ever reach a cloud LLM, compresses structured payloads losslessly with TOON, offloads routine reads and reviews to local models at $0 cloud cost, and synchronizes MCP configuration across 8 coding harnesses.

  • Live Zero-Install Demo: ccancellieri.github.io/cortical | settings.html (zero CDNs, 3 one-click hardware presets)

  • Zero External Dependencies: dependencies = [] in pyproject.toml. Auditable Python stdlib only, zero supply-chain bloat.

  • Zero Persistent Daemons: Default stdio MCP transport. Interactive Prompt Studio (cortical next) binds a one-shot 127.0.0.1:0 loopback listener guarded by a 256-bit single-use token and shuts down immediately on submit.

  • Works With or Without Local LLMs: Tier-1 Privacy Vault (.md, .txt, .json, .docx, .xlsx, .pptx, selectable .pdf metadata strip + PII/secret redaction + SHA-256 audit ledger), lossless TOON compression, doctor, and 8-harness sync run 100% deterministically in Python stdlib.


90-Second Video Demos

  1. Privacy Vault + Lossless TOON (-78% Tokens) in pi CLI - Zero-LLM fail_closed PII/metadata masking, deterministic TOON compression, and $0 local offload.

  2. Sync 8 AI Coding Harnesses with 1 Command + Rollback - Idempotent --dry-run sync, timestamped --rollback, and the static zero-CDN control plane (settings.html).

  3. Run 27B Local Models at 65K Context on a 16GB Laptop - Hardware preflight (cortical doctor), variable-quant 27B at 65,536 context in 9.08 GiB VRAM, and local offload across 7 runners.


Related MCP server: io.github.admiralpunk/provena-memory

Why Cortical

Most MCP servers are thin API wrappers that introduce heavy runtime dependencies, leave sensitive files exposed to cloud prompts, and force every developer to maintain separate configs for Claude Desktop, Cursor, Windsurf, OpenCode, Codex, and local runners.

Cortical solves the four architectural gaps that standalone wrappers leave open:

  1. Deterministic Fail-Closed Privacy Boundary: Files classified as max_security or fail_closed cannot leave the machine. Structured PII, secrets, custom terms, and Office/PDF metadata are stripped locally with a verifiable SHA-256 ledger before any cloud call.

  2. Lossless Payload Compression (TOON): Compresses JSON payloads by -78.12% vs pretty JSON (-62.09% vs compact JSON) with deterministic round-trip fidelity and automatic fallback when savings are below 10%.

  3. Hardware-Aware Local Offload (7 Runners, 10 @role:* Slots): Never hardcodes model tags. Maps semantic roles (@role:router, @role:daily_coder, @role:reviewer, @role:summarizer, @role:deep_reasoner, @role:vision, @role:tech_communicator) across Ollama, Unsloth Studio, LM Studio, llama.cpp, Apple MLX, vLLM, and any openai_compatible endpoint.

  4. Declarative Cross-Harness Sync + Prompt Studio: Keeps MCP definitions, memory rules, and cross-harness handoffs aligned across Claude Code, Cursor, Windsurf, Antigravity, OpenCode, Codex, pi, dsh, and Unsloth Studio with --dry-run previews and timestamped --rollback.


Architecture

flowchart LR
    subgraph Clients["MCP Clients & Harnesses"]
        C1["Claude Desktop / Code"]
        C2["Cursor / Windsurf"]
        C3["OpenCode / Codex / pi / Antigravity"]
    end

    subgraph ControlPlane["Cortical MCP Control Plane (Python 3.10+ Stdlib, 0 Deps)"]
        MCP["MCP Server (stdio / streamable-http)"]
        Vault["Privacy Vault & 3+1 Second Brain (auto | fail_closed | fail_open)"]
        TOON["Lossless TOON & Log Compressor"]
        Studio["Prompt Studio (127.0.0.1:0 Ephemeral Elicitor)"]
        ROI["Zero-Token ROI & Handoff Ledger"]
    end

    subgraph Execution["Execution Backends"]
        Local["Local Runners (Ollama, Unsloth, LM Studio, MLX, llama.cpp, vLLM)"]
        Cloud["Remote Cloud LLMs (Sanitized & TOON-Compressed Only)"]
    end

    Clients -->|"JSON-RPC 2.0"| MCP
    MCP --> Vault
    MCP --> TOON
    MCP --> Studio
    MCP --> ROI
    Vault -->|"max_security stays local"| Local
    TOON -->|"Sanitized + Compressed"| Cloud
    MCP -->|"Zero-cloud-token offload"| Local

Quickstart (Copy-Paste, Zero Friction)

Option A: Local Python (Zero External Dependencies)

git clone https://github.com/ccancellieri/cortical.git && cd cortical
python3 -m venv .venv && .venv/bin/pip install --no-deps -e .

# Verify hardware tier, Tier-1 Zero-LLM Privacy Vault & benchmarks
PYTHONPATH=src .venv/bin/python -m cortical.cli doctor
PYTHONPATH=src .venv/bin/python -m cortical.cli bench --compare

Option B: Docker (Reproducible Containerized MCP)

docker build -t cortical-mcp .
docker run -i --rm cortical-mcp

Option C: Connect Your MCP Client

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "cortical": {
      "command": "python3",
      "args": ["-m", "cortical.mcp_server"],
      "env": {
        "PYTHONPATH": "/absolute/path/to/cortical/src",
        "CORTICAL_VAULT_DB": "/absolute/path/to/cortical/.cortical_data/vault.db"
      }
    }
  }
}

Cursor (.cursor/mcp.json) & Windsurf (~/.codeium/windsurf/mcp_config.json)

{
  "mcpServers": {
    "cortical": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "cortical-mcp"]
    }
  }
}

Or run PYTHONPATH=src .venv/bin/python -m cortical.cli sync --dry-run to preview automatic configuration across all 8 supported harnesses (see docs/INTEGRATIONS.md).


MCP Capabilities

Cortical exposes a focused surface of 8 Core Tools (all with MCP annotations and outputSchema), Native Resources, and 3 Reusable Prompts.

Tools (8)

Tool

Purpose

Key Inputs

Example Prompt

cortical_ingest_private

Sanitize a file, directory, or raw text into the Privacy Vault (auto, fail_closed, fail_open).

path_or_text (req), alias, policy, profile, task_tags

"Ingest ./contracts/client_brief.pdf as client_brief with fail_closed policy."

cortical_vault_read

Read a sanitized vault item or task-tagged group at 3+1 depth (light, medium, high, max). Blocks max_security from cloud egress.

alias, task_tag, tier

"Read @private:client_brief at medium tier so we can draft the architecture plan safely."

cortical_compress

Deterministically compress JSON (lossless TOON), XML, YAML, or verbose logs.

text (req), format

"Compress this API response JSON using cortical_compress before storing it in context."

cortical_doctor_status

Inspect CPU/RAM/GPU tier, active local runners, and composed OSS tools (Serena, RTK).

(none)

"Run cortical_doctor_status to check which local models fit my 16 GB laptop."

cortical_local_offload

Delegate file reading, summarization, or code review to a local runner via @role:* at $0 cloud tokens.

prompt (req), role, model, file_paths, vault_alias

"Offload reviewing src/cortical/mcp_server.py to @role:reviewer using cortical_local_offload."

cortical_roi_report

Compute local vs. cloud token usage, USD savings, and remaining cloud budget at zero cloud token cost.

conversation_id, include_local_summary

"Generate my session token savings report with cortical_roi_report."

cortical_handoff

Save or load structured task context (goal, modified files, next step) when switching between harnesses.

action (req: save|load), goal, summary, modified_files, next_step

"Save a cross-harness handoff so I can resume this refactor in OpenCode."

cortical_next_prompt

Harvest repo/issue/ADR state, run the 5-Trigger confidence gate or ephemeral browser questionnaire, and synthesize a high-precision continuation prompt.

seed, mode, persona, lang, detail_tier, attach_paths, target

"Run cortical_next_prompt in colleague mode on my project folder to plan the next milestone."

Resources & Prompts

Type

Identifier

Description

Resource

cortical://private/<alias>

Sanitized read-only view of any vault item (automatically blocks max_security from remote cloud egress).

Resource

cortical://brain

Factorized 3+1 Local Second Brain index (concepts, reconciled facts, tasks, curated skills).

Prompt

cortical-private

Inject sanitized @private:<alias> context into the active conversation (omit alias to list items).

Prompt

cortical-local

Execute a task offline on the configured local model runner without spending cloud tokens.

Prompt

cortical-next-prompt

Launch Prompt Studio to synthesize or interactively elicit the next continuation prompt.


2-Tier Capability Matrix & Reproducible Benchmarks

Measured offline via PYTHONPATH=src .venv/bin/python -m cortical.cli bench --compare and docs/METRICS_LEDGER.md:

Capability

Execution Tier

Local LLM Needed?

Verified Result

Privacy Vault, Metadata Strip & SHA-256 Ledger

Tier 1 (Zero-LLM Stdlib)

No

100% structured PII masked, 100% technical prose preserved

Lossless TOON Compression

Tier 1 (Zero-LLM Stdlib)

No

-78.12% vs pretty JSON (-62.09% vs compact JSON)

Hardware Preflight & 8-Harness sync

Tier 1 (Zero-LLM Stdlib)

No

--dry-run preview + timestamped --rollback <id>

Lean 8-Tool MCP Handshake

Tier 1 (Zero-LLM Stdlib)

No

~1-4 ms ingest+read round-trip, zero external deps

Local Offload (file_paths) & Vision OCR

Tier 2 (Local Runner)

Yes (@role:*)

-95.80% cloud input tokens at $0 cloud cost


Daily CLI Commands & Verification

# Workspace init, IDE integration & drift reconciliation
PYTHONPATH=src .venv/bin/python -m cortical.cli init -y
PYTHONPATH=src .venv/bin/python -m cortical.cli integrate --list
PYTHONPATH=src .venv/bin/python -m cortical.cli reconcile --dry-run --json

# Privacy Vault, Bulk Disk Privatizer & AI Colleague Prompt Studio
PYTHONPATH=src .venv/bin/python -m cortical.cli privatize ./client_docs --tier medium
PYTHONPATH=src .venv/bin/python -m cortical.cli colleague "Prepare an anonymized risk summary" --attach ./client_docs
PYTHONPATH=src .venv/bin/python -m cortical.cli next "Add multi-runner health metrics" --target pi

# Static zero-CDN browser control plane, ROI telemetry & test suite (64/64 passing)
PYTHONPATH=src .venv/bin/python -m cortical.cli dashboard --out-dir html --open
PYTHONPATH=src .venv/bin/python -m cortical.cli roi
PYTHONPATH=src .venv/bin/python -m unittest discover -s tests -q

Codebase footprint (v0.3.0, verifiable via wc -l): 7 Python subpackages totaling 22,230 LOC (18,139 Core Python/CLI/Second Brain/Prompt Studio/Wiki + 4,091 embedded zero-CDN SPA modules) backed by 64/64 passing unittest tests (3,224 test LOC). See SECURITY.md for the fail-closed security policy and docs/adr/README.md for Architecture Decision Records.


Author & Vision

Cortical is designed and maintained by Carlo Cancellieri, Software Architect and open-source builder focused on local-first AI infrastructure, privacy-preserving developer tooling, and verifiable multi-agent systems.

The vision behind Cortical is pragmatic: developers and professionals should not have to choose between frontier AI productivity and data sovereignty. By keeping the control plane zero-dependency, auditable, and strictly local-first, Cortical makes privacy guardrails, lossless token economics, and multi-runner orchestration a default layer rather than an afterthought.

Available Tools

8 tools
cortical_compressB
Read-onlyIdempotent

Deterministically compress JSON (to lossless TOON with compact fallback), XML, or verbose logs.

Inputs: text (required), format. Returns: compressed, saving_pct, format_used, raw_tokens_est, +1 more

cortical_doctor_statusA
Read-onlyIdempotent

Inspect machine hardware tier (incl. 4GB VRAM Hybrid & 16GB Unified 27B), installed local models, and composed OSS tools.

Inputs: no named parameters. Returns: models, routing, hardware, composers

cortical_handoffA
Idempotent

Save or load shared working context (goal, modified files, decisions, next_step) across Antigravity, pi, OpenCode, Claude Code & Codex.

Inputs: action (required), goal, summary, next_step, +2 more. Returns: path, found, saved, handoff

cortical_ingest_privateB
Idempotent

Ingest a local file or text into Privacy Vault with dynamic auto | fail_closed | fail_open classification.

Inputs: path_or_text (required), alias, policy, profile, +1 more. Returns: uri, alias, profile, local_only, +4 more

cortical_local_offloadA
Read-only

Delegate summarization/analysis/review to configured local Ollama/Unsloth model (0 cloud tokens).

Inputs: prompt (required), role, model, file_paths, +1 more. Returns: response, model_used, elapsed_sec, completed_locally

cortical_next_promptA

Harvest repo/issue/ADR state + loop_memory, run 5-Trigger confidence gate or open one-shot ephemeral loopback browser questionnaire, and synthesize a high-precision continuation prompt.

Inputs: lang, mode, seed, issue, +9 more. Returns: ok, prompt, target, escalated, +3 more

cortical_roi_reportB
Read-onlyIdempotent

Compute local vs cloud token usage, USD savings, and remaining cloud budget (0 cloud tokens).

Inputs: conversation_id, include_local_summary. Returns: markdown, local_note, effective_mode, handoff_recommended, +3 more

cortical_vault_readA
Read-onlyIdempotent

Read a Vault item by alias OR all items matching a task_tag at 3+1 depth (light, medium, high, max; blocks max_security from cloud).

Inputs: tier, alias, task_tag. Returns: uri, text, tier, alias, +7 more

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 8 tools

    Disambiguation4/5

    Each tool targets a fairly distinct action: vault read, ingest, compress, local offload, ROI reporting, handoff, next-prompt synthesis, and environment diagnosis. The only mild overlaps are cortical_local_offload vs cortical_compress (both token-saving) and cortical_doctor_status vs cortical_roi_report (both diagnostic), but the descriptions make the boundaries reasonably clear.

    Naming Consistency3/5

    All names share a consistent `cortical_` prefix and snake_case, which helps grouping. However, the ordering convention is mixed: some are verb_noun (vault_read, ingest_private, local_offload), others are noun_noun or adjective_noun (doctor_status, roi_report, next_prompt, handoff), so the pattern isn't fully predictable.

    Tool Count5/5

    Eight tools is well within the ideal range for a focused local/private LLM orchestration server. Each tool maps to a distinct stage of the workflow (ingest → compress → offload → report → handoff → next prompt) with no obvious filler.

    Completeness3/5

    The vault surface is lopsided: read and ingest exist but there is no delete, update, or alias-listing operation, which is a real gap for a privacy vault. Likewise cortical_compress produces a lossless TOON form with no corresponding decompress/expand tool, and doctor_status only inspects configuration with no tool to change it.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to use a neuro-symbolic memory fabric with bi-temporal knowledge graph and holographic VSA, providing tools for adding, searching, temporal queries, auditing, and proving memories with cryptographic provenance and zero-LLM ingest.
      2
      Apache 2.0
    • A
      license
      B
      quality
      C
      maintenance
      Enables AI agents to store, semantically recall, update, forget, consolidate, and verify persistent memories with session isolation and hyperbolic concept navigation. It also supports knowledge-graph linking and claim verification for anti-hallucination workflows.
      16
      MIT