Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

dbsize

Check the total number of keys in your Redis database to monitor storage usage and track data volume.

Instructions

Get the number of keys stored in the Redis database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler implementation for the 'dbsize' MCP tool. This async function, decorated with @mcp.tool(), connects to Redis via RedisConnectionManager, calls dbsize() to get the key count, and returns it as an int or an error string on RedisError.
    @mcp.tool()
    async def dbsize() -> int:
        """Get the number of keys stored in the Redis database"""
        try:
            r = RedisConnectionManager.get_connection()
            return r.dbsize()
        except RedisError as e:
            return f"Error getting database size: {str(e)}"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states the tool gets the number of keys, but doesn't disclose behavioral traits such as performance impact (e.g., if it's a fast O(1) operation or scans the database), whether it requires specific permissions, or if it's safe for frequent use. The description is minimal and lacks critical operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without any wasted words. It is front-loaded with the core action ('Get the number of keys'), making it easy to understand at a glance. Every part of the sentence contributes essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (0 parameters, simple read operation) and the presence of an output schema (which likely describes the return value), the description is somewhat complete but lacks depth. It covers the basic purpose but misses behavioral details like performance or usage context, which are important for a tool in a database environment with many siblings. It's adequate but has clear gaps in guidance and transparency.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and schema description coverage is 100% (though the schema is empty). With no parameters, the description doesn't need to add semantic details beyond what the schema provides. The baseline for 0 parameters is 4, as there's nothing to compensate for, and the description correctly implies no inputs are required.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Get') and resource ('number of keys stored in the Redis database'), distinguishing it from siblings like 'scan_all_keys' (which lists keys) or 'info' (which provides general server information). It precisely communicates what the tool does without ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. For example, it doesn't mention if this is for monitoring database size, checking key counts before operations, or how it differs from tools like 'scan_all_keys' (which might count keys differently) or 'info' (which includes size metrics). No exclusions or context are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/redis/mcp-redis'

If you have feedback or need assistance with the MCP directory API, please join our Discord server