# Upstash Redis MCP

> Upstash Redis lets your AI agent treat a serverless key-value database like an extension of your workflow. You can manage data—reading values, setting expiration times, deleting old keys, and incrementing counters—all by talking to your agent via natural chat or IDE terminal.

## Overview
- **Category:** industry-titans
- **Price:** Free
- **Tags:** key-value-store, caching, serverless-database, data-persistence, database-administration, latency-optimization

## Description

Stop context switching just to check a cache value. This MCP securely connects your AI client directly to your Upstash Redis database. Instead of jumping into a separate GUI tool, you talk to your agent and ask it to perform data operations against your live store. Your agent gets the technical ability to act like a real database administrator, letting you scan active keys or read raw datastore strings right from your chat window.

Whether you need to inject new values with specific lifespans or safely track operational counters, this connection handles it all. Because Vinkius hosts this MCP, your agent gets immediate access to the full suite of Redis tools. You can ask it to check the Time-To-Live on a caching profile or audit key patterns without writing boilerplate code.

## Tools

### delete
Removes one or more specified keys entirely from the Redis store.

### get
Retrieves the current string value associated with a single key.

### increment
Adjusts a numeric counter at a specific key by increasing or decreasing its value.

### get_key_info
Provides details on the data type and remaining expiration time of a given key.

### list_keys
Scans for keys that match a specified pattern across your database.

### ping
Verifies that the Redis instance is online and responsive.

### set
Writes a string value to a key, allowing you to optionally set an expiration time in seconds.

## Prompt Examples

**Prompt:** 
```
List all active Redis keys associated with app sessions.
```

**Response:** 
```
I invoked the `list_keys` query with the pattern 'session:*'. Found 3 active keys residing in your environment.
```

**Prompt:** 
```
Check the Time-To-Live duration limit configured for the 'cache:product_header' key.
```

**Response:** 
```
I checked the key info via `get_key_info`. The 'cache:product_header' value is a standard String and currently holds a remaining Time-to-Live format of exactly 3600 seconds.
```

**Prompt:** 
```
Delete all caching strings tagged as 'user_193_avatar' from the database immediately.
```

**Response:** 
```
Using the `delete` tool, I have entirely removed the 'user_193_avatar' cache key structure from the Upstash datastore instance. Future calls seeking this key limit will return null entries until regenerated.
```

## Capabilities

### Retrieve stored data values
The MCP fetches the exact string configuration of any specified key.

### Inject and expire new keys
You can instruct the agent to write a new value, optionally setting how long it remains active before expiring automatically.

### Scan for specific data patterns
The MCP scans across your database using pattern matching to find relevant keys and inspect their structures or lifespans.

### Manage numeric counters
You can safely increase or decrease numerical keys, perfect for counting rate limits or tracking user sessions in real time.

### Check key metadata and TTL
The MCP retrieves the data type and remaining Time-to-Live duration configured for any given key.

## Use Cases

### Debugging a broken feature cache
A backend developer suspects cached product data is wrong. Instead of logging into RedisInsight, they ask their agent to run `get_key_info` on the key 'cache:product_header' to verify its type and check the remaining Time-to-Live before assuming it's expired.

### Implementing a simple rate limiter
A DevOps engineer needs to enforce a 10x per minute limit. They prompt their agent to use `increment` on a user key, checking that the count doesn't exceed 10 before allowing the request through.

### Auditing active sessions
A system architect needs to know which session tokens are still alive. They ask their agent to use `list_keys` with a pattern like 'session:*', immediately giving them visibility into all active users without manual scanning.

### Cleaning up expired data
A developer finishes a test run and needs to wipe out temporary mock parameters. They instruct their agent using the `delete` tool, specifying the exact key prefix they want removed from the database.

## Benefits

- Immediate debugging access: Instead of opening a specialized desktop database client, you can use the `get` tool to verify cache hits or check key status directly through your agent chat.
- Safe operational counting: Use the `increment` tool to track things like rate limits or user attempts without having to run manual counter scripts in an external terminal.
- Auditability: The `list_keys` tool lets you quickly scan for keys matching a pattern, helping you audit which sessions or resources are currently active in your system.
- Clean state management: Need to remove stale data? The `delete` tool allows you to clear specific cache fragments or outdated session states instantly when prompted.
- Time-to-Live control: You can set new values using the `set` tool and dictate exactly how long they must live, ensuring your system automatically cleans up temporary data.

## How It Works

The bottom line is that using natural language, you treat managing your key-value store like another conversation with your agent.

1. First, you authorize the Upstash Redis MCP component in your agent's extensions.
2. Next, you provide the necessary REST URL and REST Token connected to your database from the Upstash console.
3. Finally, you prompt your AI client naturally—for example, 'List all active keys matching session:*'—and your agent executes the required command.

## Frequently Asked Questions

**How do I check if the 'Upstash Redis' key is still active?**
Use `get_key_info` to check the status. This tool reports both the data type and the remaining Time-to-Live (TTL) for any specific key, letting you know exactly how long it will last.

**Can I use Upstash Redis MCP to count things?**
Yes, that's what `increment` is for. It safely increases or decreases a numeric counter at a specified key, making it perfect for tracking usage metrics or rate limits.

**What if I want to clear out old session keys using Upstash Redis MCP?**
You can run `list_keys` with the relevant pattern (e.g., 'session:*') to find them, and then use the `delete` tool to remove the entire set of keys you need gone.

**Does Upstash Redis MCP support setting expiration times?**
Yes, when using the `set` tool, you can include an optional Time-To-Live (TTL) value in seconds. This ensures temporary data automatically cleans itself up later.

**Is Upstash Redis MCP only for simple key lookups?**
No. While it handles basic key/value operations, you can also use `list_keys` to perform pattern-based scans across large sections of your database, making audits much easier.