This is a preview of PR #813, not valkey.io.

Introducing the Valkey Admin MCP Server: Big Keys and Hot Keys for Your AI Assistant

Technical Deep Dive 2026-12-01 · Rong Zhang, Nas Nassery

An AI assistant can read your application code, but it cannot see your Valkey cluster. So when one shard runs out of memory, you copy INFO output and a list of large keys into the chat by hand, and the assistant reasons about whatever you remembered to paste. Valkey Admin 1.4 adds a read-only Model Context Protocol (MCP) server, so an assistant that supports MCP, such as Claude Code or Cursor, can ask Valkey Admin for server info, big keys and hot keys itself.

In this post, we'll walk through what the assistant can ask, how a request reaches Valkey, how to turn the MCP server on, and how it stays read-only.

What the assistant can ask

The MCP server gives the assistant three tools, and each one returns a view that Valkey Admin already shows in its UI.

Server info. get_server_info returns the INFO and memory data behind the dashboard. On a cluster it covers only the node that Valkey Admin connected to.

Big keys. get_big_keys returns the largest keys by memory, each with its type, its size in bytes, its TTL and the node it lives on. It samples up to 10,000 keys on every primary by default (scanLimit) and returns the 20 largest of that sample (topN), so a cluster with three primaries scans up to about 30,000 keys in one call. The scan adds load to every primary it touches, and a call fails when Valkey Admin takes more than 10 seconds to reply, so lower scanLimit when that happens. Finding big keys in a running Valkey cluster explains how the scan works.

Claude Code session in which the assistant calls the Valkey Admin MCP server and lists the 10 largest keys in a cluster with their type, size, TTL and node

Hot keys. get_hot_keys returns the most frequently accessed keys across a cluster. Valkey Admin finds the hottest slots by CPU time from CLUSTER SLOT-STATS, then ranks the keys in those slots by their LFU access frequency, so the tool needs cluster mode, cluster-slot-stats-enabled yes and an LFU maxmemory-policy such as allkeys-lfu. Changing the eviction policy also changes which keys Valkey evicts when memory is full. The frequency it reports is the LFU counter, a value from 0 to 255 on a logarithmic scale that decays over time, so use it to rank keys and not to count requests. Introducing Valkey Admin 1.0 explains how hot key detection works.

Claude Code session in which the assistant calls the Valkey Admin MCP server and lists the 8 hottest keys in a cluster with their access score, size, node and time to expiry

With the three tools connected, you can ask which keys use the most memory in a deployment and whether they have a TTL, and the assistant can answer from live data next to the code that writes those keys.

Where it fits

MCP servers that run Valkey commands for an assistant already exist, for example the Valkey MCP server from AWS Labs, and they suit an assistant that needs to read and write data. The Valkey Admin MCP server takes no commands at all. It hands the assistant the analysis that Valkey Admin already does across a cluster, and it complements those servers and valkey-cli without replacing them.

How a request reaches Valkey

AI assistant --HTTP--> MCP server --WebSocket--> Valkey Admin server --> Valkey

The MCP server never connects to Valkey. It talks to the Valkey Admin server over the same WebSocket API the browser uses, like one more browser tab, and the Valkey Admin server does the Valkey work. Each tool call opens its own WebSocket, asks Valkey Admin to connect the way the connection form does, sends one read request and closes.

The MCP server connects as its own Valkey user, and Valkey Admin runs one metrics collector per primary for each Valkey user. The collectors for the MCP user start with a tool call and stop about 10 seconds after it. Plan for about 150 MB of RAM per primary while a call runs, on top of what the UI already uses for the same deployment.

Turning it on

The MCP server ships inside Valkey Admin and stays off until you set VALKEY_ADMIN_MCP_ENABLED=true. It runs in Web mode, for example the Docker image, and it is not available in the desktop app or in Kubernetes mode in this release. You give it a token of at least 32 characters, the Valkey deployments the assistant may read, and the credentials of a read-only Valkey user:

MCP_TOKEN="$(openssl rand -hex 32)"
echo "$MCP_TOKEN"  # keep it: the assistant sends this token

docker run -d --name valkey-admin -p 127.0.0.1:8080:8080 \
  -e VALKEY_ADMIN_MCP_ENABLED=true \
  -e VALKEY_ADMIN_MCP_TOKEN="$MCP_TOKEN" \
  -e VALKEY_ADMIN_MCP_TARGETS="prod=valkey-prod:6379,cache=valkeys://valkey-cache:6380" \
  -e VALKEY_ADMIN_MCP_USERNAME=mcp_readonly \
  -e VALKEY_ADMIN_MCP_PASSWORD="<password>" \
  valkey/valkey-admin

Valkey Admin serves each target on port 8080 at /mcp/<target>, here http://localhost:8080/mcp/prod and http://localhost:8080/mcp/cache. For a cluster one target is enough, since Valkey Admin finds the other nodes from the one you point it at. Then add a target to your assistant, for example in Claude Code:

claude mcp add --transport http valkey-cache http://localhost:8080/mcp/cache \
  --header "Authorization: Bearer <token>"

The MCP page in the Valkey Admin docs has the JSON form for other assistants and every setting.

How it stays read-only

The tools take no raw commands, and after it connects, the MCP server sends only three kinds of request to Valkey Admin, one per tool. Every request from the assistant must carry the token, and the MCP server refuses requests with a non-local Origin. The assistant never sends a host or a password: it can reach only the deployments you listed, with the credentials you configured. Valkey's ACL is the real access control, so connect as a dedicated user that can read and cannot write:

ACL SETUSER mcp_readonly reset on >password ~* +@read +@connection -@dangerous +info +memory|stats +cluster|slots +cluster|slot-stats +commandlog|get +command|info

The rule starts with reset, so a user that already exists loses its earlier grants and passwords. It then grants @read and @connection, removes @dangerous, and adds back only the commands that the tools and the metrics collector use. Create the user on every node, since a cluster does not replicate ACL users.

Tool results, key names included, go to your AI assistant and its model provider. Valkey Admin itself has no authentication, so keep port 8080 published on loopback as in the example above.

Join the community

Valkey Admin gives Valkey users a single place to monitor, inspect, and troubleshoot Valkey clusters, and 1.4 opens three of its views to the AI assistant you already work with. We invite you to try it out, and to tell us in a GitHub issue which view you want your assistant to read next. The release notes have everything else in 1.4.0.

The project lives at github.com/valkey-io/valkey-admin under the Apache 2.0 license.

@nassery318 built the MCP server.