Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

lpush

Add a value to the beginning of a Redis list and optionally set an expiration time for the list.

Instructions

Push a value onto the left of a Redis list and optionally set an expiration time.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
valueYes
expireNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'lpush' MCP tool. Decorated with @mcp.tool(), it pushes a value to the left side of a Redis list using r.lpush(), optionally sets an expiration, and returns a success or error message.
    @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)}"
  • The registration mechanism for all tools, including 'lpush'. Imports all modules in src/tools package, triggering the @mcp.tool() decorators to register the tools with the FastMCP server.
    def load_tools():
        import src.tools as tools_pkg
    
        for _, module_name, _ in pkgutil.iter_modules(tools_pkg.__path__):
            importlib.import_module(f"src.tools.{module_name}")
    
    
    # Initialize FastMCP server
    mcp = FastMCP("Redis MCP Server", dependencies=["redis", "dotenv", "numpy", "aiohttp"])
    
    # Load tools
    load_tools()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the optional expiration feature, which adds some context beyond basic functionality. However, it doesn't describe important behavioral aspects like whether this is a destructive operation (it modifies the list), what happens if the key doesn't exist (creates new list), or the return value (new list length).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core functionality ('Push a value onto the left of a Redis list') and adds the optional feature as a concise extension. Every word earns its place with no redundancy or unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that there's an output schema (which handles return values) but no annotations and 0% schema description coverage, the description is moderately complete. It covers the basic operation and optional expiration, but doesn't address behavioral aspects like creation of new lists, atomicity, or error conditions that would be helpful for a mutation tool with undocumented parameters.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage for all 3 parameters, the description must compensate but only partially does so. It mentions 'value' and 'expiration time' but doesn't explain the 'name' parameter (the Redis key name). The description adds some meaning for 'value' and 'expire' but leaves 'name' completely unexplained, failing to fully compensate for the schema coverage gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Push a value onto the left of a Redis list') and distinguishes it from sibling tools like 'rpush' (right push) and 'lpop' (left pop). It identifies both the verb ('Push') and the resource ('Redis list'), making the purpose immediately understandable.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for adding elements to Redis lists, but doesn't explicitly state when to use this tool versus alternatives like 'rpush' (for right-side insertion) or 'sadd' (for sets). It mentions the optional expiration feature, which provides some context, but lacks explicit guidance on tool selection scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/redis/mcp-redis'

If you have feedback or need assistance with the MCP directory API, please join our Discord server