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
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes |
Implementation Reference
- src/tools/misc.py:30-48 (handler)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)}
- src/tools/misc.py:30-30 (registration)The @mcp.tool() decorator registers the 'type' function as an MCP tool, likely using the function name as the tool name.@mcp.tool()