Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

hexists

Check if a specific field exists within a Redis hash by providing the hash key and field name.

Instructions

Check if a field exists in a Redis hash.

Args: name: The Redis hash key. key: The field name inside the hash.

Returns: True if the field exists, False otherwise.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
keyYes

Implementation Reference

  • The hexists tool implementation: an async function decorated with @mcp.tool() that registers and handles the tool. It checks if a Redis hash field exists by calling r.hexists(name, key), returning True/False or error string.
    @mcp.tool()
    async def hexists(name: str, key: str) -> bool:
        """Check if a field exists in a Redis hash.
    
        Args:
            name: The Redis hash key.
            key: The field name inside the hash.
    
        Returns:
            True if the field exists, False otherwise.
        """
        try:
            r = RedisConnectionManager.get_connection()
            return r.hexists(name, key)
        except RedisError as e:
            return f"Error checking existence of field '{key}' in hash '{name}': {str(e)}"
  • The @mcp.tool() decorator registers the hexists function as an MCP tool.
    @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