BetterDB MCP server

Query a BetterDB monitor's Valkey and Redis metrics, slowlogs, hot keys and cache proposals from a chat

Official · BetterDB TypeScript Local · stdio DevOps and monitoringDatabases

43 popularity score ★ 1.3k ↓ 75/wk

Connect your client

Local (npm)

Add in one click

Opens the app, which asks before it adds the server. Then replace each <NAME> in its settings with your value.

Or add it by command or config

It needs BETTERDB_URL. Replace each <NAME> with your value.

Claude CodeTerminal
claude mcp add betterdb -e BETTERDB_URL=<BETTERDB_URL> -- npx @betterdb/mcp
Claude Desktopclaude_desktop_config.json
{
  "mcpServers": {
    "betterdb": {
      "command": "npx",
      "args": [
        "@betterdb/mcp"
      ],
      "env": {
        "BETTERDB_URL": "<BETTERDB_URL>"
      }
    }
  }
}
Cursor~/.cursor/mcp.json
{
  "mcpServers": {
    "betterdb": {
      "command": "npx",
      "args": [
        "@betterdb/mcp"
      ],
      "env": {
        "BETTERDB_URL": "<BETTERDB_URL>"
      }
    }
  }
}
VS Code.vscode/mcp.json
{
  "servers": {
    "betterdb": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "@betterdb/mcp"
      ],
      "env": {
        "BETTERDB_URL": "<BETTERDB_URL>"
      }
    }
  }
}
Codex~/.codex/config.toml
[mcp_servers.betterdb]
command = "npx"
args = ["@betterdb/mcp"]

[mcp_servers.betterdb.env]
BETTERDB_URL = "<BETTERDB_URL>"
Gemini CLITerminal
gemini mcp add --scope user -e BETTERDB_URL=<BETTERDB_URL> betterdb npx -- @betterdb/mcp

Settings 4

