Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

hget

Retrieve a field value from a Redis hash by specifying the hash key and field name. Returns the value or an error if the field does not exist.

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 actual handler function for the 'hget' tool. Decorated with @mcp.tool(), takes 'name' (Redis hash key) and 'key' (field name), calls Redis HGET, and returns the value or an error 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 on the hget function registers it as an MCP tool named 'hget'.
    @mcp.tool()
  • src/tools/hash.py:7-10 (registration)
    The mcp server instance imported from src.common.server, which provides the @mcp.tool() decorator used to register hget.
    from src.common.server import mcp
    
    
    @mcp.tool()
Behavior3/5

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

The description mentions 'or an error message' but does not clarify behavior for missing keys or nonexistent hashes. With no annotations, the description provides minimal but adequate transparency for a simple get operation.

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 short and includes an Args/Returns section, but the Arg descriptions are essentially redundant with the schema. Still, it avoids unnecessary verbosity.

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

Completeness3/5

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

The description covers the core operation and mentions error handling, but given the complexity of Redis hash operations and the presence of many sibling tools, it could better explain edge cases or return formats.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, and the description only restates parameter names ('The Redis hash key', 'The field name inside the hash') without adding meaningful context beyond what the schema titles already provide.

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 uses a specific verb ('Get') and clearly identifies the resource ('value of a field in a Redis hash'), which distinguishes it from siblings like hgetall or hset.

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 on when to use this tool versus alternatives such as hset, hgetall, or hexists. The description lacks context for the agent to choose appropriately.

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