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
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| key | Yes |
Implementation Reference
- src/tools/hash.py:39-55 (handler)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)}"
- src/tools/hash.py:39-39 (registration)The @mcp.tool() decorator registers the hget function as an MCP tool.@mcp.tool()
- src/tools/hash.py:40-49 (schema)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. """