Redis MCP server

Integrates Redis to enable set/get/delete/list operations on Redis instances
Back to servers
Provider
Model Context Protocol
Release date
Feb 08, 2025
Language
TypeScript
Stats
39.3K stars

The Redis MCP server enables Large Language Models (LLMs) to interact with Redis key-value stores through a standardized set of tools. This server bridges the gap between AI models and Redis databases, allowing for data storage, retrieval, and manipulation operations.

Prerequisites

Before using the Redis MCP server, you need:

  1. A running Redis server installation

Installation and Setup

Using Docker

Run the Redis MCP server using Docker:

docker run -i --rm mcp/redis redis://localhost:6379

When running on macOS with Docker, use host.docker.internal instead of localhost if the Redis server is on the host network:

docker run -i --rm mcp/redis redis://host.docker.internal:6379

Using NPX

You can also run the server directly with NPX:

npx -y @modelcontextprotocol/server-redis redis://localhost:6379

The Redis URL is optional and defaults to redis://localhost:6379. If you experience connection issues with localhost, try using the explicit IP redis://127.0.0.1:6379.

Integration with Claude Desktop

To use this server with the Claude Desktop app, add the following configuration to your claude_desktop_config.json file:

Docker Configuration

{
  "mcpServers": {
    "redis": {
      "command": "docker",
      "args": [
        "run", 
        "- i", 
        "--rm", 
        "mcp/redis", 
        "redis://host.docker.internal:6379"]
    }
  }
}

NPX Configuration

{
  "mcpServers": {
    "redis": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-redis",
        "redis://localhost:6379"
      ]
    }
  }
}

Available Tools

The Redis MCP server provides several tools for interacting with Redis:

Set

Sets a Redis key-value pair with optional expiration:

  • key (string): Redis key
  • value (string): Value to store
  • expireSeconds (number, optional): Expiration time in seconds

Get

Retrieves a value by key from Redis:

  • key (string): Redis key to retrieve

Delete

Deletes one or more keys from Redis:

  • key (string | string[]): Key or array of keys to delete

List

Lists Redis keys matching a pattern:

  • pattern (string, optional): Pattern to match keys (default: *)

Troubleshooting

Connection Errors

If you encounter an ECONNREFUSED error:

  1. Verify the Redis server is running:

    • Redis: redis-cli ping should return "PONG"
    • Memurai (Windows): memurai-cli ping should return "PONG"
  2. Check the service status:

    • Linux: systemctl status redis
    • macOS: brew services list
    • Windows: Check Memurai in Services (services.msc)
  3. Ensure the Redis port (default 6379) isn't blocked by a firewall

  4. Try using the explicit IP address:

    • Instead of redis://localhost:6379
    • Use redis://127.0.0.1:6379

Server Reconnection Behavior

The server implements these connection policies:

  • Exponential backoff with maximum 5 retries
  • Initial retry delay: 1 second
  • Maximum delay: 30 seconds
  • The server will exit after maximum retries to prevent infinite reconnection loops

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later