Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

type

Retrieve the data type of a specified key in Redis to identify its storage format. Supports efficient data management by verifying key existence and type directly.

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

Implementation Reference

  • The main handler function for the 'type' MCP tool. It uses RedisConnectionManager to get the connection, calls r.type(key) to get the key type, r.ttl(key) for TTL, and returns a dict with key, type, and ttl, or error.
    @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 @mcp.tool() decorator registers the 'type' function as an MCP tool, likely using the function name as the tool name.
    @mcp.tool()

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