How andrewcharly1/mcum works
Purpose and entry points
MCUM is a local, PostgreSQL-native MCP orchestration, audit, and persistent-memory layer installed per workspace. The primary user entry point is the Node CLI at bin/mcum.mjs, published through package.json; it installs/configures the Python runtime and agent bridges. Runtime request entry is the Python dispatcher core/dispatcher.py, with direct query utilities in mcum_query.py and simple_query.py.
Agent-to-brain boundary
Agents do not access PostgreSQL directly. MCP-capable clients connect through Node/stdio bridges, which invoke the Python brain:
• Local MCP bridge: integrations/antigravity/mcum_local_mcp_stdio.mjs
• OpenClaw bridge: integrations/openclaw/openclaw_bridge.py
• Agent definitions: agents/openai.yaml
This boundary centralizes tool execution, policy enforcement, session context, and audit recording before any persistence operation.
Request orchestration and lifecycle
core/dispatcher.py is the main tool-routing/control-plane layer. It coordinates task intake, project context, agent execution, and state recording:
• Context assembly/planning: core/project_context_orchestrator.py, core/context_query_planner.py
• Session lifecycle and playbooks: core/session_manager.py, workspace_session.py, db/session_playbooks.py
• Worker execution/model selection: core/worker_runner.py, core/model_router.py, core/multi_agent.py
The expected flow is agent request → bridge → dispatcher → context/policy/session services → database-backed execution result and memory updates.
PostgreSQL memory and graph persistence
PostgreSQL is the system of record; schema and seeds live in db/schema.sql and db/seed_minimal.sql. Connection/runtime provisioning supports existing databases, Docker/pgvector, or an embedded persistent PostgreSQL:
• Connection/provisioning: db/connection.py, db/embedded_pg.mjs
• Vector embeddings: db/embedder.py, db/pgvector_util.py
• Cross-domain graph storage: db/unified_graph_store.py, db/code_graph_store.py, db/graph_intelligence_store.py
Semantic retrieval combines stored records and embeddings; vector acceleration depends on pgvector/HNSW where available.
Code and artifact knowledge graph
The graph subsystem indexes workspace code and non-code artifacts into a queryable dependency/intelligence graph:
• Index/sync lifecycle: core/code_graph_autoindex.py, core/code_graph_indexer.py, core/code_graph_sync.py
• Extraction boundary: core/graph_extractors/tree_sitter_extractor.py, core/graph_extractors/artifact_extractor.py
• Query, impact, analytics, and export surfaces: core/graph_query_service.py, core/graph_impact.py, core/graph_analytics.py
Tree-sitter and media/artifact adapters isolate source-format parsing from graph persistence and planner-facing queries.
Knowledge, patterns, and self-improvement
Long-lived organizational knowledge is managed separately from code graph data, with taxonomy/routing and semantic/shadow stores:
core/knowledge_library_router.py, db/knowledge_library_semantic.py, db/knowledge_library_shadow.py.
Pattern discovery materializes reusable execution knowledge through core/pattern_discovery.py and db/pattern_store.py. SISL then generates, evaluates, and evolves skills: sisl/autonomous_loop.py, sisl/skill_writer.py, core/skill_factory.py.
Policy, quality gates, and operations
Policies are data-driven JSON directives, interpreted by enforcement services rather than embedded in agent clients:
directives/execution_policy.json, directives/graph_policy.json, core/graph_policy.py.
Operational safeguards include loop prevention (anti_loop.py), memory freshness/governance (memory_freshness.py, memory_governor.py), specifications/contracts (core/spec_contract.py), and connector health (core/connector_health.py). A lightweight optional dashboard exposes persisted operational data via integrations/dashboard/server.py and integrations/dashboard/data_service.py.
Main entry points: schema.sql PostgreSQL system of record · dispatcher.py Request dispatcher · project_context_orchestrator.py Context planning · mcum_local_mcp_stdio.mjs MCP agent bridges
Components 21
Entry & Agent Bridges
- MCUM CLI · Installs and configures the local runtime and bridges.
bin/mcum.mjs - MCP agent bridges · Isolate agent clients from direct database access.
integrations/antigravity/mcum_local_mcp_stdio.mjs - Agent definitions
agents/openai.yaml - Direct query utilities
mcum_query.py
Control Plane
- Request dispatcher · Routes tools and records request lifecycle state.
core/dispatcher.py - Context planning
core/project_context_orchestrator.py - Session lifecycle
core/session_manager.py - Worker execution
core/worker_runner.py
Code & Artifact Graph
- Graph indexing & sync
core/code_graph_autoindex.py - Source & artifact extraction · Tree-sitter and artifact adapters isolate format parsing.
core/graph_extractors/tree_sitter_extractor.py - Graph query & impact
core/graph_query_service.py
PostgreSQL Memory
- Unified graph storage
db/unified_graph_store.py - PostgreSQL system of record · Stores audit, sessions, memory, vectors, and graph records.
db/schema.sql - Database provisioning · Supports existing, Docker/pgvector, and embedded PostgreSQL.
db/connection.py - Embedding retrieval · Uses pgvector/HNSW acceleration when available.
db/embedder.py
Knowledge & Improvement
- Knowledge library · Maintains organizational knowledge separate from code graph data.
core/knowledge_library_router.py - Pattern discovery
core/pattern_discovery.py - SISL skill evolution · Generates, evaluates, and evolves reusable skills.
sisl/autonomous_loop.py
Policy & Operations
- Policy enforcement · Interprets data-driven execution and graph directives.
core/graph_policy.py - Operational safeguards · Loop prevention, freshness, contracts, and connector health.
memory_governor.py - Optional dashboard · Exposes persisted operational data.
integrations/dashboard/server.py
Connections 25
- MCUM CLI → MCP agent bridges: configures
- Agent definitions → MCP agent bridges: defines clients
- MCP agent bridges → Request dispatcher: agent requests
- Direct query utilities → Request dispatcher: direct queries
- Request dispatcher → Context planning: assembles context
- Request dispatcher → Session lifecycle: manages lifecycle
- Request dispatcher → Policy enforcement: enforces directives
- Request dispatcher → Worker execution: dispatches execution
- Context planning → Graph query & impact: retrieves code context
- Context planning → Knowledge library: retrieves knowledge
- Session lifecycle → PostgreSQL system of record: persists state
- Worker execution → PostgreSQL system of record: records results and audit
- Policy enforcement → Graph query & impact: governs graph access
- Operational safeguards → PostgreSQL system of record: governs memory
- Graph indexing & sync → Source & artifact extraction: extracts workspace artifacts
- Source & artifact extraction → Unified graph storage: writes entities and links
- Unified graph storage → PostgreSQL system of record: persists graph records
- Graph query & impact → Unified graph storage: queries dependencies and impact
- Database provisioning → PostgreSQL system of record: connects or provisions
- Embedding retrieval → PostgreSQL system of record: stores and searches vectors
- Knowledge library → Embedding retrieval: semantic retrieval
- Pattern discovery → PostgreSQL system of record: materializes patterns
- SISL skill evolution → Pattern discovery: uses execution knowledge
- SISL skill evolution → Worker execution: creates evolved skills
- Optional dashboard → PostgreSQL system of record: reads operational data