hgetall
Retrieve all field-value pairs from a specified Redis hash to access and manage stored data efficiently. Input the hash key to return a dictionary or error message.
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
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes |
Implementation Reference
- src/tools/hash.py:81-100 (handler)The hgetall tool handler: async function decorated with @mcp.tool() that retrieves all fields from a Redis hash using r.hgetall(name), returns dict or error string.@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)}"