Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

rename

Change the name of a Redis key from an old identifier to a new one, updating data references within 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 core handler function for the 'rename' MCP tool. It uses RedisConnectionManager to get a connection, checks if the old_key exists, renames it to new_key using r.rename(), and returns success or error dict.
    @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 @mcp.tool() decorator registers the rename function as an MCP tool.
    @mcp.tool()
  • Type hints and docstring defining input parameters (old_key: str, new_key: str) and output format (Dict[str, Any] with status or error).
    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": "..."}
        """
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool renames a key and returns a success/error dictionary, but fails to describe critical behaviors: whether the operation is atomic, if it overwrites existing keys, what happens if old_key doesn't exist, or any side effects on associated data (e.g., TTL, data type). This leaves significant gaps for a mutation tool.

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 well-structured and front-loaded with the core purpose in the first sentence. The Args and Returns sections are organized efficiently, with no redundant or verbose explanations. Every sentence serves a clear purpose, making it easy to parse.

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 the tool's complexity (a mutation with 2 parameters), no annotations, and an output schema present (implied by Returns section), the description is partially complete. It covers parameters and return format adequately but lacks behavioral details like error conditions, atomicity, or side effects, which are crucial for safe usage in a Redis context.

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?

Schema description coverage is 0%, but the description compensates by clearly defining both parameters in the Args section: 'old_key' as the current name and 'new_key' as the new name. It adds meaningful semantics beyond the schema's generic titles ('Old Key', 'New Key'), though it doesn't detail constraints like key naming rules or length limits.

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 ('renames') and resource ('a Redis key'), distinguishing it from sibling tools like 'delete' or 'set'. It explicitly identifies both the source ('old_key') and destination ('new_key'), making the purpose unambiguous.

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?

The description provides no guidance on when to use this tool versus alternatives like 'set' (for overwriting) or 'delete' followed by 'set' (for similar functionality). It lacks context about prerequisites, such as whether the old_key must exist or new_key must not exist, or any error conditions like key collisions.

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