lpush
Add a value to the left of a Redis list and optionally set an expiration time, enabling efficient list management and time-based data control in Redis.
Instructions
Push a value onto the left of a Redis list and optionally set an expiration time.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expire | No | ||
| name | Yes | ||
| value | Yes |
Implementation Reference
- src/tools/list.py:11-21 (handler)The handler function for the lpush tool. It uses RedisConnectionManager to get a connection, performs r.lpush(name, value), optionally sets expiration with r.expire, and returns a success or error message. The @mcp.tool() decorator registers it as an MCP tool.@mcp.tool() async def lpush(name: str, value: FieldT, expire: Optional[int] = None) -> str: """Push a value onto the left of a Redis list and optionally set an expiration time.""" try: r = RedisConnectionManager.get_connection() r.lpush(name, value) if expire: r.expire(name, expire) return f"Value '{value}' pushed to the left of list '{name}'." except RedisError as e: return f"Error pushing value to list '{name}': {str(e)}"