Redis MCP Server

Redis MCP Server

Enables AI agents to manage and search data in Redis using natural language. Supports hashes, lists, sets, sorted sets, streams, JSON, and vector search.

Category
访问服务器

README

Redis MCP Server

Integration PyPI - Version Python Version MIT licensed Verified on MseeP Docker Image Version codecov

Discord Twitch YouTube Twitter Stack Exchange questions

Overview

The Redis MCP Server is a natural language interface designed for agentic applications to efficiently manage and search data in Redis. It integrates seamlessly with MCP (Model Content Protocol) clients, enabling AI-driven workflows to interact with structured and unstructured data in Redis. Using this MCP Server, you can ask questions like:

  • "Store the entire conversation in a stream"
  • "Cache this item"
  • "Store the session with an expiration time"
  • "Index and search this vector"

Table of Contents

Features

  • Natural Language Queries: Enables AI agents to query and update Redis using natural language.
  • Seamless MCP Integration: Works with any MCP client for smooth communication.
  • Full Redis Support: Handles hashes, lists, sets, sorted sets, streams, and more.
  • Search & Filtering: Supports efficient data retrieval and searching in Redis.
  • Lite Mode: Lightweight mode for maximum flexibility with generic Redis command execution.
  • Scalable & Lightweight: Designed for high-performance data operations.
  • The Redis MCP Server supports the stdio transport. Support to the stremable-http transport will be added in the future.

Tools

This MCP Server provides tools to manage the data stored in Redis.

  • string tools to set, get strings with expiration. Useful for storing simple configuration values, session data, or caching responses.
  • hash tools to store field-value pairs within a single key. The hash can store vector embeddings. Useful for representing objects with multiple attributes, user profiles, or product information where fields can be accessed individually.
  • list tools with common operations to append and pop items. Useful for queues, message brokers, or maintaining a list of most recent actions.
  • set tools to add, remove and list set members. Useful for tracking unique values like user IDs or tags, and for performing set operations like intersection.
  • sorted set tools to manage data for e.g. leaderboards, priority queues, or time-based analytics with score-based ordering.
  • pub/sub functionality to publish messages to channels and subscribe to receive them. Useful for real-time notifications, chat applications, or distributing updates to multiple clients.
  • streams tools to add, read, and delete from data streams. Useful for event sourcing, activity feeds, or sensor data logging with consumer groups support.
  • JSON tools to store, retrieve, and manipulate JSON documents in Redis. Useful for complex nested data structures, document databases, or configuration management with path-based access.

Additional tools.

  • query engine tools to manage vector indexes and perform vector search
  • server management tool to retrieve information about the database
  • redis execute tools for generic Redis command execution (available in Lite Mode)

Lite Mode

Lite Mode is a lightweight operating mode that provides maximum flexibility by offering only generic Redis command execution tools. When enabled, all specialized data-type tools are disabled, and you get access to universal Redis command tools that can execute any Redis command.

Features

  • Disabled by Default: Lite Mode is disabled by default (LITE_MODE=false)
  • Minimal Tool Set: Only 2 generic command execution tools instead of 11+ specialized tools
  • Maximum Flexibility: Execute any Redis command without being limited to predefined tools
  • Environment Controlled: Simply set an environment variable to enable/disable
  • Restart Required: Changes take effect after server restart

Available Tools in Lite Mode

When Lite Mode is enabled, you get access to these two powerful tools:

  1. redis_execute_command: Execute Redis commands with structured arguments

    {
      "command": "SET",
      "args": ["mykey", "myvalue"]
    }
    
  2. redis_execute_raw_command: Execute Redis commands from string format

    {
      "command_str": "SET mykey myvalue"
    }
    

Enabling Lite Mode

Using Environment Variables

# Enable Lite Mode
export LITE_MODE=true

# Disable Lite Mode (default)
export LITE_MODE=false

With uvx

# Enable Lite Mode with uvx
LITE_MODE=true uvx redis-mcp-server --url redis://localhost:6379/0

# Or with environment file
echo "LITE_MODE=true" > .env
uvx --env-file .env redis-mcp-server --url redis://localhost:6379/0

In MCP Client Configuration

{
  "mcpServers": {
    "redis": {
      "command": "uvx",
      "args": [
        "--from",
        "redis-mcp-server@latest",
        "redis-mcp-server",
        "--url",
        "redis://localhost:6379/0"
      ],
      "env": {
        "LITE_MODE": "true"
      }
    }
  }
}

Usage Examples

Basic Operations

# String operations
redis_execute_command("SET", ["key", "value"])
redis_execute_command("GET", ["key"])

# Hash operations
redis_execute_command("HSET", ["myhash", "field", "value"])
redis_execute_command("HGETALL", ["myhash"])

