Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

hgetall

Retrieve all fields and values from a Redis hash key to access stored data. Use this tool to extract complete hash contents for processing or analysis.

Instructions

Get all fields and values from a Redis hash.

Args: name: The Redis hash key.

Returns: A dictionary of field-value pairs or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes

Implementation Reference

  • The main handler function for the 'hgetall' tool. It retrieves all fields and values from a specified Redis hash key using RedisConnectionManager, converts bytes to strings if present, and handles Redis errors by returning an error message.
    @mcp.tool() async def hgetall(name: str) -> dict: """Get all fields and values from a Redis hash. Args: name: The Redis hash key. Returns: A dictionary of field-value pairs or an error message. """ try: r = RedisConnectionManager.get_connection() hash_data = r.hgetall(name) return ( {k: v for k, v in hash_data.items()} if hash_data else f"Hash '{name}' is empty or does not exist." ) except RedisError as e: return f"Error getting all fields from hash '{name}': {str(e)}"
  • The load_tools function imports all modules in src/tools, which triggers the @mcp.tool() decorators to register the 'hgetall' tool (among others) with the MCP server.
    def load_tools(): import src.tools as tools_pkg for _, module_name, _ in pkgutil.iter_modules(tools_pkg.__path__): importlib.import_module(f"src.tools.{module_name}") # Initialize FastMCP server mcp = FastMCP("Redis MCP Server", dependencies=["redis", "dotenv", "numpy", "aiohttp"]) # Load tools load_tools()

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