Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

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
NameRequiredDescriptionDefault
keyYes

Implementation Reference

  • 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)}"

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