Skip to main content
Glama
lm203688

redis-mcp-server

by lm203688

db_size

Retrieves the total number of keys in the current Redis database. Use to monitor database size and resource usage.

Instructions

获取当前数据库的键数量

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for 'db_size'. Decorated with @mcp.tool(), it calls db.dbsize() and returns JSON-formatted result with the current database key count.
    @mcp.tool()
    def db_size() -> str:
        """获取当前数据库的键数量"""
        try:
            result = db.dbsize()
            return json.dumps(result, ensure_ascii=False, indent=2)
        except Exception as e:
            return json.dumps({"error": str(e)}, ensure_ascii=False)
  • The RedisConnection.dbsize() method that executes the actual Redis DBSIZE command and returns the database index and key count as a dict.
    def dbsize(self) -> dict[str, Any]:
        """获取当前数据库键数量"""
        return {"db": self.config.db, "key_count": self._client.dbsize()}
  • Tool registration via the @mcp.tool() decorator on the db_size function (line 60). All tools in this file are registered using FastMCP's decorator pattern.
    @mcp.tool()
    def ping() -> str:
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While it implies a read-only operation, it does not specify performance characteristics, such as whether it scans all keys or uses an internal counter. The description is minimal but sufficient for a simple counting operation.

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 sentence that conveys the entire purpose without any unnecessary words. It is appropriately brief and front-loaded, earning a high score for conciseness.

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

Completeness4/5

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

Given that the tool has no parameters and an output schema exists to describe the return format, the description is sufficient for a simple key count operation. It covers the essential purpose and is complete in the context of the sibling tools and the database domain.

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 no parameters, and the input schema is empty with 100% coverage, so the description does not need to explain parameters. The baseline for 0 parameters is 4, and the description meets that by not overcomplicating.

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 that the tool retrieves the number of keys in the current database. It uses a specific verb (获取/get) and resource (键数量/key count), and is distinctly different from sibling tools like delete_keys or get_hash.

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

Usage Guidelines3/5

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

The description does not provide any guidance on when to use this tool versus alternatives. For example, it doesn't mention that server_info might provide more detailed statistics or that this tool is a lightweight alternative. The usage context is implied but not explicitly stated.

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

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