Skip to main content
Glama
farhankaz

Redis MCP Server

by farhankaz

zadd

Add one or more score-value pairs to a sorted set in Redis, enabling organized data storage and retrieval for efficient database management.

Instructions

Add one or more members to a sorted set

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesSorted set key
membersYesArray of score-value pairs to add

Implementation Reference

  • The execute method of ZAddTool that performs the zadd operation: validates input, maps members, calls Redis client.zAdd, and returns success or error response.
    async execute(args: unknown, client: RedisClientType): Promise<ToolResponse> {
      if (!this.validateArgs(args)) {
        return this.createErrorResponse('Invalid arguments for zadd');
      }
    
      try {
        const members = args.members.map(member => ({
          score: member.score,
          value: member.value
        }));
    
        const result = await client.zAdd(args.key, members);
        return this.createSuccessResponse(`Added ${result} new members to the sorted set`);
      } catch (error) {
        return this.createErrorResponse(`Failed to add members to sorted set: ${error}`);
      }
    }
  • Input schema definition for the zadd tool, specifying the structure of key and members array with score-value objects.
    inputSchema = {
      type: 'object',
      properties: {
        key: { type: 'string', description: 'Sorted set key' },
        members: {
          type: 'array',
          description: 'Array of score-value pairs to add',
          items: {
            type: 'object',
            properties: {
              score: { type: 'number', description: 'Score for the member' },
              value: { type: 'string', description: 'Member value' }
            },
            required: ['score', 'value']
          }
        }
      },
      required: ['key', 'members']
    };
  • TypeScript interface defining the arguments for the zadd tool.
    export interface ZAddArgs {
      key: string;
      members: Array<{score: number; value: string}>;
    }
  • Instantiation of ZAddTool in the default tools array for registration in ToolRegistry.
    new ZAddTool(),
  • Validation function for zadd arguments ensuring correct types for key and members array.
    validateArgs(args: unknown): args is ZAddArgs {
      return typeof args === 'object' && args !== null &&
        'key' in args && typeof (args as any).key === 'string' &&
        'members' in args && Array.isArray((args as any).members) &&
        (args as any).members.every((member: any) =>
          typeof member === 'object' && member !== null &&
          'score' in member && typeof member.score === 'number' &&
          'value' in member && typeof member.value === 'string'
        );
    }
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 ('Add') but does not cover critical aspects like whether this is a mutation (implied but not explicit), error conditions (e.g., if key is not a sorted set), or performance implications (e.g., handling of duplicates). This leaves significant gaps in understanding 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, direct sentence that efficiently conveys the core functionality without any wasted words. It is front-loaded with the essential action and resource, making it highly concise and well-structured for quick comprehension.

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 complexity of a mutation tool with no annotations and no output schema, the description is insufficient. It lacks details on return values, error handling, and behavioral nuances (e.g., how duplicates are handled), leaving the agent with incomplete context for reliable tool invocation.

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 schema description coverage is 100%, with clear documentation for 'key' and 'members' parameters. The description adds no additional semantic context beyond what the schema provides, such as examples or edge cases, so it meets the baseline for adequate but unenhanced parameter understanding.

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 ('Add') and resource ('one or more members to a sorted set'), making the purpose immediately understandable. However, it does not explicitly differentiate from sibling tools like 'sadd' (which adds to a set) or 'zrem' (which removes from a sorted set), which would be needed for a perfect score.

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 like 'sadd' for sets or 'zrem' for removal from sorted sets. It also lacks context on prerequisites, such as whether the key must exist or if it creates a new sorted set, leaving the agent with minimal usage direction.

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