hdel
Remove a specific field from a Redis hash by specifying the hash key and field name. Simplifies data management in Redis by enabling precise deletion of hash fields.
Instructions
Delete a field from a Redis hash.
Args: name: The Redis hash key. key: The field name inside the hash.
Returns: A success message or an error message.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | ||
| name | Yes |
Implementation Reference
- src/tools/hash.py:58-78 (handler)The main handler function for the 'hdel' tool. It is decorated with @mcp.tool() which registers it as an MCP tool. The function deletes a specified field from a Redis hash and returns a success message if deleted or indicates if not found, handling Redis errors appropriately.@mcp.tool() async def hdel(name: str, key: str) -> str: """Delete a field from a Redis hash. Args: name: The Redis hash key. key: The field name inside the hash. Returns: A success message or an error message. """ try: r = RedisConnectionManager.get_connection() deleted = r.hdel(name, key) return ( f"Field '{key}' deleted from hash '{name}'." if deleted else f"Field '{key}' not found in hash '{name}'." ) except RedisError as e: return f"Error deleting field '{key}' from hash '{name}': {str(e)}"