Skip to main content
Glama
farhankaz

Redis MCP Server

by farhankaz

hmset

Set multiple hash fields to specific values in a Redis database using a single command, streamlining data updates and improving efficiency in hash management.

Instructions

Set multiple hash fields to multiple values

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fieldsYesField-value pairs to set
keyYesHash key

Implementation Reference

  • The execute method implements the core hmset logic using Redis client.hSet(key, fields).
    async execute(args: unknown, client: RedisClientType): Promise<ToolResponse> {
      if (!this.validateArgs(args)) {
        return this.createErrorResponse('Invalid arguments for hmset');
      }
    
      try {
        await client.hSet(args.key, args.fields);
        return this.createSuccessResponse('Hash fields set successfully');
      } catch (error) {
        return this.createErrorResponse(`Failed to set hash fields: ${error}`);
      }
    }
  • JSON schema defining the input parameters for the hmset tool: key (string) and fields (object).
    inputSchema = {
      type: 'object',
      properties: {
        key: { type: 'string', description: 'Hash key' },
        fields: { 
          type: 'object',
          description: 'Field-value pairs to set',
          additionalProperties: { type: 'string' }
        }
      },
      required: ['key', 'fields']
    };
  • Registers HMSetTool as part of the default tools in ToolRegistry by instantiating and adding to the registry.
    const defaultTools = [
      new HMSetTool(),
      new HGetTool(),
      new HGetAllTool(),
      new ScanTool(),
      new SetTool(),
      new GetTool(),
      new DelTool(),
      new ZAddTool(),
      new ZRangeTool(),
      new ZRangeByScoreTool(),
      new ZRemTool(),
      new SAddTool(),
      new SMembersTool(),
    ];
  • TypeScript type definition for HMSetArgs used in hmset tool validation.
    export interface HMSetArgs {
      key: string;
      fields: Record<string, string>;
    }
  • Validates input arguments match HMSetArgs structure before execution.
    validateArgs(args: unknown): args is HMSetArgs {
      return typeof args === 'object' && args !== null &&
        'key' in args && typeof (args as any).key === 'string' &&
        'fields' in args && typeof (args as any).fields === 'object';
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the action is to 'set' values, implying a write/mutation operation, but doesn't disclose behavioral traits like whether it overwrites existing fields, requires specific permissions, has side effects, or how errors are handled. The description is minimal and lacks critical context for a mutation tool.

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, efficient sentence with zero waste. It's front-loaded with the core purpose and appropriately sized for the tool's complexity.

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 no annotations, no output schema, and a mutation tool with 2 parameters, the description is incomplete. It lacks information on return values, error handling, permissions, or how it interacts with sibling tools. The high schema coverage helps, but the description doesn't compensate for missing behavioral 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?

Schema description coverage is 100%, so the schema already documents both parameters ('key' as hash key and 'fields' as field-value pairs). The description adds no additional meaning beyond what the schema provides, such as examples, constraints, or usage notes. Baseline 3 is appropriate when schema does the heavy lifting.

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 ('Set multiple hash fields to multiple values') and identifies the resource (hash fields/values). It distinguishes from basic 'set' by specifying multiple fields, but doesn't explicitly differentiate from other hash operations like hget or hgetall among siblings.

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?

No guidance on when to use this tool versus alternatives like 'set' (for single values) or other hash operations. The description implies it's for hash data structures but doesn't specify prerequisites, constraints, or when to choose this over other hash tools like hgetall for reading.

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