Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

json_get

Retrieve specific JSON values from Redis keys using JSON path queries to access nested data structures.

Instructions

Retrieve a JSON value from Redis at a given path.

Args: name: The Redis key where the JSON document is stored. path: The JSON path to retrieve (default: root '$').

Returns: The retrieved JSON value or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
pathNo$

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'json_get' tool. It uses Redis JSON .get() to retrieve data from a specified path in a JSON document stored in Redis. Includes error handling and formats the output as an indented JSON string. The @mcp.tool() decorator registers it as an MCP tool.
    @mcp.tool()
    async def json_get(name: str, path: str = "$") -> str:
        """Retrieve a JSON value from Redis at a given path.
    
        Args:
            name: The Redis key where the JSON document is stored.
            path: The JSON path to retrieve (default: root '$').
    
        Returns:
            The retrieved JSON value or an error message.
        """
        try:
            r = RedisConnectionManager.get_connection()
            value = r.json().get(name, path)
            if value is not None:
                # Convert the value to JSON string for consistent return type
                return json.dumps(value, ensure_ascii=False, indent=2)
            else:
                return f"No data found at path '{path}' in '{name}'."
        except RedisError as e:
            return f"Error retrieving JSON value at path '{path}' in '{name}': {str(e)}"
  • The @mcp.tool() decorator registers the json_get function as an MCP tool.
    @mcp.tool()
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses the tool's read-only nature ('Retrieve') and mentions error handling ('or an error message'), but lacks details on permissions, rate limits, or what happens if the key/path doesn't exist. It adds some behavioral context but is incomplete for a tool with no annotation coverage.

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 efficiently structured with a clear purpose statement followed by labeled sections for Args and Returns. Every sentence adds value without redundancy, and it's appropriately sized for a simple retrieval tool.

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, no annotations, and the presence of an output schema (which handles return values), the description is mostly complete. It covers purpose, parameters, and basic behavior, but could improve by adding more behavioral context (e.g., error conditions) to fully compensate for 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?

With 0% schema description coverage, the description compensates well by explaining both parameters: 'name' as 'The Redis key where the JSON document is stored' and 'path' as 'The JSON path to retrieve (default: root '$')'. It adds clear meaning beyond the schema's basic titles, though it doesn't detail path syntax or key constraints.

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 ('Retrieve a JSON value'), resource ('from Redis'), and scope ('at a given path'), distinguishing it from sibling tools like 'get' (which retrieves raw values) and 'json_set' (which writes JSON). It precisely communicates what the tool does 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 Guidelines4/5

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

The description implies usage context by specifying it retrieves JSON values from Redis, but does not explicitly state when to use this tool versus alternatives like 'get' (for non-JSON data) or 'json_del' (for deletion). It provides clear operational context but lacks explicit comparative guidance.

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