Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

json_get

Extract specific JSON values from Redis keys using a defined path. Simplify data retrieval by querying nested JSON structures directly, enabling efficient data management and integration.

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$

Implementation Reference

  • The handler function implementing the json_get tool logic. It retrieves a JSON value from Redis using the redis-py JSON module at the specified path in the document named by 'name'. Returns the JSON string or error message. Registered via @mcp.tool() decorator.
    @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, inferring schema from the function signature and docstring.
    @mcp.tool()
  • The function signature and docstring define the input schema (name: str, path: str = '$') and output (str).
    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. """

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