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
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| key | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/tools/hash.py:39-55 (handler)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)}" - src/tools/hash.py:39-39 (registration)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()