Skip to main content
Glama

zset_range

Retrieve elements from a Redis sorted set by index range. Specify start and stop positions to get members, optionally with their scores.

Instructions

获取有序集合范围

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYes有序集合键名
startYes起始索引
stopYes结束索引
withScoresNo是否返回分数(可选)

Implementation Reference

  • The main execution handler for the 'zset_range' MCP tool. Ensures Redis connection, invokes RedisService.zrange with key, start, stop indices, and optional withScores flag, formats result as JSON text content.
    private async handleZsetRange(args: any) {
      this.ensureRedisConnection();
      const result = await this.redisService!.zrange(args.key, args.start, args.stop, args.withScores);
      
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2)
          }
        ]
      };
    }
  • Input schema definition for the 'zset_range' tool, specifying parameters: key (string), start/stop (numbers), optional withScores (boolean).
    inputSchema: {
      type: 'object',
      properties: {
        key: { type: 'string', description: '有序集合键名' },
        start: { type: 'number', description: '起始索引' },
        stop: { type: 'number', description: '结束索引' },
        withScores: { type: 'boolean', description: '是否返回分数(可选)' }
      },
      required: ['key', 'start', 'stop']
    }
  • Dispatch/registration case in the CallToolRequest handler that routes 'zset_range' calls to the handleZsetRange method.
    case 'zset_range':
      return await this.handleZsetRange(args);
  • Tool registration in ListTools response, including name, description, and input schema for 'zset_range'.
    {
      name: 'zset_range',
      description: '获取有序集合范围',
      inputSchema: {
        type: 'object',
        properties: {
          key: { type: 'string', description: '有序集合键名' },
          start: { type: 'number', description: '起始索引' },
          stop: { type: 'number', description: '结束索引' },
          withScores: { type: 'boolean', description: '是否返回分数(可选)' }
        },
        required: ['key', 'start', 'stop']
      }
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states '获取' (get), implying a read-only operation, but doesn't clarify if it's safe, what happens if the key doesn't exist, or any rate limits. The description lacks details on return format (e.g., list of values, scores if withScores is true) or error conditions, which is insufficient for a tool with no annotation coverage.

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

Conciseness4/5

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

The description is a single phrase '获取有序集合范围', which is concise and front-loaded. It wastes no words, but it may be overly brief, risking under-specification. However, given the schema provides details, this conciseness is efficient, though it could benefit from slightly more context without becoming verbose.

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 tool with 4 parameters (3 required), the description is incomplete. It doesn't explain the return values, error handling, or behavioral traits like read-only nature. For a data retrieval tool in a Redis context with siblings like zset_add, more context is needed to ensure the agent can use it correctly without guesswork.

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 descriptions for all parameters (key, start, stop, withScores). The description adds no meaning beyond the schema, as it doesn't explain parameter interactions (e.g., start and stop are indices, withScores affects output). With high schema coverage, the baseline score is 3, as the description doesn't compensate but doesn't detract either.

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 '获取有序集合范围' (Get sorted set range) states the verb '获取' (get) and resource '有序集合范围' (sorted set range), which is clear but vague. It doesn't specify what 'range' means (e.g., by index, score, or lexicographic order) or distinguish it from sibling tools like zset_add or zset_remove. The purpose is understandable but lacks specificity for precise tool selection.

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 zset_add for adding elements or zset_remove for removing them, nor does it explain prerequisites such as requiring an existing sorted set key. Usage is implied by the name but not explicitly stated, leaving gaps for an AI agent to infer context.

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