Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

hgetall

Retrieve all fields and values from a Redis hash key to access stored data. Use this tool to extract complete hash contents for processing or analysis.

Instructions

Get all fields and values from a Redis hash.

Args: name: The Redis hash key.

Returns: A dictionary of field-value pairs or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes

Implementation Reference

  • The main handler function for the 'hgetall' tool. It retrieves all fields and values from a specified Redis hash key using RedisConnectionManager, converts bytes to strings if present, and handles Redis errors by returning an error message.
    @mcp.tool()
    async def hgetall(name: str) -> dict:
        """Get all fields and values from a Redis hash.
    
        Args:
            name: The Redis hash key.
    
        Returns:
            A dictionary of field-value pairs or an error message.
        """
        try:
            r = RedisConnectionManager.get_connection()
            hash_data = r.hgetall(name)
            return (
                {k: v for k, v in hash_data.items()}
                if hash_data
                else f"Hash '{name}' is empty or does not exist."
            )
        except RedisError as e:
            return f"Error getting all fields from hash '{name}': {str(e)}"
  • The load_tools function imports all modules in src/tools, which triggers the @mcp.tool() decorators to register the 'hgetall' tool (among others) with the MCP server.
    def load_tools():
        import src.tools as tools_pkg
    
        for _, module_name, _ in pkgutil.iter_modules(tools_pkg.__path__):
            importlib.import_module(f"src.tools.{module_name}")
    
    
    # Initialize FastMCP server
    mcp = FastMCP("Redis MCP Server", dependencies=["redis", "dotenv", "numpy", "aiohttp"])
    
    # Load tools
    load_tools()
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. It discloses the read-only nature ('Get') and return format ('dictionary of field-value pairs or an error message'), but does not mention error conditions, performance implications, or data size limits that could affect behavior.

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 efficiently structured with a clear purpose statement followed by labeled sections for Args and Returns. Every sentence adds value without redundancy, making it easy to parse and understand quickly.

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 read operation with one parameter and no output schema, the description is mostly complete—it covers purpose, parameter meaning, and return format. However, it lacks details on error handling or edge cases (e.g., non-existent keys), leaving minor gaps in context.

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 schema has 0% description coverage, but the description compensates by explaining the single parameter 'name' as 'The Redis hash key', adding essential semantic context beyond the schema's basic string type. However, it does not detail key naming conventions or validation rules.

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 all fields and values') and resource ('from a Redis hash'), distinguishing it from siblings like hget (single field) or get (string values). It precisely defines the tool's scope 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 Guidelines4/5

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

The description implies usage context by specifying 'Redis hash', but does not explicitly state when to use this versus alternatives like hget (for single fields) or scan_keys (for keys). It provides clear operational context but lacks explicit comparative guidance.

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