Skip to main content
Glama
farhankaz

Redis MCP Server

by farhankaz

hgetall

Retrieve all fields and values stored in a specific hash key within a Redis database using the Model Context Protocol (MCP) for structured data management.

Instructions

Get all the fields and values in a hash

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesHash key

Implementation Reference

  • The execute method implements the hgetall tool logic: validates args, calls Redis hGetAll on the key, and returns formatted response or error.
    async execute(args: unknown, client: RedisClientType): Promise<ToolResponse> { if (!this.validateArgs(args)) { return this.createErrorResponse('Invalid arguments for hgetall'); } try { const value = await client.hGetAll(args.key); if (Object.keys(value).length === 0) { return this.createSuccessResponse('Hash not found or empty'); } return this.createSuccessResponse(JSON.stringify(value, null, 2)); } catch (error) { return this.createErrorResponse(`Failed to get hash: ${error}`); } }
  • JSON schema defining input for hgetall tool: requires 'key' string.
    inputSchema = { type: 'object', properties: { key: { type: 'string', description: 'Hash key' } }, required: ['key'] };
  • TypeScript interface for HGetAllArgs used in validation.
    export interface HGetAllArgs { key: string; }
  • Imports and instantiates HGetAllTool for registration in ToolRegistry's default tools.
    import { HGetAllTool } from './hgetall_tool.js'; import { ScanTool } from './scan_tool.js'; import { SetTool } from './set_tool.js'; import { GetTool } from './get_tool.js'; import { DelTool } from './del_tool.js'; import { ZAddTool } from './zadd_tool.js'; import { ZRangeTool } from './zrange_tool.js'; import { ZRangeByScoreTool } from './zrangebyscore_tool.js'; import { ZRemTool } from './zrem_tool.js'; import { SAddTool } from './sadd_tool.js'; import { SMembersTool } from './smembers_tool.js'; export class ToolRegistry { private tools: Map<string, BaseTool>; constructor() { this.tools = new Map(); this.registerDefaultTools(); } private registerDefaultTools() { const defaultTools = [ new HMSetTool(), new HGetTool(), new HGetAllTool(),
Install Server

Other Tools

Related 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/farhankaz/redis-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server