BetterDB MCP
The BetterDB MCP server gives AI assistants deep observability and management capabilities for Valkey and Redis databases through the BetterDB monitoring platform.
Instance & Connection Management
List, add, test, remove, and set default Valkey/Redis connections
Select which instance subsequent tool calls operate on
Start and stop a persistent BetterDB monitor background process
Health & Diagnostics
Get a synthetic health summary (hit rate, memory fragmentation, connected clients, replication lag)
Retrieve full INFO stats filtered by section (server, memory, clients, replication, keyspace, stats)
Get memory diagnostics via MEMORY DOCTOR and MEMORY STATS
View active client list with connection details
Slow Command & Latency Analysis
Retrieve recent slowlog entries and COMMANDLOG entries (Valkey 8+) with time range filtering
Get aggregated slowlog/COMMANDLOG patterns (frequency, avg duration)
View latency event history and detailed history for specific latency events
Hot Key & Access Pattern Detection
Find hot keys using LFU frequency scores or idle time analysis
Identify cache-busting keys and uneven access patterns
Cluster Visibility
Discover all cluster nodes with roles, health, and slot ranges
Get per-node performance stats (memory, ops/sec, clients, CPU)
Retrieve aggregated slowlog across all cluster nodes
View per-slot key counts and CPU usage (Valkey 8+)
Anomaly Detection & Audit
Retrieve Z-score based anomaly detection events for memory, CPU, hit rate, and other metrics (Pro)
View time-bucketed client activity (connection counts, command distribution, buffer usage)
Query persisted ACL audit log entries filtered by username, reason, or time range
Cache Intelligence (semantic_cache & agent_cache)
List all registered caches with hit rate and total ops
Get detailed cache health (category/tool breakdown), threshold-tuning recommendations, and similarity score histograms
View per-tool hit rate, cost saved, and TTL recommendations for agent caches
Review recent proposals to avoid re-proposing pending changes
Cache Change Proposals (Advisory Workflow)
Propose similarity-threshold changes for semantic caches or per-tool TTL changes for agent caches
Propose cache invalidations (by tool, key prefix, session, or Valkey Search filter)
List, fetch, approve, reject, or edit-and-approve pending proposals with full audit trail
Supports PostgreSQL as a persistent storage backend for monitoring data and configuration.
Exposes database metrics, including ACL events and connection statistics, in Prometheus-compatible format for external monitoring and observability.
Provides comprehensive monitoring for Redis databases, including server health, slowlogs, client lists, memory statistics, and ACL logs.
Supports SQLite as a local storage backend for persisting monitoring data and settings when used via the CLI.
@betterdb/mcp
Give your AI assistant deep visibility into your Valkey and Redis databases. The BetterDB MCP server connects Claude Code, Cursor, Windsurf, and other MCP-compatible clients to the BetterDB monitoring platform — letting your AI query real-time metrics, diagnose slow commands, detect anomalies, and investigate incidents without leaving your editor.
Why BetterDB?
BetterDB is a monitoring and observability platform built for Valkey and Redis providing real-time dashboards, anomaly detection, and operational intelligence for your Valkey and Redis deployments. Unlike tools that only show a live snapshot, BetterDB persists historical metrics, slowlogs, and audit trails — so you can investigate what happened yesterday, not just what's happening now.
Key capabilities exposed through MCP:
Real-time health checks — memory fragmentation, hit rate, replication lag, connected clients
Slow command analysis — slowlog and COMMANDLOG (Valkey 8+) with pattern aggregation
Hot key detection — find cache-busting keys via LFU frequency scores or idle time analysis
Cluster-wide visibility — per-node stats, aggregated slowlogs, and slot-level metrics across all nodes
Anomaly detection — Z-score analysis on memory, CPU, hit rate, and other metrics (Pro)
Client activity tracking — connection counts, command distribution, and buffer usage over time
ACL audit log — investigate auth failures and access patterns
Latency event history — track latency trends for specific event types
Quick Start
1. Get a token
In BetterDB, go to Settings → MCP Tokens and generate a new token.
2. Configure your MCP client
Add to your MCP client config (e.g. Claude Code or OpenAI Codex):
{
"mcpServers": {
"betterdb": {
"type": "stdio",
"command": "npx",
"args": ["@betterdb/mcp"],
"env": {
"BETTERDB_URL": "https://<your-workspace>.app.betterdb.com",
"BETTERDB_TOKEN": "<your-token>"
}
}
}
}For local development with an existing monitor (token not required):
{
"mcpServers": {
"betterdb": {
"type": "stdio",
"command": "npx",
"args": ["@betterdb/mcp"],
"env": {
"BETTERDB_URL": "http://localhost:3001"
}
}
}
}For zero-config local development (auto-starts and manages a monitor process):
{
"mcpServers": {
"betterdb": {
"type": "stdio",
"command": "npx",
"args": ["@betterdb/mcp", "--autostart", "--persist"]
}
}
}3. Start asking questions
Once connected, your AI assistant can query your databases directly:
"What's the health of my production Valkey instance?"
"Show me the slowest commands from the last hour"
"Are there any hot keys causing uneven load?"
"Which cluster node has the highest memory usage?"
"Have there been any anomalies in the last 24 hours?"
"Tune the threshold on my faq-cache — propose a change for me to review"
"Why is the weather_lookup tool's hit rate so low?"
Configuration
Environment Variables
Variable | Default | Description |
|
| BetterDB instance URL (port depends on your Docker config) |
| — | MCP token from Settings (required for cloud, optional for local) |
| — | Pre-select a specific instance (skips |
CLI Arguments
Argument | Default | Description |
| — | Spawn and manage a local BetterDB monitor process on startup |
| — | Keep the monitor running after the MCP server exits (requires |
|
| Port for the auto-started monitor API |
|
| Storage backend: |
| — | Stop a previously persisted monitor process and exit |
Available Tools
Instance Tools
Tool | Description |
| List all registered Valkey/Redis instances with connection status |
| Select which instance subsequent calls operate on |
| Synthetic health summary — the best starting point for any investigation |
| Full INFO stats, optionally filtered by section |
| Recent slow commands from the slowlog buffer |
| Recent COMMANDLOG entries (Valkey 8+) |
| Latency event history |
| Detailed history for a specific latency event |
| MEMORY DOCTOR assessment and MEMORY STATS breakdown |
| Active client list with connection details |
| Hot key tracking data from LFU or idle time analysis |
| Aggregated slowlog patterns with frequency and avg duration |
| Persisted COMMANDLOG entries with time range filtering |
| Aggregated COMMANDLOG patterns |
| Anomaly detection events (Pro) |
| Time-bucketed client activity from persisted snapshots |
| ACL audit log entries |
| Cluster node discovery — roles, health, slot ranges |
| Per-node performance stats across the cluster |
| Aggregated slowlog across all cluster nodes |
| Per-slot key counts and CPU usage (Valkey 8+) |
Connection Management Tools
Tool | Description |
| Add a new Valkey/Redis connection to BetterDB |
| Test connection credentials without persisting |
| Remove a connection from BetterDB |
| Set a connection as the active default |
Monitor Lifecycle Tools
Tool | Description |
| Start a persistent BetterDB monitor background process |
| Stop a previously started persistent monitor process |
Cache Intelligence Tools
For deployments running @betterdb/semantic-cache or @betterdb/agent-cache. Caches register themselves in a Valkey-side discovery hash; Monitor exposes them through the tools below.
Read-only:
Tool | Description |
| List all caches registered for the active instance with hit rate and total ops |
| Detailed health for one cache; response branches on |
| Threshold-tuning recommendation for a semantic_cache, derived from the rolling similarity window |
| Per-tool hit rate, cost saved, and TTL recommendation for an agent_cache |
| Histogram of recent similarity scores for a semantic_cache (20 buckets, width 0.1) |
| Recent proposals (any status) for a single cache, so agents can avoid re-proposing |
Propose changes (advisory — no Valkey writes until approved):
Tool | Description |
| Propose a similarity-threshold change on a semantic_cache (per-category or global) |
| Propose a per-tool TTL change on an agent_cache |
| Propose an invalidation; filter shape branches on cache type |
Approve / reject / list:
Tool | Description |
| List pending proposals on the active instance, optionally filtered by cache_name |
| Fetch a single proposal by id, including its audit trail |
| Approve a pending proposal; synchronously applies the change to Valkey |
| Reject a pending proposal with an optional reason |
| Edit a proposal's value (threshold or TTL) and approve in one step; invalidate proposals are not editable |
Requirements
Node.js 20+
A running BetterDB instance (cloud or self-hosted), or use
--autostartto have the MCP server manage one automatically
Documentation
Full docs: docs.betterdb.com
License
See LICENSE for details.
Maintenance
Appeared in Searches
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/BetterDB-inc/monitor'
If you have feedback or need assistance with the MCP directory API, please join our Discord server