Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

smembers

Retrieve all members of a Redis set. Provide the set key to get its values or an error if the key does not exist.

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The actual implementation of the smembers tool handler. It gets a Redis connection, calls r.smembers(name), and returns the members as a list 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 smembers as an MCP tool.
    @mcp.tool()
  • The FastMCP server instance 'mcp' used by the @mcp.tool() decorator is created here.
    mcp = FastMCP(
        "Redis MCP Server", dependencies=["redis", "python-dotenv", "numpy", "aiohttp"]
    )
  • The load_tools() function dynamically imports all modules in src/tools, which triggers the @mcp.tool() decorators and registers them.
    def load_tools():
        import src.tools as tools_pkg
    
        for _, module_name, _ in pkgutil.iter_modules(tools_pkg.__path__):
            importlib.import_module(f"src.tools.{module_name}")
    
    
    # Initialize FastMCP server
    mcp = FastMCP(
        "Redis MCP Server", dependencies=["redis", "python-dotenv", "numpy", "aiohttp"]
    )
    
    # Load tools
    load_tools()
  • The RedisConnectionManager used by smembers to obtain a Redis connection via get_connection().
    import logging
    from typing import Optional, Type, Union
    
    import redis
    from redis import Redis
    from redis.cluster import RedisCluster
    
    from src.common.config import REDIS_CFG, is_entraid_auth_enabled
    from src.common.entraid_auth import (
        create_credential_provider,
        EntraIDAuthenticationError,
    )
    from src.version import __version__
    
    _logger = logging.getLogger(__name__)
    
    
    class RedisConnectionManager:
        _instance: Optional[Redis] = None
    
        @classmethod
        def get_connection(cls, decode_responses=True) -> Redis:
            if cls._instance is None:
                try:
                    # Create Entra ID credential provider if configured
                    credential_provider = None
                    if is_entraid_auth_enabled():
                        try:
                            credential_provider = create_credential_provider()
                        except EntraIDAuthenticationError as e:
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries burden. It mentions returning an error message, hinting at error for non-set keys, but lacks details on behavior for missing keys or performance.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Very concise, two sentences for core description plus args/returns. No wasted text, but could be slightly more structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Simple tool with output schema present. Description covers return type (list or error). Sufficient for basic understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, but description adds minimal gloss: 'The Redis set key.' This adds value beyond the schema's bare field name.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Get all members of a Redis set,' identifying the action and resource. It distinguishes from siblings like 'sadd' and 'srem' by being a read operation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool over alternatives, no prerequisites or context for usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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