BETTERDB_URL Required: Address of the BetterDB monitor or Cloud workspace (https://<workspace>.app.betterdb.com). Default http://localhost:3001.
BETTERDB_TOKEN secret Optional: MCP token from Settings → MCP Tokens, sent as a Bearer header. Needed for BetterDB Cloud, optional for a self-hosted monitor.
BETTERDB_INSTANCE_ID Optional: Instance to use from the start, so select_instance is not needed. For select_instance.
BETTERDB_TELEMETRY Optional: Set to false to stop the tool-call usage reports the server posts to the monitor. For telemetry.

What it does

The BetterDB MCP server (npm package @betterdb/mcp) is the assistant-facing side of BetterDB Monitor, an observability tool for Valkey and Redis. It does not open a database connection itself: every tool calls the REST API of a running BetterDB monitor, either a self-hosted one (http://localhost:3001 by default) or a BetterDB Cloud workspace, and returns what that monitor has collected.

Through it an assistant can pick one of the monitored instances and read its health summary, INFO sections, slowlog and COMMANDLOG entries (live and persisted, with pattern aggregation), latency events, memory diagnostics, client lists and activity over time, hot and largest keys, the ACL audit log, cluster node and per-slot stats, capacity forecasts, anomaly events, vector index health and FT.SEARCH latency, and OpenTelemetry traces from AI applications correlated with Valkey state.

It can also change things: add, test, remove or set the default monitored connection; start and stop a local monitor process; and work with the review flow for BetterDB's semantic and agent caches and agent-memory stores, where tools propose a threshold, TTL, invalidation or forget, and separate approve tools apply the change to Valkey.

The version 1.5.0 source registers 60 tools (packages/mcp/src/index.ts at tag mcp-v1.5.0). The package README lists 51 of them: it leaves out the nine agent-memory tools (memory_stores, memory_list, memory_get, memory_stats, memory_recall, memory_forget, memory_list_pending_forgets, memory_approve_forget, memory_reject_forget). With --autostart the server launches the monitor itself by running npx --yes @betterdb/monitor, records the process id in ~/.betterdb/monitor.pid, and gives up if the monitor is not healthy within 15 seconds (src/autostart.ts).

What it needs

RuntimeNode.js 20+
Runs onmacOS, Windows, Linux
BetterDBYour own instanceA running BetterDB monitor (self-hosted or BetterDB Cloud) that watches a Valkey 8.0+ or Redis 6+ instance. Cloud needs an MCP token.
Also
  • npx on PATH, also used by --autostart to fetch @betterdb/monitor

On BetterDB Cloud, create a token under Settings → MCP Tokens and set it as BETTERDB_TOKEN. A self-hosted monitor can run from the betterdb/monitor Docker image, npx @betterdb/monitor or Helm. With --autostart nothing has to run beforehand. The started monitor gets the server's whole environment, so its own database settings (DB_HOST, DB_TLS, DB_TLS_CA_FILE, DB_TLS_CERT_FILE, DB_TLS_KEY_FILE, DB_AUTH_MODE and so on, from the main README) can go in the client's env block. sqlite storage may need better-sqlite3 installed globally (npm install -g better-sqlite3).

Limits

  • Not covered No direct database access: every tool calls the BetterDB monitor's REST API, so it sees only what the monitor collects and runs no arbitrary commands.
  • Not covered add_connection and test_connection take host, port, username and password only. TLS, CA bundles and certificate-only (mTLS) sign-in are set on the monitor, not through these tools.
  • Cost get_anomalies, get_latency_regressions, get_largest_keys and the SLA fields of get_inference_latency are Pro features, free during early access per the README.
  • Limit COMMANDLOG and per-slot tools need Valkey 8 or newer. Vector tools need valkey-search or RediSearch.
  • Limit Cache and memory tools work only with BetterDB's semantic-cache, agent-cache or agent-memory libraries in use on the instance.
  • Not covered memory_recall takes a precomputed embedding vector. The server does not embed text itself.
  • Limit Each call to the monitor's API times out after 30 seconds (src/index.ts).
  • Limit With --autostart it gives up if the monitor is not healthy within 15 seconds. --storage takes only sqlite or memory.

It only sees what the BetterDB monitor exposes; it has no direct database access and runs no arbitrary commands. get_anomalies, get_latency_regressions, get_largest_keys and the SLA fields of get_inference_latency are Pro features (free in early access, per the README). COMMANDLOG and per-slot stats need Valkey 8 or newer; vector tools need the Search module (valkey-search or RediSearch); cache and memory tools need BetterDB's own semantic-cache, agent-cache or agent-memory libraries. memory_recall takes a precomputed embedding vector; the server does not embed text. Each API call times out after 30 seconds (src/index.ts). --storage accepts only sqlite or memory.

Who it suits

Suits teams already running BetterDB Monitor, self-hosted or on Cloud, who want an assistant to investigate Valkey or Redis incidents from history that the database itself has discarded: slow commands, hot keys, cluster imbalance, anomalies. Also suits users of BetterDB's semantic or agent caches who want proposed tuning changes reviewed before they are applied. It is a poor fit if you do not want to run the BetterDB monitor at all, or want an assistant to run arbitrary Redis commands or read and write keys directly: this server only goes through the monitor's API.

Tools 60

46 only read, 12 change things, 2 can delete or overwrite. A ? marks an optional parameter.

list_instances
Lists the Valkey/Redis instances the monitor knows, with connection status
select_instance
Chooses the instance later calls work oninstanceId: string
add_connection changes
Registers a new Valkey/Redis connection in BetterDBname: stringhost: stringport?: numberusername?: stringpassword?: stringsetAsDefault?: boolean
test_connection
Checks connection details without saving themname: stringhost: stringport?: numberusername?: stringpassword?: string
remove_connection deletes
Deletes a connection from BetterDBinstanceId: string
set_default_connection changes
Makes a connection the active defaultinstanceId: string
get_health
Summarised health of the selected instance
get_info
INFO output, optionally one sectionsection?: stringinstanceId?: string
get_slowlog
Current slowlog entriescount?: numberinstanceId?: string
get_commandlog
Current COMMANDLOG entries (Valkey 8+)count?: numberinstanceId?: string
get_latency
Latency event list
get_latency_history
History for one latency event typeeventName: stringinstanceId?: string
get_memory
MEMORY DOCTOR and MEMORY STATS output
get_clients
Connected clients and their details
get_hot_keys
Most-accessed keys by LFU or idle timestartTime?: numberendTime?: numberlimit?: numberinstanceId?: string
get_slowlog_patterns
Slowlog grouped into command patterns with counts and averageslimit?: numberinstanceId?: string
get_commandlog_history
Stored COMMANDLOG entries for a time rangestartTime?: numberendTime?: numbercommand?: stringminDuration?: numberlimit?: numberinstanceId?: string
get_commandlog_patterns
COMMANDLOG grouped into patternsstartTime?: numberendTime?: numberlimit?: numberinstanceId?: string
get_anomalies
Detected anomaly events (Pro)limit?: numbermetricType?: stringstartTime?: numberinstanceId?: string
get_client_activity
Client activity over time from stored snapshotsstartTime?: numberendTime?: numberbucketSizeMinutes?: numberinstanceId?: string
get_acl_audit
ACL audit log entriesusername?: stringreason?: stringstartTime?: numberendTime?: numberlimit?: numberinstanceId?: string
get_cluster_nodes
Cluster nodes with roles, health and slot ranges
get_cluster_node_stats
Performance figures per cluster node
get_cluster_slowlog
Slowlog merged across cluster nodeslimit?: numberinstanceId?: string
get_slot_stats
Key counts and CPU per slot (Valkey 8+)orderBy?: enumlimit?: numberinstanceId?: string
start_monitor changes
Launches a local monitor as a background process that outlives the sessionport?: numberstorage?: enum
stop_monitor changes
Stops a monitor started earlier
get_forecast
Projects when memory, ops/sec, CPU or fragmentation hits its ceilingmetricKind: enuminstanceId?: string
get_latency_regressions
Sustained p99 latency rises against baseline (Pro)limit?: numberstartTime?: numberinstanceId?: string
get_largest_keys
Keys using the most memory, from key analytics (Pro)limit?: numberstartTime?: numberendTime?: numberinstanceId?: string
get_vector_indexes
Health of each vector search indexinstanceId?: string
get_inference_latency
FT.SEARCH latency percentiles per index, SLA status on ProwindowMs?: numberinstanceId?: string
ai_list_instances
AI cache and memory components with liveness and latest figuresinstanceId?: string
ai_instance_history
Stored metric history for one AI componentfield: stringhours?: numberinstanceId?: string
list_ai_traces
Recent traces sent in from AI applicationshours?: numberservice?: stringlimit?: number
get_ai_trace
All spans of one trace with timingstraceId: string
correlate_ai_trace
Matches a trace's cache and memory spans to live Valkey statetraceId: stringinstanceId?: string
cache_list
Caches registered on the instance with hit rate and op countsinstanceId?: string
cache_health
Health details for one cachecache_name: stringinstanceId?: string
cache_threshold_recommendation
Suggested similarity threshold for a semantic cachecache_name: stringcategory?: stringminSamples?: numberinstanceId?: string
cache_tool_effectiveness
Per-tool hit rate, savings and TTL advice for an agent cachecache_name: stringinstanceId?: string
cache_similarity_distribution
Histogram of recent similarity scores for a semantic cachecache_name: stringcategory?: stringwindow_hours?: numberinstanceId?: string
cache_recent_changes
Recent proposals for one cachecache_name: stringlimit?: numberinstanceId?: string
cache_propose_threshold_adjust changes
Files a proposal to change a similarity thresholdcache_name: stringnew_threshold: numbercategory?: stringreasoning: stringinstanceId?: string
cache_propose_tool_ttl_adjust changes
Files a proposal to change a tool's TTLcache_name: stringtool_name: stringnew_ttl_seconds: numberreasoning: stringinstanceId?: string
cache_propose_invalidate changes
Files a proposal to invalidate cache entriescache_name: stringfilter_kind: enumfilter_expression?: stringfilter_value?: stringestimated_affected: numberreasoning: stringinstanceId?: string
cache_list_pending_proposals
Proposals awaiting a decisioncache_name?: stringlimit?: numberinstanceId?: string
cache_get_proposal
One proposal with its audit trailproposal_id: string
cache_approve_proposal changes
Approves a proposal and applies it to Valkeyproposal_id: stringactor?: string
cache_reject_proposal changes
Rejects a proposal, with an optional reasonproposal_id: stringreason?: stringactor?: string
cache_edit_and_approve_proposal changes
Changes a threshold or TTL proposal's value and applies itproposal_id: stringnew_threshold?: numbernew_ttl_seconds?: numberactor?: string
memory_stores
Agent-memory stores found on the instance
memory_list
Memories in a store, newest first, filterable by scope and tagmemory_name: stringthreadId?: stringagentId?: stringnamespace?: stringtags?: arraylimit?: numberoffset?: numberinstanceId?: string
memory_get
One memory by IDmemory_name: stringid: stringinstanceId?: string
memory_stats
Item and eviction counts and config of a memory storememory_name: stringinstanceId?: string
memory_recall
Finds memories by a supplied embedding vectormemory_name: stringvector: arrayk?: numberthreshold?: numbertags?: arraythreadId?: stringagentId?: stringnamespace?: stringinstanceId?: string
memory_forget changes
Files a proposal to delete memories by ID, scope or tagsmemory_name: stringid?: stringthreadId?: stringagentId?: stringnamespace?: stringtags?: arrayreasoning: stringinstanceId?: string
memory_list_pending_forgets
Delete proposals awaiting approvalmemory_name?: stringlimit?: numberinstanceId?: string
memory_approve_forget deletes
Approves a delete proposal and removes the memoriesproposal_id: stringactor?: stringinstanceId?: string
memory_reject_forget changes
Rejects a delete proposalproposal_id: stringreason?: stringactor?: stringinstanceId?: string

Similar servers