set_add
Add one or multiple members to a Redis set using the specified key. This tool helps store unique values in Redis for data management and deduplication.
Instructions
添加集合成员
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | 集合键名 | |
| members | Yes | 要添加的成员或成员数组 |
Implementation Reference
- src/services/mcpService.ts:1092-1104 (handler)The handler function that executes the 'set_add' tool logic: checks Redis connection, adds members to set using RedisService.sadd, and returns formatted result.private async handleSetAdd(args: any) { this.ensureRedisConnection(); const result = await this.redisService!.sadd(args.key, args.members); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; }
- src/services/mcpService.ts:352-372 (schema)The input schema definition for the 'set_add' tool provided in the ListTools response.{ name: 'set_add', description: '添加集合成员', inputSchema: { type: 'object', properties: { key: { type: 'string', description: '集合键名' }, members: { oneOf: [ { type: 'string', description: '成员' }, { type: 'array', items: { type: 'string' }, description: '成员数组' } ], description: '要添加的成员或成员数组' } }, required: ['key', 'members'] }
- src/services/mcpService.ts:670-671 (registration)The switch case in the CallToolRequestSchema handler that registers and dispatches 'set_add' tool calls to its handler function.case 'set_add': return await this.handleSetAdd(args);