Redis MCP server

Bridge to Redis databases, enabling fast in-memory data operations for AI workflows.
Back to servers
Provider
Farhan Kaz
Release date
Jan 07, 2025
Language
TypeScript
Package
Stats
956 downloads
6 stars

The Redis MCP Server provides access to Redis database operations through the Model Context Protocol (MCP). It enables AI assistants to interact with Redis databases, supporting various Redis commands for hash manipulation, key operations, string management, sorted sets, and more.

Installation

Prerequisites

  • Node.js and npm installed
  • Redis server running (default: localhost:6379)

Installation via Smithery

The easiest way to install Redis MCP Server is through Smithery:

npx -y @smithery/cli install redis-mcp --client claude

Manual Setup

You can also set up the Redis MCP Server manually in your MCP client configuration (like Claude Desktop or Cline):

{
  "mcpServers": {
    "redis": {
      "command": "npx",
      "args": ["redis-mcp", "--redis-host", "localhost", "--redis-port", "6379"],
      "disabled": false
    }
  }
}

Configuration Options

The Redis MCP Server accepts the following command-line arguments:

  • --redis-host: Redis server host (default: localhost)
  • --redis-port: Redis server port (default: 6379)

Available Redis Operations

Hash Commands

Hash Commands

Tool Description Input Parameters
hmset Set multiple hash fields to multiple values key: string (Hash key)
fields: object (Field-value pairs to set)
hget Get the value of a hash field key: string (Hash key)
field: string (Field to get)
hgetall Get all fields and values in a hash key: string (Hash key)

Key Commands

Tool Description Input Parameters
scan Scan Redis keys matching a pattern pattern: string (Pattern to match, e.g., "user:*")
count: number, optional (Number of keys to return)
del Delete a key key: string (Key to delete)

String Commands

Tool Description Input Parameters
set Set string value with optional NX and PX options key: string (Key to set)
value: string (Value to set)
nx: boolean, optional (Only set if not exists)
px: number, optional (Expiry in milliseconds)
get Get string value key: string (Key to get)

Sorted Set Commands

Tool Description Input Parameters
zadd Add one or more members to a sorted set key: string (Sorted set key)
members: array of objects with score: number and value: string
zrange Return a range of members from a sorted set by index key: string (Sorted set key)
start: number (Start index)
stop: number (Stop index)
withScores: boolean, optional (Include scores in output)
zrangebyscore Return members from a sorted set with scores between min and max key: string (Sorted set key)
min: number (Minimum score)
max: number (Maximum score)
withScores: boolean, optional (Include scores in output)
zrem Remove one or more members from a sorted set key: string (Sorted set key)
members: array of strings (Members to remove)

Set Commands

Tool Description Input Parameters
sadd Add one or more members to a set key: string (Set key)
members: array of strings (Members to add to the set)
smembers Get all members in a set key: string (Set key)

Usage Examples

Setting and Getting a String Value

// Example: Setting a string value
{
  "tool": "set",
  "args": {
    "key": "greeting",
    "value": "Hello, World!",
    "px": 3600000  // expires in 1 hour
  }
}

// Example: Getting a string value
{
  "tool": "get",
  "args": {
    "key": "greeting"
  }
}

Working with Hashes

// Example: Setting multiple hash fields
{
  "tool": "hmset",
  "args": {
    "key": "user:1000",
    "fields": {
      "name": "John Doe",
      "email": "[email protected]",
      "age": "30"
    }
  }
}

// Example: Getting a specific hash field
{
  "tool": "hget",
  "args": {
    "key": "user:1000",
    "field": "name"
  }
}

// Example: Getting all hash fields and values
{
  "tool": "hgetall",
  "args": {
    "key": "user:1000"
  }
}

Working with Sorted Sets

// Example: Adding members to a sorted set
{
  "tool": "zadd",
  "args": {
    "key": "leaderboard",
    "members": [
      { "score": 100, "value": "player1" },
      { "score": 85, "value": "player2" },
      { "score": 95, "value": "player3" }
    ]
  }
}

// Example: Getting members by score range
{
  "tool": "zrangebyscore",
  "args": {
    "key": "leaderboard",
    "min": 90,
    "max": 100,
    "withScores": true
  }
}

Scanning Keys

// Example: Scanning for keys matching a pattern
{
  "tool": "scan",
  "args": {
    "pattern": "user:*",
    "count": 10
  }
}

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later