MCP-CORTEX-INTELLIGENT

// MAKE ORDINARY LLMS SMARTER — OFFLINE · NO API KEYS · NO CLOUD

Cortex Intelligent is an MCP server that augments an ordinary LLM with context, procedures, memory, exemplars, verification, and an internal decision engine. Everything runs locally. No API keys. No cloud. No model gateway. The model becomes smarter by following structured guardrails and checking real execution feedback.

OFFLINE-FIRST NO API KEYS 61 TOOLS STDIO MCP MIT LICENSE NODE >= 22.12
62MCP Tools
259Tests Passing
0API Keys
100%Offline

Features

Auto-Provision Agent & Skill

Idempotent marker-block append. Never overwrites user content. Backup before write.

Model Awareness + Guardrails

Detects model tier (weak/medium/strong) and injects anti-blunder procedures.

Offline Cognitive Augmentor

Exemplar retrieval, structured self-critique, compliance scoring, verification runner.

Internal Decision Engine

Fast deterministic decisions (tier/risk/route/compliance) via heuristics. No LLM.

Plan & Task Management

AI Agent → SKILL.md → AGENTS.md → PLAN.md ↔ CORTEX_EXECUTE ↔ TASK.md ↔ CORTEX_VERIFY → DONE. Persistent task tracking.

Knowledge Base + Memory

Hybrid search (BM25 + vector + RRF), long-term memory with decay.

Installation

Requirements

From source

git clone https://github.com/adyoi/mcp-cortex-intelligent.git cd mcp-cortex-intelligent npm install npm run build npm start

From npm (after publish)

npx mcp-cortex-intelligent

Configuration

Copy .env.example to .env and edit. Environment variables always win over the file.

VariableDefaultPurpose
CORTEX_DB_DIR.cortex-dataSQLite store location
CORTEX_MODEL(auto)Override model
CORTEX_TIER_OVERRIDE(auto)Override tier
CORTEX_VERIFY_ALLOWLISTnpm test,npm run lint,npm run typecheckVerification commands
CORTEX_VERIFY_TIMEOUT_MS300000Verification timeout
CORTEX_SELF_CRITIQUE_THRESHOLD0.8Revision threshold
CORTEX_SELF_CRITIQUE_MAX_ITERS3Max self-critique iterations
CORTEX_PROVISION_BACKUP1Backup before write
CORTEX_GUARDRAILS_STRICT1Enforce guardrails
EMBEDDING_PROVIDERlocallocal / transformers
EMBEDDING_MODELXenova/all-MiniLM-L6-v2Embedding model
SEARCH_MODEhybridhybrid / vector / keyword
KB_MEMORY_HALF_LIFE_DAYS14Memory decay half-life

OpenCode registration

Add to ~/.config/opencode/opencode.json:

{ "mcp": { "cortex": { "type": "local", "command": ["node", "~/mcp-cortex-intelligent/dist/index.js"], "cwd": "~/mcp-cortex-intelligent", "environment": { "CORTEX_DB_DIR": "~/mcp-cortex-intelligent/.cortex-data" } } } }

Tools (62)

