Skip to main content

MCP server to interact with redis server, aws memory DB, etc for caching or other use-cases where in-memory and key-value based storage is appropriate

Project description

MseeP.ai Security Assessment Badge

Usage

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

Capabilities of this server

Resources:

  • redis://status - Current connection status
  • redis://info - Redis server information
  • redis://keys/{pattern} - List keys matching a pattern

Tools:

  • Basic operations:
    • get_value - Get a value
    • set_value - Set a value with optional expiry
    • delete_key - Delete a key
    • increment - Increment a numeric value
  • List operations:
    • list_push - Push values to a list
    • list_range - Get range of list values
  • Hash operations:
    • hash_set - Set hash fields
    • hash_get - Get hash fields
  • Set operations:
    • set_add - Add to a set
    • set_members - Get set members
  • Pub/Sub:
    • publish_message - Publish a message

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

Example

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.

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

iflow_mcp_mcp_server_redis-0.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

iflow_mcp_mcp_server_redis-0.1.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file iflow_mcp_mcp_server_redis-0.1.0.tar.gz.

File metadata

  • Download URL: iflow_mcp_mcp_server_redis-0.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_mcp_server_redis-0.1.0.tar.gz
Algorithm Hash digest
SHA256 70d357afd6e46150cf93c4eb608ee1f67f3c3323884fe2165b8a4fe5503b73f7
MD5 a403e2153044db8db14c9678ed6b1ebd
BLAKE2b-256 a27cb8e3a12476cd3c9502ed1139ecd86484f208006fae02c6ba50e1daf067f7

See more details on using hashes here.

File details

Details for the file iflow_mcp_mcp_server_redis-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_mcp_server_redis-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_mcp_server_redis-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78e57ac3ad18fbd150f5535a5625b5d6919b7d1538fb2ad341c6365a1a3b42a6
MD5 ee2a065f2d937bdd633816a2f9313542
BLAKE2b-256 e1a871a2e2b541a4917547d13570570926c34327033da199ef5bb533a067f59d

See more details on using hashes here.

Supported by

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