Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

get

Retrieve stored string values from Redis by specifying their keys to access data in 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
NameRequiredDescriptionDefault
keyYes

Implementation Reference

  • The handler function for the MCP 'get' tool, which retrieves a string value from Redis using the r.get(key) command, handles bytes decoding, and returns 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)}"

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