Skip to main content
Glama
farhankaz

Redis MCP Server

by farhankaz

smembers

Retrieve all members from a specific set stored in Redis using the Model Context Protocol (MCP), enabling efficient data management and access for set operations.

Instructions

Get all members in a set

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesSet key

Implementation Reference

  • The execute method implements the smembers tool logic: validates args, calls Redis client.sMembers(key), handles empty set or errors, returns formatted members or messages.
    async execute(args: unknown, client: RedisClientType): Promise<ToolResponse> {
      if (!this.validateArgs(args)) {
        return this.createErrorResponse('Invalid arguments for smembers');
      }
    
      try {
        const members = await client.sMembers(args.key);
        if (members.length === 0) {
          return this.createSuccessResponse('Set is empty or does not exist');
        }
        return this.createSuccessResponse(JSON.stringify(members, null, 2));
      } catch (error) {
        return this.createErrorResponse(`Failed to get set members: ${error}`);
      }
    }
  • Input schema definition for the smembers tool, specifying the required 'key' parameter.
    inputSchema = {
      type: 'object',
      properties: {
        key: { type: 'string', description: 'Set key' }
      },
      required: ['key']
    };
  • TypeScript interface defining the arguments for smembers tool (key: string).
    export interface SMembersArgs {
      key: string;
    }
  • Instantiation and registration of SMembersTool in the default tools array of ToolRegistry.
    new SMembersTool(),
  • Import of SMembersTool for registration in tool registry.
    import { SMembersTool } from './smembers_tool.js';

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Related 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/farhankaz/redis-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server