A FastMCP-based server with SSE support for Redis operations
Project description
Redis MCP Server
A Model Context Protocol (MCP) server for Redis operations built with FastMCP.
Features
- Core Redis operations: get, set, delete, list
- Bulk operations: mget, mset
- Pattern-based key scanning
- Connection pooling for efficient Redis access
- Multiple transport support (stdio, SSE, streamable-http)
- Environment-based configuration
- Type hints and comprehensive error handling
Installation
From PyPI
pip install redis-mcp
Or using uv:
uv tool install redis-mcp
From Source
# Clone the repository
git clone https://github.com/yourusername/redis-mcp.git
cd redis-mcp
# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install the package
pip install -e .
Configuration
The server can be configured via environment variables:
REDIS_HOST: Redis server hostname (default: localhost)REDIS_PORT: Redis server port (default: 6379)REDIS_DB: Redis database number (default: 0)REDIS_PASSWORD: Redis password (optional)REDIS_USERNAME: Redis username (optional)
Usage
As a CLI Tool
# Using stdio transport (default)
redis-mcp
# Using SSE transport
redis-mcp --transport sse
# With custom Redis connection
redis-mcp --host redis.example.com --port 6380 --db 1
In Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"redis": {
"command": "uv",
"args": ["tool", "run", "redis-mcp"],
"env": {
"REDIS_HOST": "localhost",
"REDIS_PORT": "6379"
}
}
}
}
Available Tools
- get: Retrieve a value by key
- set: Store a key-value pair with optional expiry and conditions
- delete: Remove one or more keys
- list: List keys matching a pattern
- mget: Get multiple values in one operation
- mset: Set multiple key-value pairs in one operation
- scan: Iterate through keys matching a pattern without blocking
Example Usage
from fastmcp import Client
async def main():
async with Client("http://localhost:8000/sse") as client:
# Set a value
await client.call_tool("set", {"key": "user:123", "value": "John Doe"})
# Get a value
result = await client.call_tool("get", {"key": "user:123"})
print(result) # "John Doe"
# List keys
keys = await client.call_tool("list", {"pattern": "user:*"})
print(keys) # ["user:123"]
Development
Setup
# Install development dependencies
pip install -e ".[dev]"
Running Tests
pytest
Code Quality
# Format code
black .
isort .
# Type checking
mypy .
# Linting
ruff check .
Requirements
- Python 3.10+
- Redis server
- FastMCP 2.3.3+
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
redis_mcp-0.1.1.tar.gz
(41.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file redis_mcp-0.1.1.tar.gz.
File metadata
- Download URL: redis_mcp-0.1.1.tar.gz
- Upload date:
- Size: 41.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5170cc243298409de27d2a469dba25746c346a7d20479f4f42e696c19d4addf
|
|
| MD5 |
a52f2867e2c11689fa176489d582198c
|
|
| BLAKE2b-256 |
a83f9702fc66a0a60b347fcfa215cc1514a514104bb4b0ed1aaa808cb3c03589
|
File details
Details for the file redis_mcp-0.1.1-py3-none-any.whl.
File metadata
- Download URL: redis_mcp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af63f466e8a07e803ddaabbe7f34bc5869ecbb880951c5966df4921418bbaeaa
|
|
| MD5 |
3d785b46a6d297f614a6e6782d42dc3b
|
|
| BLAKE2b-256 |
e36e908055bc3a46e6f8bffa0fe98adb7f217436c5d6ac9afb8d72e736f29f73
|