# Upstash MCP for AI Agents AI Agent Connect

> Upstash lets you manage your serverless Redis database through your AI agent. You can run commands, organize data structures, and monitor your database health without ever opening a terminal or using the Redis CLI. It turns your agent into a data engineer for your cache.

## Overview
- **Category:** loved-by-devs
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_zagQBS4pH55ftq2YT6fVCqaAZsOFKu1bqXJWmxCc/ai-agent-connect
- **Tags:** redis, serverless, key-value-store, caching, data-structures, rest-api

## Description

Instead of jumping between your code editor and a terminal to run Redis commands, you can just tell your agent what to do. You'll be able to check if a session exists, update a feature flag, or clear out old cache keys just by asking. It handles the heavy lifting of interacting with the Upstash REST API so you can stay in your flow. If you're using the Vinkius catalog to set up your workspace, this is the way to make your serverless data store actually usable for your AI. You can manage complex data like sets and lists or push messages to channels without writing a single line of boilerplate code. It takes the friction out of managing your cache and lets you treat your data like a natural part of your conversation.

Whether you're trying to debug a production issue by looking for specific patterns or you're just trying to see what's inside a hash, you can do it all in one place. You don't have to worry about the nuances of the REST API or the specific syntax of different commands. You just describe the action you want to take, and the agent executes it. This is a huge win for anyone who needs to move fast. You can quickly verify that your rate limits are being hit, check the contents of a queue, or update a configuration value without ever leaving your chat window. It turns your database into a conversational tool that actually responds to your needs in real time.

## Tools

### decr
Decreases a numeric value in your Redis store. It initializes the key to 0 if it doesn't exist before subtracting.

### del
Removes a specific key from your database. Use this when you need to clear out data permanently.

### exists
Checks if a key is present in your store. It's a fast way to verify data without pulling the whole value.

### expire
Sets a time-to-live on a specific key. This ensures your data gets deleted automatically after a certain period.

### get
Retrieves the value of a string key. This is your main way to read data from the cache.

### hget
Grabs a specific field value from a Redis hash. It's perfect for looking up one piece of structured data.

### hgetall
Pulls every field and value from a hash key. Use this to see the full contents of a structured object.

### hset
Adds or updates a field within a Redis hash. It creates the hash automatically if it isn't already there.

### incr
Increases a numeric value by one. If the key is missing, it starts at 0 before adding.

### list_keys
Shows all keys in your database, optionally filtered by a pattern. Be careful with this on very large databases.

### llen
Tells you how many items are in a specific Redis list. It returns 0 if the list doesn't exist.

### lpush
Adds new values to the start of a Redis list. This is great for building stacks or queues.

### lrange
Pulls a specific range of elements from a list. You can get everything by using 0 as the start and -1 as the stop.

### pipeline
Sends a batch of commands in a single request. This is a powerful way to do multiple operations at once.

### publish
Sends a message to a specific channel for subscribers. This is a fire-and-forget way to handle events.

### rpush
Adds new values to the end of a Redis list. Use this for standard queue behavior.

### set
Saves a string value to a key. You can also include an expiry time to keep the data fresh.

### sismember
Checks if a specific member exists in a set. This is a very fast way to do membership lookups.

### smembers
Returns every unique member in a set. Use this to see everything inside a collection.

### srem
Removes specific members from a set. It ignores any members that aren't actually there.

### ttl
Shows how much time is left before a key expires. It returns -1 if there is no expiration set.

### key_type
Identifies the data type of a specific key. This helps you figure out if a key is a string, hash, list, or set.

### sadd
Adds unique members to a Redis set. It ignores any members that are already in the collection.

## Prompt Examples

**Prompt:** 
```
Is the 'user_session_99' key still active in my cache?
```

**Response:** 
```
I checked the cache for `user_session_99`. The key exists and has a remaining TTL of 3,600 seconds. It's active and will expire in about an hour.
```

**Prompt:** 
```
Update the 'maintenance_mode' flag to true for all users.
```

**Response:** 
```
I've updated the `maintenance_mode` key to `true`. I also set an expiration of 24 hours on it so it will reset automatically tomorrow.
```

**Prompt:** 
```
Show me what's in the 'pending_jobs' list.
```

**Response:** 
```
The `pending_jobs` list currently contains 4 items:
- Job_ID_102
- Job_ID_105
- Job_ID_110
- Job_ID_112
```

## Capabilities

### Check database health
Ping your database to see if it is active and responding to commands.

### Manage key-value pairs
Get, set, and delete string data with optional time-to-live settings.

