| Crates.io | plenum |
| lib.rs | plenum |
| version | 1.7.0 |
| created_at | 2026-01-09 21:28:45.821561+00 |
| updated_at | 2026-01-14 05:07:38.605285+00 |
| description | Agent-first database control CLI with least-privilege execution |
| homepage | https://github.com/reflex-search/plenum |
| repository | https://github.com/reflex-search/plenum |
| max_upload_size | |
| id | 2032902 |
| size | 659,395 |
Agent-first database control CLI with least-privilege execution
Plenum is a lightweight, deterministic database control tool designed specifically for autonomous AI coding agents. It provides a constrained, safe execution surface for database operations with read-only defaults and explicit capability requirements.
This is not a human-oriented database client. If you're looking for a tool with interactive shells, autocomplete, or pretty-printed output, Plenum is not for you.
Plenum enables AI agents to:
Plenum is exposed via a local MCP (Model Context Protocol) server, making it seamlessly integrable with AI agent frameworks.
git clone https://github.com/yourusername/plenum.git
cd plenum
cargo build --release
./target/release/plenum --help
Plenum provides exactly three commands:
plenum connect - Configure Database ConnectionsManage database connection configurations (interactive or non-interactive):
# Interactive connection picker
plenum connect
# Create new connection interactively
plenum connect --name prod --engine postgres --host db.example.com \
--port 5432 --user readonly --password secret --database myapp \
--save global
# Validate existing connection
plenum connect --name prod
Connection configurations are stored:
.plenum/config.json (team-shareable)~/.config/plenum/connections.json (per-user)plenum introspect - Schema IntrospectionInspect database schema and return structured JSON:
# Introspect using named connection
plenum introspect --name prod
# Introspect with explicit parameters
plenum introspect --engine postgres --host localhost --port 5432 \
--user admin --password secret --database mydb
# Introspect specific schema
plenum introspect --name prod --schema public
Returns JSON with:
plenum query - Read-Only Query ExecutionExecute read-only SQL queries with safety constraints:
# Read-only query
plenum query --name prod --sql "SELECT * FROM users WHERE id = 1"
# With row limit (recommended for large tables)
plenum query --name prod --sql "SELECT * FROM large_table" \
--max-rows 100 --timeout-ms 5000
# Introspection queries
plenum query --name prod --sql "SHOW TABLES"
plenum query --name prod --sql "DESCRIBE users"
# Complex query with joins
plenum query --name prod --sql "
SELECT u.name, o.total
FROM users u
JOIN orders o ON u.id = o.user_id
WHERE o.status = 'completed'
" --max-rows 50
Read-Only Enforcement:
For write operations: Plenum will reject the query with a helpful error message. Construct the SQL and present it to the user for manual execution.
All commands output structured JSON to stdout:
Success:
{
"ok": true,
"engine": "postgres",
"command": "query",
"data": { ... },
"meta": {
"execution_ms": 42,
"rows_returned": 10
}
}
Error:
{
"ok": false,
"engine": "postgres",
"command": "query",
"error": {
"code": "CAPABILITY_VIOLATION",
"message": "DDL statements require --allow-ddl flag"
}
}
Plenum returns stable, machine-parseable error codes. Agents should check the error.code field for programmatic error handling:
| Code | Description | When It Occurs |
|---|---|---|
CAPABILITY_VIOLATION |
Operation blocked - Plenum is read-only | Attempting any write or DDL operations (INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, etc.) |
CONNECTION_FAILED |
Database connection failed | Invalid credentials, unreachable host, or database doesn't exist |
QUERY_FAILED |
Query execution failed | SQL syntax errors, missing tables/columns, constraint violations |
INVALID_INPUT |
Malformed input or missing parameters | Missing required flags, invalid engine type, etc. |
ENGINE_ERROR |
Engine-specific database error | Database-specific errors wrapped for consistency |
CONFIG_ERROR |
Configuration file or connection registry error | Missing config file, invalid JSON, connection name not found |
Example error handling:
{
"ok": false,
"engine": "postgres",
"command": "query",
"error": {
"code": "CAPABILITY_VIOLATION",
"message": "Plenum is read-only and cannot execute this query. Please run this query manually:\n\nINSERT INTO users (name) VALUES ('Alice')"
}
}
Agents should:
ok field first (true = success, false = error)error.code for programmatic handlingerror.message for logging/debugging (agent-appropriate, no sensitive data)Plenum exposes functionality via MCP (Model Context Protocol) server:
# Start MCP server (hidden command, for AI agent use)
plenum mcp
Configure in your MCP client:
{
"mcpServers": {
"plenum": {
"command": "plenum",
"args": ["mcp"]
}
}
}
Each CLI command maps to an MCP tool:
connect → Validate and save database connectionsintrospect → Retrieve schema informationquery → Execute constrained SQL queriesPlenum is built around strict architectural principles:
Plenum's security boundary is strict read-only enforcement, not SQL validation.
Plenum enforces:
max_rows) and query timeouts (timeout_ms)Plenum does NOT enforce:
Critical: Agents must sanitize all user inputs before constructing SQL. Plenum assumes read-only SQL passed to it is safe and passes it verbatim to database drivers.
Credentials are stored as plaintext JSON in config files:
.plenum/config.json (team-shareable)~/.config/plenum/connections.json (user-private)Recommendations:
password_env for production (environment variables)chmod 600)--password CLI flag (visible in process listings)For detailed security documentation, threat model, and vulnerability reporting, see SECURITY.md.
To report security vulnerabilities, create a GitHub issue with the security label.
Plenum uses native, engine-specific drivers (NOT sqlx):
tokio-postgresmysql_asyncrusqliteThis ensures maximum isolation between engines and preserves vendor-specific behavior.
# Clone repository
git clone https://github.com/yourusername/plenum.git
cd plenum
# Build
cargo build --release
# Run tests
cargo test
# Check code quality
cargo fmt --check
cargo clippy --all-targets --all-features
# Install locally
cargo install --path .
See CONTRIBUTING.md for development guidelines.
plenum/
├── src/
│ ├── lib.rs # Library API for CLI and MCP
│ ├── main.rs # CLI entry point
│ ├── engine/ # Database engine implementations (Phase 3-5)
│ ├── capability/ # Capability validation (Phase 1.4)
│ ├── config/ # Configuration management (Phase 1.5)
│ ├── output/ # JSON output envelopes (Phase 1.2)
│ └── error/ # Error handling (Phase 1.3)
├── CLAUDE.md # Core principles and architecture
├── PROJECT_PLAN.md # Implementation roadmap
├── RESEARCH.md # Design decisions and rationale
└── PROBLEMS.md # Resolved architectural issues
Plenum has completed Phase 8: Security Audit.
Recent Accomplishments:
See PROJECT_PLAN.md for the complete implementation roadmap:
Contributions must adhere to Plenum's core principles. Before adding code, ask:
"Does this make autonomous agents safer, more deterministic, or more constrained?"
If the answer is no, it does not belong in Plenum.
See CONTRIBUTING.md for detailed guidelines.
Licensed under either of:
at your option.
Plenum follows the architecture pattern established by reflex-search for MCP integration.