Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

rename

Rename a Redis key by providing the current key name and the new key name. Updates the key identifier in the database.

Instructions

Renames a Redis key from old_key to new_key.

Args: old_key (str): The current name of the Redis key to rename. new_key (str): The new name to assign to the key.

Returns: Dict[str, Any]: A dictionary containing the result of the operation. On success: {"status": "success", "message": "..."} On error: {"error": "..."}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
old_keyYes
new_keyYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The rename tool handler function. Decorated with @mcp.tool(), it renames a Redis key from old_key to new_key. Validates that the old key exists before renaming, catches RedisError exceptions, and returns a dict with status/error information.
    @mcp.tool()
    async def rename(old_key: str, new_key: str) -> Dict[str, Any]:
        """
        Renames a Redis key from old_key to new_key.
    
        Args:
            old_key (str): The current name of the Redis key to rename.
            new_key (str): The new name to assign to the key.
    
        Returns:
            Dict[str, Any]: A dictionary containing the result of the operation.
                On success: {"status": "success", "message": "..."}
                On error: {"error": "..."}
        """
        try:
            r = RedisConnectionManager.get_connection()
    
            # Check if the old key exists
            if not r.exists(old_key):
                return {"error": f"Key '{old_key}' does not exist."}
    
            # Rename the key
            r.rename(old_key, new_key)
            return {
                "status": "success",
                "message": f"Renamed key '{old_key}' to '{new_key}'",
            }
    
        except RedisError as e:
            return {"error": str(e)}
  • The rename function is registered as an MCP tool via the @mcp.tool() decorator on line 76.
    @mcp.tool()
  • The FastMCP server (mcp) is initialized here. The @mcp.tool() decorator used in misc.py registers tools on this server instance. The load_tools() function dynamically imports all tool modules including misc.py.
    import importlib
    import pkgutil
    from mcp.server.fastmcp import FastMCP
    
    
    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", "python-dotenv", "numpy", "aiohttp"]
    )
    
    # Load tools
    load_tools()
Behavior2/5

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

Lacks disclosure of critical behavior: what happens if new_key already exists (overwrites in Redis). No mention of destructiveness or permissions. With no annotations, description should cover these.

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?

Three concise sentences for purpose, then structured Args and Returns. No wasted words, front-loaded with main action.

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

Completeness4/5

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

Adequately covers purpose and return for a simple tool, but omits behavioral details (overwrite) that would make it fully self-contained. Output schema provided compensates partially.

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

Parameters4/5

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

Adds meaning beyond the schema: explains old_key is current name, new_key is new name, and provides return structure. Schema had 0% description coverage, so this is valuable, though missing constraints like key existence.

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 tool renames a Redis key from old_key to new_key, with specific args and return format. It is not a tautology and distinguishes from siblings.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives (e.g., copy, delete). No mention of prerequisites (key must exist) or when not to use (e.g., if new_key exists).

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