Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

hget

Retrieve specific field values from Redis hash data structures by specifying the hash key and field name.

Instructions

Get the value of a field in a Redis hash.

Args: name: The Redis hash key. key: The field name inside the hash.

Returns: The field value or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
keyYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'hget' tool, decorated with @mcp.tool() for registration. It retrieves a specific field value from a Redis hash using RedisConnectionManager, handling errors and returning the value or a not-found message.
    @mcp.tool()
    async def hget(name: str, key: str) -> str:
        """Get the value of a field in a Redis hash.
    
        Args:
            name: The Redis hash key.
            key: The field name inside the hash.
    
        Returns:
            The field value or an error message.
        """
        try:
            r = RedisConnectionManager.get_connection()
            value = r.hget(name, key)
            return value if value else f"Field '{key}' not found in hash '{name}'."
        except RedisError as e:
            return f"Error getting field '{key}' from hash '{name}': {str(e)}"
  • The @mcp.tool() decorator registers the hget function as an MCP tool.
    @mcp.tool()
  • Function signature and docstring define the input schema (name: str, key: str) and output (str), serving as the tool schema.
    async def hget(name: str, key: str) -> str:
        """Get the value of a field in a Redis hash.
    
        Args:
            name: The Redis hash key.
            key: The field name inside the hash.
    
        Returns:
            The field value or an error message.
        """
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 of behavioral disclosure. It mentions that it 'Returns: The field value or an error message,' which covers basic output behavior, but lacks details on error conditions (e.g., if the hash or field doesn't exist), performance implications, or any rate limits. For a read operation with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves beyond the basic function.

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 front-loaded with a clear purpose statement, followed by structured sections for 'Args' and 'Returns' that are efficiently formatted. Every sentence earns its place by providing essential information without redundancy, making it easy to scan 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?

Given the tool's low complexity (a simple read operation), 2 parameters, and the presence of an output schema (which handles return value details), the description is largely complete. It covers the purpose, parameters, and basic return behavior. However, it could be more complete by including error-handling examples or clarifying when to use versus siblings, especially since annotations are absent.

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 semantics beyond the input schema, which has 0% description coverage. It explains that 'name' is 'The Redis hash key' and 'key' is 'The field name inside the hash,' clarifying the purpose and relationship of each parameter. This compensates well for the lack of schema descriptions, though it doesn't cover edge cases like data types 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 the specific action ('Get the value') and resource ('a field in a Redis hash'), distinguishing it from siblings like 'get' (for simple keys) or 'hgetall' (for all fields in a hash). It precisely identifies the tool's scope and target data structure.

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 implies usage for retrieving a single field from a Redis hash, but doesn't explicitly state when to use this versus alternatives like 'hgetall' (for all fields) or 'hexists' (to check existence). No exclusions or prerequisites are mentioned, leaving usage context inferred rather than explicitly guided.

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