Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

smembers

Retrieve all members of a specified Redis set by providing the set key, returning a list of values or an error message.

Instructions

Get all members of a Redis set.

Args: name: The Redis set key.

Returns: A list of values in the set or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes

Implementation Reference

  • The main handler function for the 'smembers' tool, decorated with @mcp.tool() for registration. It retrieves all members from a specified Redis set key using RedisConnectionManager, handles empty sets and Redis errors, returning a list of members or an error message.
    @mcp.tool() async def smembers(name: str) -> Union[str, List[str]]: """Get all members of a Redis set. Args: name: The Redis set key. Returns: A list of values in the set or an error message. """ try: r = RedisConnectionManager.get_connection() members = r.smembers(name) return list(members) if members else f"Set '{name}' is empty or does not exist." except RedisError as e: return f"Error retrieving members of set '{name}': {str(e)}"
  • src/tools/set.py:58-58 (registration)
    The @mcp.tool() decorator registers the smembers function as an MCP tool.
    @mcp.tool()
  • The function signature and docstring define the input schema (name: str) and output schema (Union[str, List[str]]).
    @mcp.tool() async def smembers(name: str) -> Union[str, List[str]]: """Get all members of a Redis set. Args: name: The Redis set key. Returns: A list of values in the set or an error message. """

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

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