delete
Remove a specified key from Redis to manage data storage and maintain database efficiency.
Instructions
Delete a Redis key.
Args: key (str): The key to delete.
Returns: str: Confirmation message or an error message.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes |
Implementation Reference
- src/tools/misc.py:12-27 (handler)The handler function for the 'delete' tool. It deletes the specified Redis key using the Redis client's delete method and returns a success or not-found message. Registered via the @mcp.tool() decorator, which also defines the input schema via type hints and docstring.@mcp.tool() async def delete(key: str) -> str: """Delete a Redis key. Args: key (str): The key to delete. Returns: str: Confirmation message or an error message. """ try: r = RedisConnectionManager.get_connection() result = r.delete(key) return f"Successfully deleted {key}" if result else f"Key {key} not found" except RedisError as e: return f"Error deleting key {key}: {str(e)}"