# List operations
redis_execute_command("LPUSH", ["mylist", "item1", "item2"])
redis_execute_command("LRANGE", ["mylist", 0, -1])

# Set operations
redis_execute_command("SADD", ["myset", "member1", "member2"])
redis_execute_command("SMEMBERS", ["myset"])

Advanced Operations

# Sorted sets
redis_execute_command("ZADD", ["myscores", 100, "player1", 200, "player2"])
redis_execute_command("ZRANGE", ["myscores", 0, -1, "WITHSCORES"])

# JSON operations (requires RedisJSON module)
redis_execute_command("JSON.SET", ["mydoc", ".", "{\"name\": \"test\"}"])
redis_execute_command("JSON.GET", ["mydoc", "."])

# Stream operations
redis_execute_command("XADD", ["mystream", "*", "field1", "value1", "field2", "value2"])
redis_execute_command("XRANGE", ["mystream", "-", "+"])

Tool Comparison

Mode Available Tools Tool Type Use Case
Normal Mode 11+ Specialized data-type tools User-friendly, guided operations
Lite Mode 2 Generic command execution Maximum flexibility, any Redis command

When to Use Lite Mode

  • Advanced Users: When you need access to specific Redis commands not covered by standard tools
  • Complex Operations: For multi-step operations that require exact command control
  • Testing & Development: When testing new Redis features or commands
  • Minimal Setup: When you want a simpler, more lightweight toolset
  • Custom Workflows: When building custom automation that needs precise Redis command control

Valid Environment Variable Values

True Values: true, t, 1, TRUE, T False Values: false, f, 0, FALSE, F, or any other value

Performance Considerations

  • Faster Startup: Lite Mode loads fewer tools, resulting in faster server startup
  • Lower Memory Usage: Reduced tool footprint means lower memory consumption
  • Simplified Interface: Fewer tools mean simpler tool discovery and selection

Installation

The Redis MCP Server is available as a PyPI package and as direct installation from the GitHub repository.

From PyPI (recommended)

Configuring the latest Redis MCP Server version from PyPI, as an example, can be done importing the following JSON configuration in the desired framework or tool. The uvx command will download the server on the fly (if not cached already), create a temporary environment, and then run it.

{
  "mcpServers": {
    "RedisMCPServer": {
      "command": "uvx",
      "args": [
        "--from",
        "redis-mcp-server@latest",
        "redis-mcp-server",
        "--url",
        "\"redis://localhost:6379/0\""
      ]
    }
  }
}

URL specification

The format to specify the --url argument follows the redis and rediss schemes:

redis://user:secret@localhost:6379/0?foo=bar&qux=baz

As an example, you can easily connect to a localhost server with:

redis://localhost:6379/0

Where 0 is the logical database you'd like to connect to.

For an encrypted connection to the database (e.g., connecting to a Redis Cloud database), you'd use the rediss scheme.

rediss://user:secret@localhost:6379/0?foo=bar&qux=baz

To verify the server's identity, specify ssl_ca_certs.

rediss://user:secret@hostname:port?ssl_cert_reqs=required&ssl_ca_certs=path_to_the_certificate

For an unverified connection, set ssl_cert_reqs to none

rediss://user:secret@hostname:port?ssl_cert_reqs=none

Configure your connection using the available options in the section "Available CLI Options".

Testing the PyPI package

You can install the package as follows:

pip install redis-mcp-server

And start it using uv the package in your environment.

uv python install 3.13
uv sync
uv run redis-mcp-server --url redis://localhost:6379/0

However, starting the MCP Server is most useful when delegate to the framework or tool where this MCP Server is configured.

From GitHub

You can configure the desired Redis MCP Server version with uvx, which allows you to run it directly from GitHub (from a branch, or use a tagged release).

It is recommended to use a tagged release, the main branch is under active development and may contain breaking changes.

As an example, you can execute the following command to run the 0.2.0 release:

uvx --from git+https://github.com/redis/mcp-redis.git@0.2.0 redis-mcp-server --url redis://localhost:6379/0

Check the release notes for the latest version in the Releases section. Additional examples are provided below.

# Run with Redis URI
uvx --from git+https://github.com/redis/mcp-redis.git redis-mcp-server --url redis://localhost:6379/0

# Run with Redis URI and SSL
uvx --from git+https://github.com/redis/mcp-redis.git redis-mcp-server --url "rediss://<USERNAME>:<PASSWORD>@<HOST>:<PORT>?ssl_cert_reqs=required&ssl_ca_certs=<PATH_TO_CERT>"

