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

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": "..."} """

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