Skip to main content
Glama

hash_mset

Set multiple hash field-value pairs in Redis with a single command to optimize database operations and reduce network overhead.

Instructions

批量设置哈希字段

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYes哈希键名
fieldValuesYes字段值对数组

Implementation Reference

  • MCP tool handler for 'hash_mset' that ensures Redis connection and delegates to RedisService.hmset
    private async handleHashMset(args: any) {
      this.ensureRedisConnection();
      const result = await this.redisService!.hmset(args.key, args.fieldValues);
      
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2)
          }
        ]
      };
    }
  • Input schema definition for the 'hash_mset' tool in the ListTools response
    {
      name: 'hash_mset',
      description: '批量设置哈希字段',
      inputSchema: {
        type: 'object',
        properties: {
          key: { type: 'string', description: '哈希键名' },
          fieldValues: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                field: { type: 'string', description: '字段名' },
                value: { type: 'string', description: '字段值' }
              },
              required: ['field', 'value']
            },
            description: '字段值对数组'
          }
        },
        required: ['key', 'fieldValues']
      }
  • Dispatch/registration of 'hash_mset' handler in the CallToolRequest switch statement
    case 'hash_mset':
      return await this.handleHashMset(args);
  • Core Redis HMSET implementation in RedisService that converts fieldValues array to object and calls underlying Redis client hSet
    async hmset(key: string, fieldValues: RedisHashField[]): Promise<RedisOperationResult<number>> {
      return this.executeCommand(async () => {
        if (!this.client) throw new Error('Redis client not initialized');
        
        const fields: Record<string, string> = {};
        fieldValues.forEach(fv => {
          fields[fv.field] = fv.value;
        });
        
        return await this.client.hSet(key, fields);
      });
    }
Behavior2/5

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

With no annotations, the description carries full burden but provides minimal behavioral insight. It implies a write operation ('设置' means set), but doesn't disclose whether this overwrites existing fields, creates new ones, requires the hash to exist, has atomicity guarantees, or returns any confirmation. For a mutation tool with zero annotation coverage, this is inadequate.

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 phrase ('批量设置哈希字段') with zero wasted words. It's appropriately sized for a simple tool and front-loads the core action.

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?

For a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what happens on success/failure, return values, or side effects. Given the complexity of batch operations and lack of structured safety hints, more context is needed.

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%, with clear parameter documentation in Chinese. The description adds no additional meaning beyond the schema, which already defines 'key' as hash key name and 'fieldValues' as array of field-value pairs. Baseline 3 is appropriate since the schema does the heavy lifting.

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

Purpose3/5

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

The description '批量设置哈希字段' (batch set hash fields) states the action (set) and target (hash fields), but is vague about scope and lacks sibling differentiation. It doesn't specify whether this creates new fields, updates existing ones, or both, nor does it distinguish from hash_set (single field set) or other data structure tools like string_mset.

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 is provided on when to use this tool versus alternatives. It doesn't mention hash_set for single-field operations, hash_getall for reading, or other batch operations like string_mset. There's no context about prerequisites, error conditions, or performance implications.

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

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/pickstar-2002/redis-mcp'

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