# Run with individual parameters
uvx --from git+https://github.com/redis/mcp-redis.git redis-mcp-server --host localhost --port 6379 --password mypassword

# See all options
uvx --from git+https://github.com/redis/mcp-redis.git redis-mcp-server --help

Development Installation

For development or if you prefer to clone the repository:

# 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

# Run with CLI interface
uv run redis-mcp-server --help

# Or run the main file directly (uses environment variables)
uv run src/main.py

Once you cloned the repository, installed the dependencies and verified you can run the server, you can configure Claude Desktop or any other MCP Client to use this MCP Server running the main file directly (it uses environment variables). This is usually preferred for development. The following example is for Claude Desktop, but the same applies to any other MCP Client.

  1. Specify your Redis credentials and TLS configuration
  2. Retrieve your uv command full path (e.g. which uv)
  3. Edit the claude_desktop_config.json configuration file
    • on a MacOS, at ~/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|False,
                "REDIS_SSL_CA_PATH": "<your_redis_ca_path>",
                "REDIS_CLUSTER_MODE": True|False
            }
        }
    }
}

You can troubleshoot problems by tailing the log file.

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

With Docker

You can use a dockerized deployment of this server. You can either build your own image or use the official Redis MCP Docker image.

If you'd like to build your own image, the Redis MCP Server provides a Dockerfile. Build this server's image with:

docker build -t mcp-redis .

Finally, configure the client to create the container at start-up. An example for Claude Desktop is provided below. Edit the claude_desktop_config.json and add:

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

To use the official Redis MCP Docker image, just replace your image name (mcp-redis in the example above) with mcp/redis.

Configuration

The Redis MCP Server can be configured in two ways: via command line arguments or via environment variables. The precedence is: command line arguments > environment variables > default values.

Redis ACL

You can configure Redis ACL to restrict the access to the Redis database. For example, to create a read-only user:

127.0.0.1:6379> ACL SETUSER readonlyuser on >mypassword ~* +@read -@write

Configure the user via command line arguments or environment variables.

Configuration via command line arguments

When using the CLI interface, you can configure the server with command line arguments:

# Basic Redis connection
uvx --from redis-mcp-server@latest redis-mcp-server \
  --host localhost \
  --port 6379 \
  --password mypassword

# Using Redis URI (simpler)
uvx --from redis-mcp-server@latest redis-mcp-server \
  --url redis://user:pass@localhost:6379/0

# SSL connection
uvx --from redis-mcp-server@latest redis-mcp-server \
  --url rediss://user:pass@redis.example.com:6379/0

# See all available options
uvx --from redis-mcp-server@latest redis-mcp-server --help

