Run the Redis MCP Server and Connect via Meshagent

To get started, you’ll need to install the Meshagent CLI, sign up and authenticate, then run both the service (agent) and a chatbot that can access the Redis toolkit inside a specific Meshagent Room.

1. Required Environment Variables

Set the following environment variables to configure your Redis MCP instance:

  • REDIS_HOST — (Default: 127.0.0.1) The Redis server hostname or IP.
  • REDIS_PORT — (Default: 6379) The Redis server port.
  • REDIS_USERNAME — (Default: default) Redis username.
  • REDIS_SSL — (Default: False) Use SSL/TLS (True/False).
  • REDIS_CA_PATH — Path to the CA certificate file (if SSL is enabled).
  • REDIS_SSL_KEYFILE — Path to the client SSL key.
  • REDIS_SSL_CERTFILE — Path to the client SSL certificate.
  • REDIS_CERT_REQS — (Default: required) SSL certificate verification requirements.
  • REDIS_CA_CERTS — Path to trusted CA certificates.
  • REDIS_CLUSTER_MODE — (Default: False) Enable Redis Cluster Mode.
  • REDIS_PWD — Redis password (if required).

2. Setup and Launch

  1. Install Meshagent:

    pip install "meshagent[all]"
    
  2. Sign Up & Authenticate:
    Follow instructions at Meshagent CLI Getting Started

  3. Start MCP Redis Server as an Agent in a Room:

    meshagent service test \
      --room=test \
      --role=agent \
      --image=meshagent/mcp-redis:latest \
      --env MESHAGENT_PORT=8001 \
      --env REDIS_HOST=<host> \
      --env REDIS_PORT=<port> \
      --env REDIS_USERNAME=<username> \
      --env REDIS_PWD=<password> \
      --port="num=8001 path=/webhook liveness=/ type=meshagent.callable" \
      --name=mcp-redis-service
    
    • Replace <host>, <port>, <username>, <password> as needed.
    • This will start a Meshagent Room called “test” with an MCP Redis server made accessible in the room; rooms close automatically if inactive.
  4. Start a Chatbot (Tool User) in the Same Room:

    meshagent chatbot join \
      --room=test \
      --agent-name=sample \
      --name=sample \
      --toolkit=mcp-redis
    
    • This launches a chatbot in the room which can interact with the Redis toolkit.
    • Multiple toolkits can be used by a single agent within a room.
    • A web link to the interactive Meshagent Room will be printed after this command for direct browser access.

Tools Available

The MCP Redis server offers a comprehensive set of tools for managing and exploring Redis databases. Below are summaries and detailed parameter descriptions for each tool available via this server.

Tools Summary

Tools provided by this ServerShort Description
client_listGet a list of connected clients to the Redis server.
create_vector_index_hashCreate a Redis 8 vector similarity index using HNSW on a Redis hash.
dbsizeGet the number of keys stored in the Redis database
deleteDelete a Redis key.
expireSet an expiration time for a Redis key.
getGet a Redis string value.
get_index_infoRetrieve schema and information about a specific Redis index using FT.INFO.
get_indexed_keys_numberRetrieve the number of indexed keys by the index
get_indexesList of indexes in the Redis database
get_vector_from_hashRetrieve a vector from a Redis hash and convert it back from binary blob.
hdelDelete a field from a Redis hash.
hexistsCheck if a field exists in a Redis hash.
hgetGet the value of a field in a Redis hash.
hgetallGet all fields and values from a Redis hash.
hsetSet a field in a hash stored at key with an optional expiration time.
infoGet Redis server information and statistics.
json_delDelete a JSON value from Redis at a given path.
json_getRetrieve a JSON value from Redis at a given path.
json_setSet a JSON value in Redis at a given path with an optional expiration time.
llenGet the length of a Redis list.
lpopRemove and return the first element from a Redis list.
lpushPush a value onto the left of a Redis list and optionally set an expiration time.
lrangeGet elements from a Redis list within a specific range.
publishPublish a message to a Redis channel.
renameRenames a Redis key from old_key to new_key.
rpopRemove and return the last element from a Redis list.
rpushPush a value onto the right of a Redis list and optionally set an expiration time.
saddAdd a value to a Redis set with an optional expiration time.
setSet a Redis string value with an optional expiration time.
set_vector_in_hashStore a vector as a field in a Redis hash.
smembersGet all members of a Redis set.
sremRemove a value from a Redis set.
subscribeSubscribe to a Redis channel.
typeReturns the string representation of the type of the value stored at key
unsubscribeUnsubscribe from a Redis channel.
vector_search_hashPerform a KNN vector similarity search using Redis 8 or later version on vectors stored in hash data structures.
xaddAdd an entry to a Redis stream with an optional expiration time.
xdelDelete an entry from a Redis stream.
xrangeRead entries from a Redis stream.
zaddAdd a member to a Redis sorted set with an optional expiration time.
zrangeRetrieve a range of members from a Redis sorted set.
zremRemove a member from a Redis sorted set.

Tools Details

client_list

Get a list of connected clients to the Redis server.

create_vector_index_hash

Create a Redis 8 vector similarity index using HNSW on a Redis hash.

Parameters:

  • dim (integer, optional): The dimensionality of the vectors stored under the vector_field.
  • distance_metric (string, optional): The distance function to use (e.g., ‘COSINE’, ‘L2’, ‘IP’).
  • index_name (string, optional): The name of the Redis index to create.
  • prefix (string, optional): The key prefix used to identify documents to index (e.g., ‘doc:’).
  • vector_field (string, optional): The name of the vector field to be indexed.

dbsize

Get the number of keys stored in the Redis database.

delete

