by prajwalnayak7
Provides an MCP server that exposes Redis operations as resources and tools for LLM integration, enabling caching, key‑value storage, list, hash, set, and Pub/Sub interactions with automatic reconnection handling.
Mcp Server Redis implements an MCP‑compatible server that wraps common Redis commands into resources (status, info, key listing) and tools (basic CRUD, list, hash, set, and Pub/Sub operations). It is designed for LLMs or other agents to interact with Redis‑based caches, AWS MemoryDB, or any compatible key‑value store without writing custom code.
uv
Python tool. Example:
uv venv
source .venv/bin/activate
uv sync
.env.example
to .env
and fill in your Redis host, port, password, etc.python src/server.py
mcp dev src/server.py
) or by installing the server in Claude Desktop (mcp install src/server.py
).redis://status
, redis://info
, redis://keys/{pattern}
get_value
, set_value
(with expiry), delete_key
, increment
list_push
, list_range
hash_set
, hash_get
set_add
, set_members
publish_message
Q: Which Redis variants are supported? A: Any Redis‑compatible service, including AWS MemoryDB, Azure Cache for Redis, or a local Redis instance.
Q: Do I need to modify code to add new Redis commands?
A: New commands can be added by creating additional tool modules under src/tools/
and exposing them via the MCP server.
Q: How does the server handle connection failures?
A: It includes retry logic that automatically reconnects and reports the status through the redis://status
resource.
Q: Can I limit which keys are exposed?
A: The redis://keys/{pattern}
resource lets you query keys by pattern, allowing you to enforce naming conventions.
Q: Is authentication required?
A: Provide credentials in the .env
file; the server uses them to establish a secure connection to Redis.
The structure is as follows:
mcp-server-redis/
├── src/
│ ├── __init__.py
│ ├── main.py # Main entry point
│ ├── config.py # Configuration
│ ├── connection.py # Redis connection management
│ ├── resources/ # Resource implementations
│ │ ├── __init__.py
│ │ ├── status.py # Connection status resources
│ │ └── keys.py # Key-related resources
│ └── tools/ # Tool implementations
│ ├── __init__.py
│ ├── basic.py # Basic Redis operations
│ ├── lists.py # List operations
│ ├── hashes.py # Hash operations
│ ├── sets.py # Set operations
│ └── pubsub.py # Pub/Sub operations
├── tests/ # Test directory
│ └── __init__.py
├── README.md
└── pyproject.toml
To use this server, you'll need to:
Install the required dependencies:
[If not already installed] https://docs.astral.sh/uv/
uv venv
source .venv/bin/activate
uv sync
Refer to the .env.example file to configure your Redis connection by adding the appropriate variables.
Run the server:
python src/server.py
Resources:
Tools:
Each tool includes error handling and returns meaningful responses. The server will automatically reconnect to Redis if the connection is lost.
You can test it with the MCP Inspector:
mcp dev src/server.py
Or install it in Claude Desktop:
mcp install src/server.py
User: What's the current Redis connection status?
LLM: Let me check the Redis connection status for you.
[Reading resource redis://status]
The Redis server is currently connected and running on localhost:6379, database 0.
User: Can you store my name "Alice" in Redis?
LLM: I'll help you store your name in Redis using the set_value tool.
[Calling set_value with key="name" value="Alice"]
Successfully set key 'name'
I've stored your name "Alice" in Redis under the key "name". Would you like me to verify the value was stored correctly by retrieving it?
User: Yes please verify it
LLM: I'll retrieve the value using the get_value tool.
[Calling get_value with key="name"]
Alice
Yes, I can confirm that your name "Alice" was successfully stored in Redis and can be retrieved correctly. The value matches exactly what we stored.
This implementation provides a solid foundation for Redis integration through MCP. You can extend it further by adding more Redis commands as needed for your specific use case.
Please log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by googleapis
An MCP server that streamlines database tool development by handling connection pooling, authentication, observability, and secure access, allowing agents to interact with databases via natural language.
by bytebase
Provides a universal gateway that lets MCP‑compatible clients explore and query MySQL, PostgreSQL, SQL Server, MariaDB, and SQLite databases through a single standardized interface.
by designcomputer
Enables secure interaction with MySQL databases via the Model Context Protocol, allowing AI applications to list tables, read contents, and execute queries safely.
by benborla
Provides read‑only access to MySQL databases for large language models, allowing schema inspection and safe execution of SQL queries.
by ClickHouse
Enables AI assistants to run read‑only ClickHouse queries, list databases and tables, and execute embedded chDB queries through an MCP interface.
by chroma-core
Offers an MCP server exposing Chroma's vector database capabilities for LLM applications, supporting collection and document management, multiple embedding functions, and flexible client types such as in‑memory, persistent, HTTP, and cloud.
by kiliczsh
Enables LLMs to interact with MongoDB databases via a standardized interface, offering schema inspection, query execution, aggregation, and write capabilities, with optional read‑only mode and smart ObjectId handling.
by domdomegg
Provides read and write access to Airtable bases for AI systems, enabling inspection of schemas and manipulation of records.
by XGenerationLab
A Model Context Protocol (MCP) server that enables natural language queries to databases