Skip to content

mmeyerlein/meclaw

Repository files navigation

MeClaw

The AI Agent OS that lives inside your database.

No runtime. No sidecar. No framework.
Just PostgreSQL — thinking.

PostgreSQL 17 Apache AGE pgvector pg_net Apache 2.0

Website · Quick Start · How It Works · Ecosystem · Docs


🤖 100% Vibe-Coded. This entire project — every SQL function, every trigger chain, every line of Python, this README, and even the website — was built through conversational AI. The human (Marcus Meyer) designed the architecture and made decisions. The code was written by Claude Opus 4.6 via OpenClaw. No line was typed by hand.


What is MeClaw?

Every AI agent framework runs outside the database. MeClaw runs inside it.

MeClaw turns PostgreSQL into an operating system for AI agents. Messages flow through trigger chains. Agents are nodes in a graph. LLM calls go out via async HTTP. Tools execute as SQL functions. Nothing leaves the database process.

SELECT meclaw.send('How many users signed up today?');

That's a real query. It fires a trigger chain that routes through a graph, loads conversation context, calls an LLM, executes a tool if needed, and delivers the response — all inside PostgreSQL.

Quick Start

git clone https://github.com/mmeyerlein/meclaw.git
cd meclaw
cp config.example.sql config.sql   # Add your API keys
docker compose up -d               # Done.

Open http://localhost:8080 — your agent is running.

Manual install (existing PostgreSQL 17)
# Required extensions: age, pg_cron, pg_net, pgvector, pg_background, plpython3u
psql -d your_db -f install.sql
psql -d your_db -f config.sql

How It Works

MeClaw uses a Hive & Bee architecture:

┌─────────────────────────────────────────────────┐
│  HIVE (= one PostgreSQL container)              │
│                                                  │
│  📥 Receiver ──▶ 🗺️ Router ──▶ 📚 Context      │
│       Bee           Bee            Bee           │
│                      │              │            │
│                      ▼              ▼            │
│                 🧠 LLM  ◀──▶  🔧 Tool           │
│                    Bee           Bee             │
│                      │                           │
│                      ▼                           │
│                 📤 Sender                        │
│                    Bee                           │
│                                                  │
│  Routing: Apache AGE graph (Cypher)              │
│  Events:  Trigger chains (zero polling)          │
│  LLM:    pg_net async HTTP (any provider)        │
│  Tools:  plpython3u (full OS access in sandbox)  │
│  State:  Append-only event log (ACID)            │
└─────────────────────────────────────────────────┘

Bees are pure functions — one input, one output, no loops. The Router Bee reads a Cypher graph to decide what happens next. Everything fires through PostgreSQL triggers. No orchestration layer. No event bus. No message queue. The database is the message queue.

Multi-Provider LLM

INSERT INTO meclaw.llm_models (id, provider_id, model_name, tier) VALUES
  ('sonnet-4', 'openrouter', 'anthropic/claude-sonnet-4', 'large'),
  ('haiku',    'openrouter', 'anthropic/claude-3.5-haiku', 'medium'),
  ('local',    'vllm',       'Qwen/Qwen3.5-9B',           'small');

Each Bee can use a different model. Context history adapts automatically — 5 messages for small models, 30 for large ones.

Built-in Tools

Tool What it does
sql_read Run SELECT queries against the database
sql_write INSERT, UPDATE, DELETE with audit trail
python_exec Execute Python code (requests, urllib, math, os)

The LLM decides when to use tools via OpenAI function calling. Tool results flow back through the same event chain.

Admin Dashboard

A web UI served directly from PostgreSQL — no web server needed:

SELECT meclaw.admin_bee(8080);
-- Status · Graph Visualization · Event Log · Chat · Models

Channels

Channel Status How
Telegram Self-sustaining pg_net long-poll
Web Chat Built-in HTTP server
Slack 🔜 Webhook via HTTP server

The Claw Ecosystem

MeClaw is part of a thriving ecosystem of AI agent projects. Here's where it fits:

OpenClaw NanoBot ZeroClaw PicoClaw NanoClaw GoClaw MeClaw
Language TypeScript Python Rust Go TypeScript Go SQL
Runtime Node.js Python Native binary Native binary Node.js Native binary None (PostgreSQL)
RAM >1 GB >100 MB <5 MB <10 MB ~200 MB ~35 MB Shares PG
Agent logic App code App code App code App code App code App code Triggers + Graph
State Files + DB SQLite/PG Files Files Files PostgreSQL PostgreSQL IS the state
Routing Config Config Config Config Config Config + PG Cypher graph queries
Observability Logs Logs Logs Logs Logs OTel SELECT * FROM events
Recovery Manual Manual Manual Manual Manual Manual ACID + WAL + PITR

The difference: Every other project runs agents as an application that uses a database. MeClaw runs agents as the database.

Design Principles

  1. Pure PostgreSQL — If it can't be done with extensions, it doesn't get done. Zero external processes.
  2. Event-Driven — Trigger chains fire on every INSERT. No polling in the hot path. No cron loops.
  3. Append-Only — Every message, every LLM call, every routing decision — immutable event log.
  4. Container = Sandbox — One Hive = one container. plpython3u gets full OS access because the container is the boundary.
  5. Bees Don't Loop — An agent does one thing and hands off. The graph decides what's next.

Extensions

MeClaw stands on the shoulders of these PostgreSQL extensions:

Extension Role
Apache AGE Graph DB — agent routing via Cypher
pg_net Async HTTP — LLM calls, webhooks
pg_cron Watchdog only (not in the hot path)
pg_background Background workers for LLM execution
pgvector Vector search — semantic memory
plpython3u Python inside SQL — tools + admin UI

Status

v0.1.0 — Pre-release. Core architecture works. Bot runs on Claude Sonnet 4.

  • Event-driven trigger chain
  • Apache AGE graph routing
  • Multi-provider LLM (OpenRouter, vLLM, any OpenAI-compatible)
  • Tool system (SQL, Python)
  • Tier-aware conversation history
  • Telegram + Web Chat channels
  • Admin dashboard
  • Rate limiting
  • Docker
  • Semantic memory (pgvector embeddings)
  • Skill & tool-set management
  • Slack channel
  • Multi-user

License

Apache 2.0 — Marcus Meyer, 2026

Links


MeClaw — Your database already knows how to think.
You just haven't asked it yet.

About

The AI Agent OS that lives inside your database. Pure PostgreSQL.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors