Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

get_indexed_keys_number

Retrieve the count of indexed keys for a specific Redis index to monitor indexing status and data volume.

Instructions

Retrieve the number of indexed keys by the index

Args: index_name (str): The name of the index to retrieve information about.

Returns: str: Number of indexed keys as a string

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
index_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'get_indexed_keys_number' MCP tool. Decorated with @mcp.tool() for automatic registration. Connects to Redis, performs a full search query on the index to retrieve the total number of documents, and returns it as a string or an error message if the operation fails.
    @mcp.tool()
    async def get_indexed_keys_number(index_name: str) -> str:
        """Retrieve the number of indexed keys by the index
    
        Args:
            index_name (str): The name of the index to retrieve information about.
    
        Returns:
            str: Number of indexed keys as a string
        """
        try:
            r = RedisConnectionManager.get_connection()
            total = r.ft(index_name).search(Query("*")).total
            return str(total)
        except RedisError as e:
            return f"Error retrieving number of keys: {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 retrieves information (implying read-only) and specifies the return type, but lacks details on permissions, error conditions, rate limits, or whether the count is real-time or cached. For a tool with no annotation coverage, this leaves significant behavioral gaps.

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 well-structured and front-loaded with the core purpose, followed by clear 'Args' and 'Returns' sections. Every sentence earns its place by defining the tool's function, parameter, and return value without redundancy or fluff.

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 the tool has one parameter and an output schema (returns a string), the description is reasonably complete. It explains what the tool does, the parameter's role, and the return type. However, for a tool with no annotations, it could benefit from more behavioral context (e.g., error handling or performance notes).

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 description adds meaningful context for the single parameter: 'index_name (str): The name of the index to retrieve information about.' This clarifies that 'index_name' identifies which index to query, which is valuable given the schema has 0% description coverage (no titles or descriptions in properties). However, it doesn't specify format constraints or valid values.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Retrieve the number of indexed keys by the index'. It specifies the verb ('Retrieve') and resource ('number of indexed keys'), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'get_index_info' or 'get_indexes', which might provide related information about indexes.

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. It doesn't mention sibling tools like 'get_index_info' or 'get_indexes', nor does it specify scenarios where retrieving the count of indexed keys is appropriate versus getting other index metadata. Usage is implied only by the tool's name and description.

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