hdel
Delete a field from a Redis hash using its key and field name. Removes the specified field to manage hash data.
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
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| key | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/tools/hash.py:58-78 (handler)The hdel tool handler function that deletes a field from a Redis hash. Decorated with @mcp.tool(), it connects to Redis, executes HDEL, and returns a success/not found/error message.
@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)}" - src/tools/hash.py:58-59 (schema)The schema/type signature of hdel: accepts 'name' (Redis hash key) and 'key' (field name) as string parameters, returns a string.
@mcp.tool() async def hdel(name: str, key: str) -> str: - src/tools/hash.py:58-58 (registration)The tool is registered via the @mcp.tool() decorator on the hdel async function.
@mcp.tool() - src/tools/hash.py:7-11 (registration)Import of the 'mcp' server object used for the @mcp.tool() decorator.
from src.common.server import mcp @mcp.tool() async def hset(