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
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | 有序集合键名 | |
| start | Yes | 起始索引 | |
| stop | Yes | 结束索引 | |
| withScores | No | 是否返回分数(可选) |
Implementation Reference
- src/services/mcpService.ts:1177-1189 (handler)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) } ] }; }
- src/services/mcpService.ts:470-479 (schema)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'] }
- src/services/mcpService.ts:682-683 (registration)Dispatch/registration case in the CallToolRequest handler that routes 'zset_range' calls to the handleZsetRange method.case 'zset_range': return await this.handleZsetRange(args);
- src/services/mcpService.ts:467-480 (registration)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'] } },