Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

get_indexed_keys_number

Get the number of keys indexed by a specific index in Redis, helping you track indexing status.

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 actual handler function for the 'get_indexed_keys_number' tool. It uses the MCP @mcp.tool() decorator to register as a tool, connects to Redis, runs FT.SEARCH with Query('*') to get the total count of indexed keys, and returns it as a string.
    @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)}"
  • The tool is registered via the @mcp.tool() decorator on the get_indexed_keys_number async function.
    @mcp.tool()
    async def get_indexed_keys_number(index_name: str) -> str:
Behavior3/5

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

The description discloses the return type (a string) and the basic operation of retrieving the count of indexed keys. However, it does not mention any behavioral traits such as whether the index must exist, performance implications, or whether the count includes duplicate or pending keys. Given that no annotations are provided, the description carries the burden but remains minimally adequate.

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

Conciseness4/5

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

The description is compact and front-loaded with the purpose. It uses a docstring format that is clear, though the extra line breaks and indentation add minimal overhead. Each sentence serves a purpose, but it could be slightly more concise.

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?

For a simple count retrieval tool with a single parameter and an output schema, the description is complete. It covers the parameter and return type adequately. However, given the number of sibling tools, some guidance on usage context would enhance completeness.

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 compensates for the lack of schema description coverage (0%) by explaining the index_name parameter: 'The name of the index to retrieve information about.' This adds meaning beyond the schema, though it could be more detailed about expected format or constraints.

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 'Retrieve the number of indexed keys by the index', specifying a specific verb and resource. It effectively distinguishes from sibling tools like get_index_info (which likely provides more details) and scan_all_keys (which lists keys).

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?

No guidance is provided on when to use this tool versus alternatives like get_index_info or other index-related tools. The description lacks context on prerequisites or scenarios where this tool is preferred.

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