Skip to content

Repository files navigation

ContextCore

A local-first, user-owned long-term context layer for AI Agents.

English · 中文

CI License: MIT Backend Frontend Desktop MCP Status


Prototype / Development: ContextCore is a local-first development build. It is suitable for local testing, dogfooding, and open-source review. It does not yet promise cloud sync, signed desktop distribution, multi-user deployment, or hot-swappable multi-database workspaces.

ContextCore is a desktop app that gives AI Agents a shared, user-owned long-term memory through the Model Context Protocol (MCP). Agents read your context, and any write-back goes through your approval — with full audit logs, encrypted backup/restore, and Skill distillation.

Your context stays on your machine. No vendor lock-in, no silent writes.

ContextCore knowledge workspace

Why ContextCore?

Today every Agent (Claude Code, Codex, Cursor, …) starts cold and forgets what it learned. ContextCore turns your context into a persistent, portable layer that every Agent can plug into:

User-owned context
  → Agent reads via MCP
  → Agent proposes drafts / stale items / Skills
  → You review and approve
  → ContextCore updates Memory / Rule / Task / Feedback / Skill
  → Next Agent run starts with better context

The core principle: by default the Agent never writes directly to your official knowledge. It can only create pending proposals you explicitly approve. Direct writes are possible only when both the agent's permission and the knowledge-type policy are explicitly set to allow — an advanced opt-in, never the default.

Features

  • 🧠 My Knowledge Base — six context types (Source / Memory / Rule / Task / Feedback / Skill), with search, filter, and import (Markdown/TXT/JSON).
  • ✅ Approval Inbox — every Agent write-back, delete, or "mark outdated" request waits for your approval. Nothing is silent.
  • ⚒️ Workflow Foundry — Agents distill reusable Skills from your knowledge and audit logs; you confirm, edit, activate, and run them.
  • 🔌 Real MCP server — Streamable HTTP at /mcp/ and stdio entrypoint, exposing twelve tools (see below).
  • 🛡️ Data sovereignty — ZIP backup, optional AES-256-GCM passphrase-encrypted .ccbackup, SQLite integrity checks, and rollback copies before restore.
  • 📋 Audit log — every Agent action is recorded and filterable by agent, action, and time window.
  • 🔍 Optional semantic layer — bring your own OpenAI-compatible embeddings for hybrid search; falls back to keyword/BM25 search when no API key is set.

MCP tools exposed to Agents

Tool Purpose
search_knowledge Search across your context items
get_context_pack Fetch a curated context bundle
get_skills List activated Skills
get_distill_context Gather knowledge/audit context before distilling a Skill
distill_skill Submit a reusable Skill draft (stays pending until you confirm)
write_draft Propose a new context item (pending approval)
write_emergence Submit an emergence insight (pending approval by default)
delete_emergence Archive an emergence item (only when policy explicitly allows)
mark_outdated Flag an item as stale (pending approval)
suggest_delete Request deletion (pending approval)
get_emergence_context Gather context for an emergence analysis
submit_emergence_report Submit an emergence analysis report

Architecture

flowchart LR
  User["User approval"] --> UI["Tauri / React UI"]
  UI --> API["FastAPI sidecar REST API"]
  API --> DB[("Local SQLite")]
  API --> MCP["MCP tools at /mcp/ and stdio"]
  MCP --> Agents["Claude Code / Codex / Cursor / LobsterAI / Hermes"]
  Agents --> MCP
  MCP --> Drafts["Drafts, stale marks, delete requests, Skill proposals"]
  Drafts --> User
Loading
app/
├── backend/    # FastAPI + SQLite, REST API + MCP server (Streamable HTTP & stdio)
├── frontend/   # React + Vite desktop UI (5 workspace pages)
└── src-tauri/  # Tauri v2 desktop shell, bundles the backend as a sidecar

Quick start

Requirements: Python ≥ 3.10, Node.js ≥ 18.

Backend:

cd app/backend
python3 -m venv .venv
.venv/bin/python -m pip install -r requirements.txt
.venv/bin/uvicorn app.main:app --host 127.0.0.1 --port 8420

Frontend:

cd app/frontend
npm install
npm run dev -- --port 5173

Then open http://127.0.0.1:5173.

Optional: semantic search

export OPENAI_API_KEY="..."
export OPENAI_BASE_URL="https://api.openai.com/v1"
export CONTEXTCORE_LLM_MODEL="gpt-4o-mini"
export CONTEXTCORE_EMBEDDING_MODEL="text-embedding-3-small"

Without an API key, ContextCore keeps keyword/BM25 search and works normally.

See .env.example and app/backend/.env.example for the full local configuration surface.

Connecting an Agent

In the app, go to Admin Console → Agent Connections to copy a ready-made MCP config for Claude Code, Codex, Cursor, and more. The first MCP call auto-registers the Agent; the connection test reports the last action, result, and any permission block.

Validation

# backend
cd app/backend && .venv/bin/pytest -q

# frontend
cd app/frontend
npm run lint
npm run typecheck
npm run test -- --run
npm run build

Desktop build

macOS arm64 is currently the verified target. Builds are heavy; run them on a capable machine.

cd app/backend
.venv/bin/python -m PyInstaller --clean --onedir --name contextcore-backend desktop_backend.py

cd ..
npx @tauri-apps/cli build

Artifacts land in app/src-tauri/target/release/bundle/.

Runtime notes

  • The SSE event bus is an in-process queue for local single-user use. Do not run with uvicorn --workers 2+ without replacing it with Redis or another shared pub/sub.
  • Events are pushed only after the SQLite transaction commits, so the UI never sees uncommitted data.
  • The desktop package uses a PyInstaller onedir sidecar and shows a startup screen until the local backend is healthy.
  • Workspaces currently separate project context in the UI and metadata. They are not yet hot-swappable physical databases in the running app.
  • REST and MCP endpoints are unauthenticated local endpoints. Keep the backend bound to 127.0.0.1; do not expose port 8420 to shared networks.

Project status

This is an actively developed prototype. See app/IMPLEMENTATION_STATUS.md for what's done and the known gaps (real-client acceptance, notarization/signing, multi-workspace runtime). Product blueprint lives in PRD.md.

Legacy material

The legacy/ folder holds reference assets from an earlier IMA / WeRead knowledge-pipeline workflow (Skills, build scripts, old deploy prompts). They are not part of the ContextCore app — see legacy/README.md.

License

MIT © AI理享派

About

Local-first Agent context base with MCP, approval inbox, audit, backup, and Skill distillation.

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages