get
Retrieve stored string values from Redis by specifying the key. Enables efficient data access and management for agentic applications.
Instructions
Get a Redis string value.
Args: key (str): The key to retrieve.
Returns: str, bytes: The stored value or an error message.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes |
Implementation Reference
- src/tools/string.py:51-78 (handler)The main handler function for the 'get' MCP tool, which retrieves a string value from Redis by key, handling encoding and errors appropriately.@mcp.tool() async def get(key: str) -> Union[str, bytes]: """Get a Redis string value. Args: key (str): The key to retrieve. Returns: str, bytes: The stored value or an error message. """ try: r: Redis = RedisConnectionManager.get_connection() value = r.get(key) if value is None: return f"Key {key} does not exist" if isinstance(value, bytes): try: text = value.decode("utf-8") return text except UnicodeDecodeError: return value return value except RedisError as e: return f"Error retrieving key {key}: {str(e)}"