zset_range
Retrieve specified range of elements from a Redis sorted set by providing the key, start, and stop indices. Optionally include scores for detailed analysis.
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 handler function that implements the zset_range tool. It ensures Redis connection, calls zrange on RedisService, and returns the JSON-formatted result.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:467-480 (schema)The input schema and tool metadata definition for zset_range, registered in the ListTools response.{ 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'] } },
- src/services/mcpService.ts:682-683 (registration)The switch case that registers and dispatches the zset_range tool call to its handler.case 'zset_range': return await this.handleZsetRange(args);