Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

hget

Retrieve the value of a specific field within a Redis hash using key and field name, enabling efficient data access and management in Redis MCP Server.

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

Implementation Reference

  • The 'hget' tool handler function, decorated with @mcp.tool(). It connects to Redis via RedisConnectionManager, performs r.hget(name, key), and returns the value or an appropriate message on error or not found.
    @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)}"
  • Registers all MCP tools by dynamically importing every module in src/tools (including hash.py containing hget), which executes the @mcp.tool() decorators.
    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