Available CLI Options:

  • --url - Redis connection URI (redis://user:pass@host:port/db)
  • --host - Redis hostname (default: 127.0.0.1)
  • --port - Redis port (default: 6379)
  • --db - Redis database number (default: 0)
  • --username - Redis username
  • --password - Redis password
  • --ssl - Enable SSL connection
  • --ssl-ca-path - Path to CA certificate file
  • --ssl-keyfile - Path to SSL key file
  • --ssl-certfile - Path to SSL certificate file
  • --ssl-cert-reqs - SSL certificate requirements (default: required)
  • --ssl-ca-certs - Path to CA certificates file
  • --cluster-mode - Enable Redis cluster mode

Configuration via Environment Variables

If desired, you can use environment variables. Defaults are provided for all 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_SSL_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_SSL_CERT_REQS Whether the client should verify the server's certificate "required"
REDIS_SSL_CA_CERTS Path to the trusted CA certificates file None
REDIS_CLUSTER_MODE Enable Redis Cluster mode False
LITE_MODE Enable Lite Mode for generic Redis command execution False

There are several ways to set environment variables:

  1. Using a .env File: Place a .env file in your project directory with key-value pairs for each environment variable. Tools like python-dotenv, pipenv, and uv can automatically load these variables when running your application. This is a convenient and secure way to manage configuration, as it keeps sensitive data out of your shell history and version control (if .env is in .gitignore). For example, create a .env file with the following content from the .env.example file provided in the repository:
cp .env.example .env

Then edit the .env file to set your Redis configuration:

OR,

  1. Setting Variables in the Shell: You can export environment variables directly in your shell before running your application. For example:
export REDIS_HOST=your_redis_host
export REDIS_PORT=6379
# Other variables will be set similarly...

This method is useful for temporary overrides or quick testing.

Logging

The server uses Python's standard logging and is configured at startup. By default it logs at WARNING and above. You can change verbosity with the MCP_REDIS_LOG_LEVEL environment variable.

  • Accepted values (case-insensitive): DEBUG, INFO, WARNING, ERROR, CRITICAL, NOTSET
  • Aliases supported: WARNWARNING, FATALCRITICAL
  • Numeric values are also accepted, including signed (e.g., "10", "+20")
  • Default when unset or unrecognized: WARNING

Handler behavior

  • If the host (e.g., uv, VS Code, pytest) already installed console handlers, the server will NOT add its own; it only lowers overly-restrictive handler thresholds so your chosen level is not filtered out. It will never raise a handler's threshold.
  • If no handlers are present, the server adds a single stderr StreamHandler with a simple format.

Examples

# See normal lifecycle messages
MCP_REDIS_LOG_LEVEL=INFO uv run src/main.py

# Very verbose for debugging
MCP_REDIS_LOG_LEVEL=DEBUG uvx --from redis-mcp-server@latest redis-mcp-server --url redis://localhost:6379/0

In MCP client configs that support env, add it alongside your Redis settings. For example:

{
  "mcpServers": {
    "redis": {
      "command": "uvx",
      "args": ["--from", "redis-mcp-server@latest", "redis-mcp-server", "--url", "redis://localhost:6379/0"],
      "env": {
        "REDIS_HOST": "localhost",
        "REDIS_PORT": "6379",
        "MCP_REDIS_LOG_LEVEL": "INFO",
        "LITE_MODE": "false"
      }
    }
  }
}

Integrations

Integrating this MCP Server to development frameworks like OpenAI Agents SDK, or with tools like Claude Desktop, VS Code, or Augment is described in the following sections.

OpenAI Agents SDK

Integrate this MCP Server with the OpenAI Agents SDK. Read the documents to learn more about the integration of the SDK with MCP.

Install the Python SDK.

pip install openai-agents

Configure the OpenAI token:

export OPENAI_API_KEY="<openai_token>"

And run the application.

python3.13 redis_assistant.py

You can troubleshoot your agent workflows using the OpenAI dashboard.

Augment

The preferred way of configuring the Redis MCP Server in Augment is to use the Easy MCP feature.

You can also configure the Redis MCP Server in Augment manually by importing the server via JSON:

{
  "mcpServers": {
    "Redis MCP Server": {
      "command": "uvx",
      "args": [
        "--from",
        "redis-mcp-server@latest",
        "redis-mcp-server",
        "--url",
        "redis://localhost:6379/0"
      ]
    }
  }
}

Claude Desktop

The simplest way to configure MCP clients is using uvx. Add the following JSON to your claude_desktop_config.json, remember to provide the full path to uvx.

{
  "mcpServers": {
    "redis-mcp-server": {
        "type": "stdio",
        "command": "/Users/mortensi/.local/bin/uvx",
        "args": [
            "--from", "redis-mcp-server@latest",
            "redis-mcp-server",
            "--url", "redis://localhost:6379/0"
        ]
    }
  }
}

VS Code with GitHub Copilot

To use the Redis MCP Server with VS Code, you must nable the agent mode tools. Add the following to your settings.json:

{
  "chat.agent.enabled": true
}

You can start the GitHub desired version of the Redis MCP server using uvx by adding the following JSON to your mcp.json file:

"servers": {
  "redis": {
    "type": "stdio",
    "command": "uvx", 
    "args": [
      "--from", "redis-mcp-server@latest",
      "redis-mcp-server",
      "--url", "redis://localhost:6379/0"
    ]
  },
}

Alternatively, you can start the server using uv and configure your mcp.json. This is usually desired for development.

// mcp.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>",
      }
    }
  }
}

For more information, see the VS Code documentation.

Tip: You can prompt Copilot chat to use the Redis MCP tools by including #redis in your message.

Note: Starting with VS Code v1.102,
MCP servers are now stored in a dedicated mcp.json file instead of settings.json.

Testing

You can use the MCP Inspector for visual debugging of this MCP Server.

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

Example Use Cases

  • AI Assistants: Enable LLMs to fetch, store, and process data in Redis.
  • Chatbots & Virtual Agents: Retrieve session data, manage queues, and personalize responses.
  • Data Search & Analytics: Query Redis for real-time insights and fast lookups.
  • Event Processing: Manage event streams with Redis Streams.

Contributing

  1. Fork the repo
  2. Create a new branch (feature-branch)
  3. Commit your changes
  4. Push to your branch and submit a PR!

License

This project is licensed under the MIT License.

Badges

<a href="https://glama.ai/mcp/servers/@redis/mcp-redis"> <img width="380" height="200" src="https://glama.ai/mcp/servers/@redis/mcp-redis/badge" alt="Redis Server MCP server" /> </a>

Contact

For questions or support, reach out via GitHub Issues.

Alternatively, you can join the Redis Discord server and ask in the #redis-mcp-server channel.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选