Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

type

Check the data type of a value stored at a given Redis key. Returns the type as a string or 'none' if the key does not exist.

Instructions

Returns the string representation of the type of the value stored at key

Args: key (str): The key to check.

Returns: str: The type of key, or none when key doesn't exist

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'type' tool. Uses Redis TYPE command to get the type of a key's value, also returns TTL. Registered via @mcp.tool() decorator.
    @mcp.tool()
    async def type(key: str) -> Dict[str, Any]:
        """Returns the string representation of the type of the value stored at key
    
        Args:
            key (str): The key to check.
    
        Returns:
            str: The type of key, or none when key doesn't exist
        """
        try:
            r = RedisConnectionManager.get_connection()
            key_type = r.type(key)
            info = {"key": key, "type": key_type, "ttl": r.ttl(key)}
    
            return info
        except RedisError as e:
            return {"error": str(e)}
  • The FastMCP server initialization and tool loading mechanism. All modules in src/tools/ are auto-imported, and the @mcp.tool() decorator registers each tool function with FastMCP.
    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 'type' handler depends on RedisConnectionManager (for database connection) and the mcp server instance (for the @mcp.tool() decorator).
    from src.common.connection import RedisConnectionManager
    from src.common.server import mcp
  • The 'type' tool accepts a single string parameter 'key' and returns a dictionary with key, type, and ttl fields.
    async def type(key: str) -> Dict[str, Any]:
        """Returns the string representation of the type of the value stored at key
Behavior4/5

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

The description discloses that 'none' is returned when the key does not exist, which is a key behavioral aspect. Since no annotations are provided, the description carries the full burden; it adequately covers the core behavior without contradictions. It does not mention side effects, but none are expected for a read-only type check.

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

Conciseness5/5

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

The description is extremely concise, using only two sentences plus a structured Args/Returns block. Every sentence provides essential information without redundancy or fluff. It is front-loaded and easy to parse.

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?

For a simple type-check tool, the description is contextually complete: it covers the purpose, the single parameter, and the return behavior. Given that the server has many sibling tools for other operations, this description allows an agent to confidently select and invoke the tool without ambiguity.

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

Parameters4/5

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

The input schema has no description for the 'key' parameter (0% coverage), but the tool description includes an 'Args' section that specifies the key's purpose. This compensates for the schema gap, providing sufficient semantic meaning for an agent to understand and correctly provide the parameter.

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

Purpose5/5

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

The description clearly states that the tool returns the string representation of the type of a value stored at a given key. This differentiates it from sibling tools like 'get' which return the value itself, and from type-checking or existence-checking commands.

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

Usage Guidelines3/5

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

The description implies when to use this tool (to check the type of a stored value) through its definition, but does not explicitly mention when not to use it or provide alternatives. Sibling tools exist for related tasks (e.g., 'get' for retrieving values), so guidance on differentiation would improve clarity.

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