sadd
Add one or multiple members to a Redis set using the specified key, enabling efficient data management and organization within the Redis MCP Server.
Instructions
Add one or more members to a set
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Set key | |
| members | Yes | Members to add to the set |
Implementation Reference
- src/tools/sadd_tool.ts:28-39 (handler)The execute method implements the core logic of the 'sadd' tool, validating arguments and performing the Redis sAdd operation.async execute(args: unknown, client: RedisClientType): Promise<ToolResponse> { if (!this.validateArgs(args)) { return this.createErrorResponse('Invalid arguments for sadd'); } try { const result = await client.sAdd(args.key, args.members); return this.createSuccessResponse(`Added ${result} new member(s) to the set`); } catch (error) { return this.createErrorResponse(`Failed to add members to set: ${error}`); } }
- src/tools/sadd_tool.ts:8-19 (schema)Input schema definition for the 'sadd' tool, specifying the expected arguments structure.inputSchema = { type: 'object', properties: { key: { type: 'string', description: 'Set key' }, members: { type: 'array', items: { type: 'string' }, description: 'Members to add to the set' } }, required: ['key', 'members'] };
- src/interfaces/types.ts:70-73 (schema)TypeScript interface defining the SAddArgs used for type-checking the tool inputs.export interface SAddArgs { key: string; members: string[]; }
- src/tools/tool_registry.ts:37-37 (registration)Instantiation and registration of the SAddTool instance in the default tools array.new SAddTool(),