#ToolPurpose
1system_statsDB, embedding, counts, verifier status
2lsp_diagnosticsRun language-server-style diagnostics (tsc/pyright/cargo/go vet)
3cognitive_statusSession summary: model, tier, calls, scores, verification, decision
4bootstrap_sessionDetect root, provision agent+skill, record session state
5provision_agent_skillProvision or append (idempotent, force version)
6list_agents_skillsInventory agent/skill files + auto-block versions
7update_procedure_blockUpdate auto block with new version
8detect_modelDetect model from env/config/arg
9get_model_profileProfile & tier of a model
10set_modelOverride model for session
11get_guardrailsProcedure + anti-blunder + verification (injectable)
12model_decisionInternal tier/risk/route/needsVerify decision
13knowledge_ingest_textIngest text
14knowledge_ingest_fileIngest file
15knowledge_ingest_dirIngest directory
16knowledge_searchHybrid search (BM25 + vector + RRF)
17knowledge_retrieveReady-to-inject context block + token count
18knowledge_list_documentsList documents (paginated)
19knowledge_document_statsDocument storage statistics
20knowledge_delete_documentDelete document + chunks + FTS
21knowledge_sync_sessionIngest OpenCode session inputs
22knowledge_reindexRe-embed all vectors in place
23knowledge_backupConsistent SQLite snapshot (VACUUM INTO)
24memory_rememberSave long-term memory
25memory_recallSemantic memory search (decay + recall count)
26memory_contextCompact context block from memories
27memory_listList memories (filter type/tag/importance)
28memory_getGet memory by id
29memory_updateUpdate memory content/type/importance/tags
30memory_forgetDelete memory
31memory_consolidateDedupe + promote hot memories
32memory_statsCounts, tokens, importance, by type
33self_critiqueChecklist + scoring + issues (no LLM)
34score_complianceCheck completeness of required steps
35run_verificationRun allowlisted test/lint/typecheck
36decision_classifyInternal decision (tier/risk/route/compliance)
37decision_healthHealth of internal decision engine
38get_procedureGet procedure by name
39list_proceduresList all procedures
40ingest_procedureStore a new procedure
41retrieve_exemplarsRetrieve best exemplars for a task
42ingest_exemplarStore a high-quality exemplar
43init_planInitialize PLAN.md if missing (idempotent)
44read_planRead PLAN.md content
45update_plan_sectionUpdate a PLAN.md section by heading
46init_taskInitialize TASK.md if missing (idempotent)
47init_agentsInitialize AGENTS.md if missing (idempotent)
48init_auditInitialize AUDIT.md if missing (idempotent)
49task_createCreate a new task
50task_listList tasks (filter status/priority)
51task_getGet task by id
52task_startSet task status to doing
53task_doneSet task status to done
54task_blockSet task status to blocked + reason
55task_deleteDelete a task
56task_updateUpdate task title/priority/owner/plan_ref/notes
57task_sync_mdWrite TASK.md from DB
58task_summarySummary of task statuses
59task_from_planAuto-generate tasks from PLAN.md step/bullet lines
60webfetchFetch URL (with SSRF guard, timeout, ingest option)
61webfetch_validateValidate URL for webfetch (no fetch)
62browser_fetchFetch URL via headless browser (playwright/puppeteer), falls back to webfetch

Workflow

Bootstrap Session

  1. Call bootstrap_session(project_root).
  2. Detect model → model_decision → set session state.
  3. Provision agent & skill (append if exists).
  4. Inject guardrails via get_guardrails(task="session_start").

Task Execution

  1. get_guardrails(task_type) → checklist.
  2. retrieve_exemplars(task) → best examples.
  3. Plan → Read → Edit → Verify → Review.
  4. run_verification() → real feedback.
  5. score_compliance(plan) + self_critique(artifact).

Plan & Task Loop

  1. init_plan + init_task.
  2. Agent reads PLAN.md → picks next task.
  3. task_list(status="todo") → choose.
  4. task_start(id) → doing.
  5. Execute with guardrails + verification.
  6. task_done(id) after verification passes.
  7. task_sync_md() → write TASK.md.
flowchart LR A[AI Agent] --> B[SKILL.md] B --> C[AGENTS.md] C --> D[memory_context] D --> E[PLAN.md] E --> F[get_guardrails] F --> G[CORTEX_EXECUTE] G <--> H[TASK.md] H <--> I[CORTEX_VERIFY] I -- pass --> J[DONE] I -- fail --> G

Security

Troubleshooting

Tools not showing up

Check config filename (opencode.json), location (global: ~/.config/opencode/opencode.json), cwd, and CORTEX_DB_DIR. Restart OpenCode.

Slow first start

tsx compiles TypeScript on first run; subsequent calls are fast. Use compiled dist/ entry.

Verification runner blocked

Only allowlisted commands run. Adjust CORTEX_VERIFY_ALLOWLIST.

Development

npm install npm run typecheck npm run lint npm run build npm test npm start