Delete a Redis key.

Parameters:

  • key (string)

expire

Set an expiration time for a Redis key.

Parameters:

  • expire_seconds (integer): Time in seconds after which the key should expire.
  • name (string): The Redis key.

get

Get a Redis string value.

Parameters:

  • key (string)

get_index_info

Retrieve schema and information about a specific Redis index using FT.INFO.

Parameters:

  • index_name (string)

get_indexed_keys_number

Retrieve the number of indexed keys by the index.

Parameters:

  • index_name (string)

get_indexes

List of indexes in the Redis database.


get_vector_from_hash

Retrieve a vector from a Redis hash and convert it back from binary blob.

Parameters:

  • name (string): The Redis hash key.
  • vector_field (string, optional): The field name inside the hash.

hdel

Delete a field from a Redis hash.

Parameters:

  • key (string): The field name inside the hash.
  • name (string): The Redis hash key.

hexists

Check if a field exists in a Redis hash.

Parameters:

  • key (string): The field name inside the hash.
  • name (string): The Redis hash key.

hget

Get the value of a field in a Redis hash.

Parameters:

  • key (string): The field name inside the hash.
  • name (string): The Redis hash key.

hgetall

Get all fields and values from a Redis hash.

Parameters:

  • name (string): The Redis hash key.

hset

Set a field in a hash stored at key with an optional expiration time.

Parameters:

  • key (string): The field name inside the hash.
  • name (string): The Redis hash key.
  • value (string): The value to set.
  • expire_seconds (integer, optional): Time in seconds after which the key should expire.

info

Get Redis server information and statistics.

Parameters:

  • section (string, optional): The section of the info command (default, memory, cpu, etc.).

json_del

Delete a JSON value from Redis at a given path.

Parameters:

  • name (string): The Redis key where the JSON document is stored.
  • path (string, optional): The JSON path to delete (default: root ’$’).

json_get

Retrieve a JSON value from Redis at a given path.

Parameters:

  • name (string): The Redis key where the JSON document is stored.
  • path (string, optional): The JSON path to retrieve (default: root ’$’).

json_set

Set a JSON value in Redis at a given path with an optional expiration time.

Parameters:

  • name (string): The Redis key where the JSON document is stored.
  • path (string): The JSON path where the value should be set.
  • value (string): The JSON value to store.
  • expire_seconds (integer, optional): Time in seconds after which the key should expire.

llen

Get the length of a Redis list.

Parameters:

  • name (string)

lpop

Remove and return the first element from a Redis list.

Parameters:

  • name (string)

lpush

Push a value onto the left of a Redis list and optionally set an expiration time.

Parameters:

  • name (string)
  • value (string)
  • expire (integer, optional)

lrange

Get elements from a Redis list within a specific range.

Parameters:

  • name (string)
  • start (integer)
  • stop (integer)

publish

Publish a message to a Redis channel.

Parameters:

  • channel (string): The Redis channel to publish to.
  • message (string): The message to send.

rename

Renames a Redis key from old_key to new_key.

Parameters:

  • new_key (string)
  • old_key (string)

rpop

Remove and return the last element from a Redis list.

Parameters:

  • name (string)

rpush

Push a value onto the right of a Redis list and optionally set an expiration time.

Parameters:

  • name (string)
  • value (string)
  • expire (integer, optional)

sadd

Add a value to a Redis set with an optional expiration time.

Parameters:

  • name (string): The Redis set key.
  • value (string): The value to add to the set.
  • expire_seconds (integer, optional): Time in seconds after which the set should expire.

set

Set a Redis string value with an optional expiration time.

Parameters:

  • key (string)
  • value (string)
  • expiration (integer, optional)

set_vector_in_hash

Store a vector as a field in a Redis hash.

Parameters:

  • name (string): The Redis hash key.
  • vector (array): The vector (list of numbers) to store in the hash.
  • vector_field (string, optional): The field name inside the hash.

smembers

Get all members of a Redis set.

Parameters:

  • name (string): The Redis set key.

srem

Remove a value from a Redis set.

Parameters:

  • name (string): The Redis set key.
  • value (string): The value to remove from the set.

subscribe

Subscribe to a Redis channel.

Parameters:

  • channel (string): The Redis channel to subscribe to.

type

Returns the string representation of the type of the value stored at key

Parameters:

  • key (string)

unsubscribe

Unsubscribe from a Redis channel.

Parameters:

  • channel (string): The Redis channel to unsubscribe from.

vector_search_hash

Perform a KNN vector similarity search using Redis 8 or later version on vectors stored in hash data structures.

Parameters:

  • query_vector (array): List of floats (query).
  • index_name (string, optional): Name of the Redis index.
  • k (integer, optional): Number of nearest neighbors to return.
  • return_fields (array, optional): List of fields to return.
  • vector_field (string, optional): Name of the indexed vector field.

xadd

Add an entry to a Redis stream with an optional expiration time.

Parameters:

  • fields (object)
  • key (string)
  • expiration (integer, optional)

xdel

Delete an entry from a Redis stream.

Parameters:

  • entry_id (string)
  • key (string)

xrange

Read entries from a Redis stream.

Parameters:

  • key (string)
  • count (integer, optional)

zadd

Add a member to a Redis sorted set with an optional expiration time.

Parameters:

  • key (string)
  • member (string)
  • score (number)
  • expiration (integer, optional)

zrange

Retrieve a range of members from a Redis sorted set.

Parameters:

  • end (integer)
  • key (string)
  • start (integer)
  • with_scores (boolean, optional)

zrem

Remove a member from a Redis sorted set.

Parameters:

  • key (string)
  • member (string)

Meshagent Resources