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
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| path | No | $ |
Implementation Reference
- src/tools/json.py:47-67 (handler)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)}"
- src/tools/json.py:47-47 (registration)The @mcp.tool() decorator registers the json_get function as an MCP tool.@mcp.tool()