Redis MCP server

Provides a natural language interface to Redis databases, enabling operations on various data structures with tools for vector similarity search, pub/sub messaging, and server management.
Back to servers
Setup instructions
Provider
Redis
Release date
Mar 29, 2025
Language
Python
Stats
110 stars

The Redis MCP Server is a natural language interface that allows AI agents to interact with Redis databases. It enables applications to manage, query, and search data in Redis using simple natural language requests instead of complex Redis commands.

Installation

# Clone the repository
git clone https://github.com/redis/mcp-redis.git
cd mcp-redis

# Install dependencies using uv
uv venv
source .venv/bin/activate
uv sync

Configuration

The Redis MCP Server can be configured using environment variables:

Name Description Default Value
REDIS_HOST Redis IP or hostname "127.0.0.1"
REDIS_PORT Redis port 6379
REDIS_DB Database 0
REDIS_USERNAME Default database username "default"
REDIS_PWD Default database password ""
REDIS_SSL Enables or disables SSL/TLS False
REDIS_CA_PATH CA certificate for verifying server None
REDIS_SSL_KEYFILE Client's private key file for client authentication None
REDIS_SSL_CERTFILE Client's certificate file for client authentication None
REDIS_CERT_REQS Whether the client should verify the server's certificate "required"
REDIS_CA_CERTS Path to the trusted CA certificates file None
REDIS_CLUSTER_MODE Enable Redis Cluster mode False
MCP_TRANSPORT Use the stdio, streamable-http or sse transport stdio
MCP_HOST Server host when streamable-http or sse are set 127.0.0.1
MCP_PORT Server port when streamable-http or sse are set 8000

You can set these variables using:

  1. Using a .env File:

    cp .env.example .env
    # Then edit the .env file
    
  2. Setting Variables in the Shell:

    export REDIS_HOST=your_redis_host
    export REDIS_PORT=6379
    # Set other variables similarly
    

Available Tools

The MCP Server provides several tools to interact with Redis:

  • String tools: Set and get strings with expiration (for config values, session data, caching)
  • Hash tools: Store field-value pairs within a single key, including vector embeddings
  • List tools: Append and pop items (useful for queues, message brokers)
  • Set tools: Add, remove and list unique values (for user IDs, tags)
  • Sorted set tools: Manage data for leaderboards, priority queues
  • Pub/sub functionality: Publish and subscribe to channels
  • Streams tools: Add, read, and delete from data streams
  • JSON tools: Store, retrieve, and manipulate JSON documents

Additional functionality:

  • Query engine tools: Manage vector indexes and perform vector search
  • Server management tools: Retrieve database information

Transport Methods

Default: STDIO Transport

This is the default configuration where the server communicates with the MCP client via stdin/stdout.

Streamable HTTP

export MCP_TRANSPORT="streamable-http"
uv run src/main.py

For GitHub Copilot configuration:

"mcp": {
    "servers": {
        "redis-mcp": {
            "type": "http",
            "url": "http://127.0.0.1:8000/mcp/"
        }
    }
}

SSE (deprecated)

export MCP_TRANSPORT="sse"
uv run src/main.py

Test with:

curl -i http://127.0.0.1:8000/sse

GitHub Copilot configuration:

"mcp": {
    "servers": {
        "redis-mcp": {
            "type": "sse",
            "url": "http://127.0.0.1:8000/sse"
        }
    }
}

Integration with OpenAI Agents SDK

pip install openai-agents
export OPENAI_API_KEY="<openai_token>"
python3.13 redis_assistant.py

You can monitor agent workflows using the OpenAI dashboard.

Integration with Claude Desktop

Via Smithery

npx -y @smithery/cli install @redis/mcp-redis --client claude

Follow the prompts to configure the server.

Manual Configuration

  1. Edit the claude_desktop_config.json configuration file (on macOS: ~/Library/Application\ Support/Claude/)
{
    "mcpServers": {
        "redis": {
            "command": "<full_path_uv_command>",
            "args": [
                "--directory",
                "<your_mcp_server_directory>",
                "run",
                "src/main.py"
            ],
            "env": {
                "REDIS_HOST": "<your_redis_database_hostname>",
                "REDIS_PORT": "<your_redis_database_port>",
                "REDIS_PWD": "<your_redis_database_password>",
                "REDIS_SSL": true,
                "REDIS_CA_PATH": "<your_redis_ca_path>",
                "REDIS_CLUSTER_MODE": false
            }
        }
    }
}

Using with Docker

docker build -t mcp-redis .

Configure Claude Desktop:

{
  "mcpServers": {
    "redis": {
      "command": "docker",
      "args": ["run",
                "--rm",
                "--name",
                "redis-mcp-server",
                "-i",
                "-e", "REDIS_HOST=<redis_hostname>",
                "-e", "REDIS_PORT=<redis_port>",
                "-e", "REDIS_USERNAME=<redis_username>",
                "-e", "REDIS_PWD=<redis_password>",
                "mcp-redis"]
    }
  }
}

You can also use the official image by replacing mcp-redis with mcp/redis.

Troubleshooting

tail -f ~/Library/Logs/Claude/mcp-server-redis.log

Integration with VS Code

  1. Enable agent mode in settings.json:
{
  "chat.agent.enabled": true
}
  1. Add server configuration to .vscode/mcp.json or settings.json:
{
  "servers": {
    "redis": {
      "type": "stdio",
      "command": "<full_path_uv_command>",
      "args": [
        "--directory",
        "<your_mcp_server_directory>",
        "run",
        "src/main.py"
      ],
      "env": {
        "REDIS_HOST": "<your_redis_database_hostname>",
        "REDIS_PORT": "<your_redis_database_port>",
        "REDIS_USERNAME": "<your_redis_database_username>",
        "REDIS_PWD": "<your_redis_database_password>"
      }
    }
  }
}

Testing

Use the MCP Inspector for visual debugging:

npx @modelcontextprotocol/inspector uv run src/main.py

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "redis" '{"command":"uv","args":["--directory","<your_mcp_server_directory>","run","src/main.py"],"env":{"REDIS_HOST":"<your_redis_database_hostname>","REDIS_PORT":"<your_redis_database_port>","REDIS_USERNAME":"<your_redis_database_username>","REDIS_PWD":"<your_redis_database_password>"}}'

See the official Claude Code MCP documentation for more details.

For 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 > Tools & Integrations and click "New MCP Server".

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

{
    "mcpServers": {
        "redis": {
            "command": "uv",
            "args": [
                "--directory",
                "<your_mcp_server_directory>",
                "run",
                "src/main.py"
            ],
            "env": {
                "REDIS_HOST": "<your_redis_database_hostname>",
                "REDIS_PORT": "<your_redis_database_port>",
                "REDIS_USERNAME": "<your_redis_database_username>",
                "REDIS_PWD": "<your_redis_database_password>"
            }
        }
    }
}

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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "redis": {
            "command": "uv",
            "args": [
                "--directory",
                "<your_mcp_server_directory>",
                "run",
                "src/main.py"
            ],
            "env": {
                "REDIS_HOST": "<your_redis_database_hostname>",
                "REDIS_PORT": "<your_redis_database_port>",
                "REDIS_USERNAME": "<your_redis_database_username>",
                "REDIS_PWD": "<your_redis_database_password>"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

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