Skip to main content

Redis MCP Server (redis-client-mcp-py)

支持单机与集群的 Redis MCP Server:连接与 key 发现、INFO、单条命令安全执行(命令由大模型产生,MCP 只做校验与执行)。

环境变量

单连接

变量 说明
REDIS_HOST 主机
REDIS_PORT 端口,默认 6379
REDIS_PASSWORD 密码,可选
REDIS_DB DB 编号,默认 0

多环境(推荐:TEST_REDIS_PROFILES / UAT_REDIS_PROFILES / PROD_REDIS_PROFILES)

每个为 JSON 数组,项内支持:

  • 单机mode: "standalone"(可省略),host, port, password, db, description, name
  • 集群mode: "cluster", hosts: ["host1:6379", "host2:6379"]host+portpassword, description, name

Profile 名为 test_0, prod_0, test_cache(若该项有 name: "cache")等。

安全与行为

变量 默认 说明
REDIS_READ_ONLY false 为 true 时仅允许只读命令
REDIS_MAX_SCAN_KEYS 1000 list_keys/SCAN 单次最多返回 key 数
REDIS_CONFIRM_DANGEROUS true 危险命令需 confirm 或禁止
REDIS_COMMAND_TIMEOUT_SECONDS 30 命令超时(秒)

安装与运行

cd redis-client-mcp-py
uv sync
uv run python -m redis_client_mcp
# 或安装后
redis-client-mcp-py

Cursor / Claude 配置示例

{
  "mcpServers": {
    "redis": {
      "command": "uvx",
      "args": ["redis-client-mcp-py"],
      "env": {
        "TEST_REDIS_PROFILES": "[{\"mode\":\"standalone\",\"host\":\"127.0.0.1\",\"port\":6379,\"description\":\"本机\"}]"
      }
    }
  }
}

工具

工具 说明
list_connections 列出可用连接(profile、单机/集群)
list_keys SCAN 列出 key(pattern、max_scan_keys 限制)
info Redis INFO(可选 section)
analyze_command 分析一条命令(不执行):只读/写/危险、是否需 confirm
execute_command 执行单条命令(由大模型产生);写操作需 confirm=true

资源

  • redis://config - 配置与安全策略摘要
  • redis://keys/{pattern} - 指定 pattern 的 key 列表

设计约定

  • 元数据:list_connections、list_keys、info 由 MCP 提供。
  • CRUD:单条命令,内容由大模型产生,MCP 只做安全检查与执行;写操作需 confirm。

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

redis_client_mcp_py-0.1.1.tar.gz (62.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

redis_client_mcp_py-0.1.1-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file redis_client_mcp_py-0.1.1.tar.gz.

File metadata

  • Download URL: redis_client_mcp_py-0.1.1.tar.gz
  • Upload date:
  • Size: 62.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for redis_client_mcp_py-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c1dabffe8a538aa4a67f6e70ce28a59a2a67a39728103d673d7d5852e35f3750
MD5 41680605eae2f3d7a528b7dd1089688f
BLAKE2b-256 7324e9720e9769f29e6bae92e577e7c7834711d399ec374a2bac46f7cfaeab0f

See more details on using hashes here.

File details

Details for the file redis_client_mcp_py-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for redis_client_mcp_py-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3685b8d74fac119711c12a39c46c5c86982e164590efa96a6187892af883bed8
MD5 a662d6502c71202c47ee300dfeb1c1d9
BLAKE2b-256 4fbb7e36920444c2fefd1b016bf407fbb63cfd114af059a3f65ec3ac8974e900

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page