Redis MCP

Redis MCP

数据库
redis/mcp-redis555 星标
Redis
claudecursorvscodegeneric
FreeOpen Source

关于此服务器

Redis 官方 MCP 服务器,为智能体提供自然语言接口来管理和搜索 Redis 中的数据——读写键值、操作 Hash/List/Set、向量搜索与全文检索,适合为 AI 应用做记忆与缓存层。

安装方式

uvx --from git+https://github.com/redis/mcp-redis.git redis-mcp-server
官方 README 安装指南(英文原文)

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.

commandline
{
  "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:

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

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

commandline
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.

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

To verify the server's identity, specify ssl_ca_certs.

commandline
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

commandline
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:

sh
pip install redis-mcp-server

And start it using uv the package in your environment.

sh
uv python install 3.14
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:

commandline
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.

sh
# 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:

sh
# 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/

json
{
    "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.

commandline
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:

commandline
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:

json
{
  "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.

常见问题

Redis MCP 主要用来做什么?

让智能体用自然语言直接操作 Redis:存取键值、管理 Hash/List/Set/Sorted Set、设置过期时间,还能用 Redis 的向量与全文检索能力。常见用途是给 AI 应用做对话记忆、语义缓存和会话状态存储。

Redis MCP 怎么安装?

这是 Python 实现,推荐用 uvx 免安装运行:uvx --from git+https://github.com/redis/mcp-redis.git redis-mcp-server,再通过 --url redis://... 或环境变量传入你的 Redis 连接信息;也支持 pip 安装与 Docker。

能连 Redis Cloud 吗?免费吗?

能。用 rediss:// 连接串即可接 Redis Cloud 或任意兼容实例。MCP 服务器本身开源免费(MIT);本地 Redis 与 Redis Cloud 免费层零成本,只有更高规格的托管实例才计费。