Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

rename

Renames a Redis key from old_key to new_key, providing a dictionary indicating the operation's success or error. Use it to update key names efficiently in Redis databases.

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
new_keyYes
old_keyYes

Implementation Reference

  • The 'rename' tool handler function, including registration via @mcp.tool() decorator, input schema via type hints and docstring, and execution logic using RedisConnectionManager to rename a Redis key.
    @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)}

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