Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

hget

Retrieve specific field values from Redis hash data structures by specifying the hash key and field name.

Instructions

Get the value of a field in a Redis hash.

Args: name: The Redis hash key. key: The field name inside the hash.

Returns: The field value or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
keyYes

Implementation Reference

  • The main handler function for the 'hget' tool, decorated with @mcp.tool() for registration. It retrieves a specific field value from a Redis hash using RedisConnectionManager, handling errors and returning the value or a not-found message.
    @mcp.tool() async def hget(name: str, key: str) -> str: """Get the value of a field in a Redis hash. Args: name: The Redis hash key. key: The field name inside the hash. Returns: The field value or an error message. """ try: r = RedisConnectionManager.get_connection() value = r.hget(name, key) return value if value else f"Field '{key}' not found in hash '{name}'." except RedisError as e: return f"Error getting field '{key}' from hash '{name}': {str(e)}"
  • The @mcp.tool() decorator registers the hget function as an MCP tool.
    @mcp.tool()
  • Function signature and docstring define the input schema (name: str, key: str) and output (str), serving as the tool schema.
    async def hget(name: str, key: str) -> str: """Get the value of a field in a Redis hash. Args: name: The Redis hash key. key: The field name inside the hash. Returns: The field value or an error message. """

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