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(),
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action but lacks details on error behavior (e.g., what happens if the key doesn't exist or isn't a hash), return format (e.g., whether it's a list, map, or raw data), or performance implications (e.g., memory usage for large hashes). This leaves significant gaps for an agent to understand the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no wasted words. It is front-loaded with the core action and resource, making it easy to parse quickly. Every part of the sentence contributes directly to understanding the tool's purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete for a tool that retrieves data. It doesn't explain what the return value looks like (e.g., a dictionary of field-value pairs), error conditions, or how it differs from similar tools like 'hget'. For a read operation with no structured output documentation, this leaves the agent with insufficient context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the 'key' parameter clearly documented as 'Hash key'. The description adds no additional semantic context beyond this, such as examples of valid keys or constraints. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get all') and the resource ('fields and values in a hash'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'hget' (which gets a single field) or 'get' (which gets a string value), leaving some ambiguity about when to choose this specific tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'hget' for single-field retrieval or 'scan' for iterative scanning, nor does it specify prerequisites such as the hash's existence or error handling for missing keys.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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