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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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()
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic read operation. It doesn't disclose behavioral traits like whether it requires specific Redis permissions, how it handles non-existent hash keys (returns False vs error), rate limits, or performance characteristics. The description is minimal beyond the core functionality.

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 perfectly structured and front-loaded with the core purpose, followed by clear Arg and Return sections. Every sentence earns its place with zero waste, making it easy to parse quickly.

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?

Given the tool's low complexity (simple existence check), 2 parameters, no annotations, but with output schema (returns boolean), the description is reasonably complete. It explains what the tool does, parameters, and return value, though could benefit from more behavioral context given the lack of annotations.

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?

Schema description coverage is 0%, but the description compensates by clearly explaining both parameters: 'name' as the Redis hash key and 'key' as the field name inside the hash. This adds essential meaning beyond the bare schema, though it doesn't cover format constraints or examples.

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 the specific action ('Check if a field exists') and resource ('in a Redis hash'), distinguishing it from siblings like hget (retrieves field value) or hset (sets field value). It precisely defines the tool's scope without ambiguity.

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 usage for existence checking in Redis hashes but doesn't explicitly state when to use this tool versus alternatives like hget (which returns null for non-existent fields) or hgetall (which retrieves all fields). No exclusions or prerequisites are mentioned.

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