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
43.8K stars

The Redis MCP Server is a specialized server that allows Large Language Models to interact with Redis databases through the Model Context Protocol. It provides standardized tools for reading, writing, and managing data in Redis key-value stores, making it possible for AI models to directly work with Redis databases.

Prerequisites

Before installing the Redis MCP server, ensure you have:

  1. A Redis server installed and running

Installation and Setup

Using Docker

You can run the Redis MCP server using Docker:

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

Notes for Docker usage:

  • When running Docker on macOS, use host.docker.internal if the server is running on the host network
  • The Redis URL can be specified as an argument (defaults to "redis://localhost:6379")
  • If localhost fails, try using the explicit IP: "redis://127.0.0.1:6379"

Using NPX

Alternatively, you can run the server using NPX:

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

Integration with Claude Desktop

To use this server with the Claude Desktop app, add the following configuration to the "mcpServers" section of your claude_desktop_config.json:

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"
      ]
    }
  }
}

Integration with VS Code

For manual installation in VS Code, add the following to your User Settings (JSON) file:

{
  "mcp": {
    "inputs": [
      {
        "type": "promptString",
        "id": "redis_url",
        "description": "Redis URL (e.g. redis://localhost:6379)"
      }
    ],
    "servers": {
      "redis": {
        "command": "npx",
        "args": ["-y", "@modelcontextprotocol/server-redis"],
        "env": {
          "REDIS_URL": "${input:redis_url}"
        }
      }
    }
  }
}

For Docker installation in VS Code:

{
  "mcp": {
    "inputs": [
      {
        "type": "promptString",
        "id": "redis_url",
        "description": "Redis URL (e.g. redis://host.docker.internal:6379)"
      }
    ],
    "servers": {
      "redis": {
        "command": "docker",
        "args": ["run", "-i", "--rm", "mcp/redis"],
        "env": {
          "REDIS_URL": "${input:redis_url}"
        }
      }
    }
  }
}

Available Tools

The Redis MCP server provides the following tools:

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:

  • Verify your Redis server is running:
    • Redis: redis-cli ping should return "PONG"
    • Memurai (Windows): memurai-cli ping should return "PONG"
  • Check service status:
    • Linux: systemctl status redis
    • macOS: brew services list
    • Windows: Check Memurai in Services (services.msc)
  • Ensure the correct port (default 6379) is not blocked by firewall
  • Verify your Redis URL format: redis://hostname:port
  • If redis://localhost:6379 fails, try using the explicit IP: redis://127.0.0.1:6379

Server Behavior Notes

  • The server implements exponential backoff with a maximum of 5 retries
  • Initial retry delay is 1 second, with a maximum delay of 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