### Organize structured data
Store and retrieve multiple field-value pairs within a single hash key.

### Handle queue patterns
Push and pop elements from Redis lists to manage stacks or queues.

### Manage unique collections
Add or remove members from sets to handle unique collections of data.

### Track counters
Increment or decrement numeric values atomically to keep track of totals.

### Send event messages
Publish messages to specific channels for event-driven workflows.

### Batch multiple commands
Execute a group of commands in a single request to speed up operations.

## Use Cases

### Checking Session Validity
A developer needs to see if a user's session is still active. They ask the agent to `get` the session key and `ttl` to see if it will expire soon.

### Updating Feature Flags
A product manager wants to flip a feature flag for a specific user. They tell the agent to `set` the flag key to true with a 1-hour `expire` time.

### Clearing Stuck Queues
A backend dev needs to clear out a stuck job queue. They ask the agent to `list_keys` to find the queue and then `del` the old entries.

### Tracking Hit Counters
An engineer needs to increment a hit counter every time a specific event triggers. They use `incr` to update the count automatically.

## Benefits

- Stop switching tabs by running Redis commands directly in your AI client using `set` and `get`.
- Manage your cache lifecycle easily by setting expiration times with `expire` and checking them with `ttl`.
- Handle complex data types like hashes and lists using `hset` and `lpush` without manual CLI commands.
- Monitor your database health instantly with `ping` and `key_type` to ensure your cache is running right.
- Execute batch operations quickly using `pipeline` to handle multiple updates in one go.
- Audit your data patterns by listing keys with `list_keys` to see exactly what's stored in your environment.

## How It Works

The bottom line is you get direct control over your Redis data without leaving your AI client.

1. Connect your Upstash REST URL and Token to the Connector.
2. Ask your agent to perform a task like 'list all keys starting with user:'.
3. Get the results back in your chat immediately.

## Frequently Asked Questions

**Can I use Upstash MCP to manage my production cache?**
Yes, you can manage production data, but be careful with commands like `list_keys` on large sets to avoid performance hits.

**Does the Upstash MCP work with my existing Redis keys?**
Yes, it connects to your existing Upstash Redis instance via your REST URL and Token.

**How do I set a feature flag using the Upstash MCP?**
Just tell your agent to set a key to a specific value and include an expiry time.

**Can I use this to clear my cache?**
Yes, you can use the `del` tool to remove specific keys or patterns.

**Is it safe to use this for session storage?**
Yes, it's a great way to get and set session strings while managing their TTLs automatically.

**Can the Upstash MCP handle complex data like hashes?**
Yes, it includes tools to get, set, and retrieve all fields from Redis hashes.

**What happens if I don't set a TTL?**
If you don't set one, the data stays in the cache until you manually delete it or it expires via a previous setting.

**Where do I find my Upstash REST URL and Token?**
Log in to the [**Upstash Console**](https://console.upstash.com), select your Redis database, and look for the **REST API** section. You'll find the HTTPS Endpoint (your REST URL, e.g. `https://xxx-yyy-12345.upstash.io`) and the **Token** value. Copy both and paste them here. There are two token types: Standard (full access) and Read-Only (read-only commands). Use Standard for full functionality.

**What Redis commands are supported via the REST API?**
The Upstash REST API supports most Redis commands including: Strings (GET, SET, DEL, EXISTS, EXPIRE, TTL, INCR, DECR), Hashes (HSET, HGET, HGETALL), Lists (LPUSH, RPUSH, LRANGE, LLEN), Sets (SADD, SMEMBERS, SISMEMBER, SREM), Keys (KEYS, TYPE, PING), and Pub/Sub (PUBLISH). The pipeline endpoint allows executing multiple commands in a single request. Blocking commands (BLPOP, BRPOP) and WATCH/UNWATCH are not supported.

**Can I execute multiple commands atomically?**
The `pipeline` tool sends multiple commands in a single HTTP request for efficiency, but it is NOT atomic — other commands may interleave between them. For atomic multi-command execution, Upstash supports the `/multi-exec` endpoint (same syntax as pipeline but guarantees atomicity). However, this Connector currently exposes the standard pipeline tool for batch operations.

**Is the Upstash REST API rate-limited?**
Upstash does not enforce a fixed RPS limit. Instead, your plan defines a daily command limit. Each REST call counts as one command (or multiple commands if using pipeline). If you exceed your daily limit, commands will fail with a 400 error. Check your Upstash console for current usage. For high-throughput scenarios, consider using the pipeline endpoint to batch multiple commands into single HTTP requests.