The Upstash Redis connector lets your AI agent act in each user's Upstash Redis account. Each user connects their own Upstash Redis access token once, and Scalekit sends it with every call, so your agent never handles credentials. It comes with 28 tools.
- Tools
- 28
- What they doRead · write · destructive
- 13 · 5 · 1013 read5 write10 destructive
- Users sign in with
- Access token
Setup
Install the SDK
Terminal window npm install @scalekit-sdk/node dotenvTerminal window pip install scalekit-sdk-python python-dotenvSet your credentials
Add your Scalekit credentials to your
.envfile. Find values in app.scalekit.com > Developers > API Credentials..env SCALEKIT_ENVIRONMENT_URL=<your-environment-url>SCALEKIT_CLIENT_ID=<your-client-id>SCALEKIT_CLIENT_SECRET=<your-client-secret>Create the Upstash Redis connection
In AgentKit > Connections, create an Upstash Redis connection. The name you give it is the
connection_nameyour code passes. See Configure connections.Authorize a user and make your first call
quickstart.mts import { ScalekitClient } from '@scalekit-sdk/node'import 'dotenv/config'import { createInterface } from 'node:readline/promises'const scalekit = new ScalekitClient(process.env.SCALEKIT_ENVIRONMENT_URL,process.env.SCALEKIT_CLIENT_ID,process.env.SCALEKIT_CLIENT_SECRET,)const actions = scalekit.actionsconst connector = 'upstashredis'const identifier = 'user_123'// Generate an authorization link for the userconst { link } = await actions.getAuthorizationLink({ connectionName: connector, identifier })console.log('Authorize Upstash Redis:', link)const rl = createInterface({ input: process.stdin, output: process.stdout })await rl.question('Press Enter after authorizing...')rl.close()// Make your first callconst result = await actions.executeTool({connector,identifier,toolName: 'upstashredis_database_size_get',toolInput: {},})console.log(result)Terminal window npx tsx quickstart.mtsquickstart.py import osfrom scalekit import ScalekitClientfrom dotenv import load_dotenvload_dotenv()scalekit_client = ScalekitClient(env_url=os.getenv("SCALEKIT_ENVIRONMENT_URL"),client_id=os.getenv("SCALEKIT_CLIENT_ID"),client_secret=os.getenv("SCALEKIT_CLIENT_SECRET"),)actions = scalekit_client.actionsconnection_name = "upstashredis"identifier = "user_123"# Generate an authorization link for the userlink_response = actions.get_authorization_link(connection_name=connection_name,identifier=identifier,)print("Authorize Upstash Redis:", link_response.link)input("Press Enter after authorizing...")# Make your first callresult = actions.execute_tool(tool_input={},tool_name="upstashredis_database_size_get",connection_name=connection_name,identifier=identifier,)print(result)Terminal window python quickstart.pyEach user opens the link once and enters their Upstash Redis credentials there. See Authorize a user for the full flow and statuses.
Tools
Pass the exact name toexecute_toolupstashredis_database_size_getGet the number of keys in the database (Redis DBSIZE).Read-onlyGet Database Size
Get the number of keys in the database (Redis DBSIZE). Returns {"result": <count>} as an integer. Use this for a quick key count or to check the connection works. Use upstashredis_key_scan to list key names.
Inputs
This tool takes no inputs.
upstashredis_hash_field_getGet the value of one field in a hash (Redis HGET).Read-onlyGet Hash Field
Get the value of one field in a hash (Redis HGET). Returns {"result": "<value>"}, or {"result": null} when the field or key does not exist. Use this for a single field. Use upstashredis_hash_get_all to read every field of the hash.
Inputs
fieldstringrequired- The field name within the hash. Example: email.
keystringrequired- The Redis hash key name. Any characters are allowed, including slashes and colons. Example: user:42.
upstashredis_hash_get_allGet every field and value in a hash (Redis HGETALL).Read-onlyGet All Hash Fields
Get every field and value in a hash (Redis HGETALL). Returns {"result": ["field1", "value1", "field2", "value2", ...]} as a flat list, or an empty list when the key does not exist. Use this to read a whole hash. Use upstashredis_hash_field_get for one field of a large hash.
Inputs
keystringrequired- The Redis hash key name. Any characters are allowed, including slashes and colons. Example: user:42.
upstashredis_key_existsCheck whether one or more keys exist (Redis EXISTS).Read-onlyCheck Keys Exist
Check whether one or more keys exist (Redis EXISTS). Returns {"result": <count>} with how many of the given keys exist; a key listed twice counts twice. Use this to test for keys without reading values. Use upstashredis_key_type_get to learn a key's data type.
Inputs
keysarrayrequired- One or more Redis key names, as a JSON array of strings. Example: ["user:42", "user:43"].
upstashredis_key_scanIterate over key names in the database a page at a time, optionally filtered by a glob pattern and type (Redis SCAN).Read-onlyScan Keys
Iterate over key names in the database a page at a time, optionally filtered by a glob pattern and type (Redis SCAN). Returns {"result": ["<next cursor>", ["key", ...]]}; a next cursor of "0" means the scan is complete. A page can be empty even when more keys remain. Use this to discover keys. Start with cursor 0 and pass back the returned cursor until it is "0". Use upstashredis_database_size_get for a count only. Works with either the standard or the read-only REST token.
Inputs
countinteger- Optional hint for how many keys to examine per call. Redis may return more or fewer. Example: 100.
cursorstring- The cursor from the previous call. Use "0" to start a new scan. Example: 0.
matchstring- Optional glob pattern to filter key names, using * ? and [] wildcards. Example: user:*.
typestring- Optional data type filter: string, list, set, zset, hash or stream.one of
stringlistsetzsethashstream
upstashredis_key_ttl_getGet the remaining time to live of a key in seconds (Redis TTL).Read-onlyGet Key TTL
Get the remaining time to live of a key in seconds (Redis TTL). Returns {"result": <seconds>}; -1 means the key has no expiry and -2 means the key does not exist. Use this to check when a key expires. Use upstashredis_key_expire to change it.
Inputs
keystringrequired- The Redis key name. Any characters are allowed, including slashes and colons. Example: user:42.
upstashredis_key_type_getGet the data type stored at a key (Redis TYPE).Read-onlyGet Key Type
Get the data type stored at a key (Redis TYPE). Returns {"result": "string" | "list" | "set" | "zset" | "hash" | "stream" | "none"}. Use this before reading a key to pick the right tool, for example upstashredis_hash_get_all for a hash.
Inputs
keystringrequired- The Redis key name. Any characters are allowed, including slashes and colons. Example: user:42.
upstashredis_list_range_getGet a range of elements from a list by index, without removing them (Redis LRANGE).Read-onlyGet List Range
Get a range of elements from a list by index, without removing them (Redis LRANGE). Returns {"result": ["element", ...]}; an empty list when the key does not exist or the range is out of bounds. Use this to read a list. Use start 0 and stop -1 for the whole list. Use upstashredis_list_pop_left to read and remove.
Inputs
keystringrequired- The Redis list key name. Any characters are allowed, including slashes and colons. Example: user:42.
startinteger- Zero-based start index, inclusive. Negative values count from the end. Defaults to 0. Example: 0.
stopinteger- Zero-based stop index, inclusive. -1 means the last element. Defaults to -1. Example: 9.
upstashredis_set_members_listGet every member of a set (Redis SMEMBERS).Read-onlyList Set Members
Get every member of a set (Redis SMEMBERS). Returns {"result": ["member", ...]} in no particular order, or an empty list when the key does not exist. Use this to read a whole set. Use upstashredis_sorted_set_range_get for sorted sets.
Inputs
keystringrequired- The Redis set key name. Any characters are allowed, including slashes and colons. Example: user:42.
upstashredis_sorted_set_range_getGet members of a sorted set by index rank or by score range, optionally reversed and with scores (Redis ZRANGE).Read-onlyGet Sorted Set Range
Get members of a sorted set by index rank or by score range, optionally reversed and with scores (Redis ZRANGE). Returns {"result": ["member", ...]}, or ["member", "score", ...] alternating when with_scores is true. Use this to read leaderboards or score ranges. Use start 0 and stop -1 for every member by rank.
Inputs
keystringrequired- The Redis sorted set key name. Any characters are allowed, including slashes and colons. Example: user:42.
startstringrequired- Range start. By rank: a zero-based index such as 0. By score: a score such as 10, (10 for exclusive, or -inf. Example: 0.
stopstringrequired- Range end, inclusive. By rank: an index such as -1 for the last member. By score: a score such as 100, (100 for exclusive, or +inf. Example: -1.
by_scoreboolean- If true (BYSCORE), start and stop are scores instead of indexes.
limit_countinteger- Optional maximum number of members to return; only valid with by_score. Example: 10.
offsetinteger- Optional number of members to skip; only valid with by_score. Requires limit_count. Example: 0.
reverseboolean- If true (REV), return members from highest to lowest score. With by_score, give start as the higher score.
with_scoresboolean- If true (WITHSCORES), include each member's score after it in the result.
upstashredis_stream_range_getGet stream entries between two IDs in ascending order (Redis XRANGE).Read-onlyGet Stream Range
Get stream entries between two IDs in ascending order (Redis XRANGE). Returns {"result": [["<id>", ["field", "value", ...]], ...]}. Use this to read a stream. Use - and + for the whole stream, and count to page; pass (<last id> as start to continue after an entry.
Inputs
keystringrequired- The Redis stream key name. Any characters are allowed, including slashes and colons. Example: user:42.
countinteger- Optional maximum number of entries to return. Example: 100.
endstring- End entry ID, inclusive. Use + for the last entry. Defaults to +. Example: +.
startstring- Start entry ID, inclusive. Use - for the first entry, or (<id> to exclude that ID. Defaults to -. Example: 1700000000000-0.
upstashredis_string_getGet the string value stored at a key (Redis GET).Read-onlyGet String Value
Get the string value stored at a key (Redis GET). Returns {"result": "<value>"}, or {"result": null} when the key does not exist. Use this for one key. Use upstashredis_string_get_many to read several keys in one call, and upstashredis_hash_get_all for hash keys.
Inputs
keystringrequired- The Redis key name. Any characters are allowed, including slashes and colons. Example: user:42.
upstashredis_string_get_manyGet the string values of several keys in one call (Redis MGET).Read-onlyGet Multiple String Values
Get the string values of several keys in one call (Redis MGET). Returns {"result": [...]} with one value per key, in the order given, and null for keys that are missing or not strings. Use this to read several keys at once. Use upstashredis_string_get for a single key.
Inputs
keysarrayrequired- One or more Redis key names, as a JSON array of strings. Example: ["user:42", "user:43"].
upstashredis_counter_incrementIncrement the integer value of a key by a given amount, creating it at 0 first if missing (Redis INCRBY).WriteIncrement Counter
Increment the integer value of a key by a given amount, creating it at 0 first if missing (Redis INCRBY). Returns {"result": <new value>} as an integer. Use this for counters and rate tracking. Use a negative increment to decrement. Use upstashredis_string_set to set an exact value. Needs the standard (read-write) REST token; a read-only token gets a 403 NOPERM error, and the connection stays active.
Inputs
keystringrequired- The Redis key name. Any characters are allowed, including slashes and colons. Example: user:42.
incrementinteger- The amount to add. Defaults to 1. Use a negative number to decrement. Example: 5.
upstashredis_list_push_leftInsert one or more elements at the head (left) of a list, creating the list if needed (Redis LPUSH).WritePush to List Head
Insert one or more elements at the head (left) of a list, creating the list if needed (Redis LPUSH). Returns {"result": <length>} with the list length after the push. Elements are inserted one after another, so the last one given ends up first. Use this for stack-style or newest-first lists. Use upstashredis_list_push_right to append to the tail. Needs the standard (read-write) REST token; a read-only token gets a 403 NOPERM error, and the connection stays active.
Inputs
elementsarrayrequired- The elements to add, as a JSON array. Non-string values are stored as their JSON text. Example: ["job-1", "job-2"].
keystringrequired- The Redis list key name. Any characters are allowed, including slashes and colons. Example: user:42.
upstashredis_list_push_rightAppend one or more elements to the tail (right) of a list, creating the list if needed (Redis RPUSH).WritePush to List Tail
Append one or more elements to the tail (right) of a list, creating the list if needed (Redis RPUSH). Returns {"result": <length>} with the list length after the push. Use this for queues and logs in arrival order. Use upstashredis_list_push_left to insert at the head. Needs the standard (read-write) REST token; a read-only token gets a 403 NOPERM error, and the connection stays active.
Inputs
elementsarrayrequired- The elements to add, as a JSON array. Non-string values are stored as their JSON text. Example: ["job-1", "job-2"].
keystringrequired- The Redis list key name. Any characters are allowed, including slashes and colons. Example: user:42.
upstashredis_set_members_addAdd one or more members to a set, creating the set if needed; members already present are ignored (Redis SADD).WriteAdd Set Members
Add one or more members to a set, creating the set if needed; members already present are ignored (Redis SADD). Returns {"result": <count>} with the number of members newly added. Use this to add unique values. Use upstashredis_sorted_set_members_add when members need a score or order. Needs the standard (read-write) REST token; a read-only token gets a 403 NOPERM error, and the connection stays active.
- Idempotent
Inputs
keystringrequired- The Redis set key name. Any characters are allowed, including slashes and colons. Example: user:42.
membersarrayrequired- The members to add, as a JSON array of strings. Example: ["red", "blue"].
upstashredis_sorted_set_members_addAdd members with scores to a sorted set, or update the scores of existing members (Redis ZADD).WriteAdd Sorted Set Members
Add members with scores to a sorted set, or update the scores of existing members (Redis ZADD). Returns {"result": <count>} with the number of members added (or added plus changed when changed is true). Use this for leaderboards and priority queues. Use upstashredis_set_members_add for plain sets without scores. Needs the standard (read-write) REST token; a read-only token gets a 403 NOPERM error, and the connection stays active.
- Idempotent
Inputs
keystringrequired- The Redis sorted set key name. Any characters are allowed, including slashes and colons. Example: user:42.
membersarrayrequired- The members to add, as a JSON array of objects, each with a numeric score and a member string. Example: [{"score": 100, "member": "ada"}, {"score": 85.5, "member": "bob"}].
changedboolean- If true (CH), the returned count includes members whose score changed, not just new members.
comparisonstring- Optional. GT only updates a score when the new one is greater; LT only when it is less. Cannot be combined with condition NX.one of
GTLT conditionstring- Optional. NX only adds new members and never updates scores; XX only updates existing members and never adds.one of
NXXX
upstashredis_hash_fields_deletePermanently remove one or more fields from a hash (Redis HDEL).DestructiveDelete Hash Fields
Permanently remove one or more fields from a hash (Redis HDEL). Returns {"result": <count>} with the number of fields removed. Use this to remove fields inside a hash. Use upstashredis_key_delete to delete the whole hash. Needs the standard (read-write) REST token; a read-only token gets a 403 NOPERM error, and the connection stays active.
- Idempotent
Inputs
fieldsarrayrequired- The field names to remove, as a JSON array of strings. Example: ["email", "phone"].
keystringrequired- The Redis hash key name. Any characters are allowed, including slashes and colons. Example: user:42.
upstashredis_hash_fields_setSet one or more fields in a hash, creating the hash if needed and overwriting existing field values (Redis HSET).DestructiveSet Hash Fields
Set one or more fields in a hash, creating the hash if needed and overwriting existing field values (Redis HSET). Returns {"result": <count>} with the number of fields that were newly added (updated fields are not counted). Use this to write hash fields. Use upstashredis_hash_fields_delete to remove fields. Needs the standard (read-write) REST token; a read-only token gets a 403 NOPERM error, and the connection stays active.
- Idempotent
Inputs
fieldsobjectrequired- The fields and values to set, as a JSON object mapping field name to value. Non-string values are stored as their JSON text. Example: {"name": "Ada", "email": "ada@example.com"}.
keystringrequired- The Redis hash key name. Any characters are allowed, including slashes and colons. Example: user:42.
upstashredis_key_deletePermanently delete one or more keys of any type (Redis DEL).DestructiveDelete Keys
Permanently delete one or more keys of any type (Redis DEL). Returns {"result": <count>} with the number of keys that existed and were removed. Use this to remove whole keys. Use upstashredis_hash_fields_delete, upstashredis_set_members_remove or upstashredis_sorted_set_members_remove to remove items inside a key. Needs the standard (read-write) REST token; a read-only token gets a 403 NOPERM error, and the connection stays active.
- Idempotent
Inputs
keysarrayrequired- One or more Redis key names, as a JSON array of strings. Example: ["user:42", "user:43"].
upstashredis_key_expireSet a time to live in seconds on a key, after which Redis deletes it (Redis EXPIRE).DestructiveSet Key Expiry
Set a time to live in seconds on a key, after which Redis deletes it (Redis EXPIRE). Returns {"result": 1} when the expiry was set, or {"result": 0} when the key does not exist or the condition stopped it. Use this to schedule a key's removal. Use upstashredis_key_ttl_get to read the remaining time, and upstashredis_string_set with ex to write a value and expiry together. Needs the standard (read-write) REST token; a read-only token gets a 403 NOPERM error, and the connection stays active.
- Idempotent
Inputs
keystringrequired- The Redis key name. Any characters are allowed, including slashes and colons. Example: user:42.
secondsintegerrequired- Time to live in seconds. A value of 0 or less deletes the key immediately. Example: 3600.
conditionstring- Optional condition. NX sets only if the key has no expiry; XX only if it has one; GT only if the new expiry is later; LT only if it is sooner.one of
NXXXGTLT
upstashredis_list_pop_leftRemove and return elements from the head (left) of a list (Redis LPOP).DestructivePop from List Head
Remove and return elements from the head (left) of a list (Redis LPOP). Returns {"result": "<element>"} without count, {"result": ["element", ...]} with count, or {"result": null} when the list is empty or missing. Use this to consume a queue. Use upstashredis_list_range_get to read without removing. Needs the standard (read-write) REST token; a read-only token gets a 403 NOPERM error, and the connection stays active.
Inputs
keystringrequired- The Redis list key name. Any characters are allowed, including slashes and colons. Example: user:42.
countinteger- Optional number of elements to pop. Without it, one element is returned as a plain value. Example: 5.
upstashredis_set_members_removePermanently remove one or more members from a set (Redis SREM).DestructiveRemove Set Members
Permanently remove one or more members from a set (Redis SREM). Returns {"result": <count>} with the number of members removed. Use this to remove values from a set. Use upstashredis_key_delete to delete the whole set. Needs the standard (read-write) REST token; a read-only token gets a 403 NOPERM error, and the connection stays active.
- Idempotent
Inputs
keystringrequired- The Redis set key name. Any characters are allowed, including slashes and colons. Example: user:42.
membersarrayrequired- The members to remove, as a JSON array of strings. Example: ["red", "blue"].
upstashredis_sorted_set_members_removePermanently remove one or more members from a sorted set (Redis ZREM).DestructiveRemove Sorted Set Members
Permanently remove one or more members from a sorted set (Redis ZREM). Returns {"result": <count>} with the number of members removed. Use this to remove entries from a leaderboard or queue. Use upstashredis_key_delete to delete the whole sorted set. Needs the standard (read-write) REST token; a read-only token gets a 403 NOPERM error, and the connection stays active.
- Idempotent
Inputs
keystringrequired- The Redis sorted set key name. Any characters are allowed, including slashes and colons. Example: user:42.
membersarrayrequired- The members to remove, as a JSON array of strings. Example: ["red", "blue"].
upstashredis_stream_entry_addAppend an entry of field-value pairs to a stream, creating the stream if needed, with optional trimming (Redis XADD).DestructiveAdd Stream Entry
Append an entry of field-value pairs to a stream, creating the stream if needed, with optional trimming (Redis XADD). Returns {"result": "<entry id>"} such as "1700000000000-0", or {"result": null} when no_create is true and the stream does not exist. Fields are stored in alphabetical order of field name, not the order given. Use this to log events. Use upstashredis_stream_range_get to read entries back. Setting max_length permanently trims the oldest entries. Needs the standard (read-write) REST token; a read-only token gets a 403 NOPERM error, and the connection stays active.
Inputs
fieldsobjectrequired- The entry's fields and values, as a JSON object mapping field name to value. Example: {"event": "signup", "user": "42"}.
keystringrequired- The Redis stream key name. Any characters are allowed, including slashes and colons. Example: user:42.
approximateboolean- If true, trim with ~ (approximately max_length, more efficient). Only used with max_length.
idstring- Optional explicit entry ID in <milliseconds>-<sequence> form. Defaults to * so Redis generates one. Example: *.
max_lengthinteger- Optional cap on the stream length (MAXLEN). Older entries beyond it are permanently deleted. Example: 1000.
no_createboolean- If true (NOMKSTREAM), do not create the stream when it does not exist.
upstashredis_string_setSet a key to a string value, replacing any existing value and type (Redis SET), with optional expiry and NX/XX condition.DestructiveSet String Value
Set a key to a string value, replacing any existing value and type (Redis SET), with optional expiry and NX/XX condition. Returns {"result": "OK"}, or {"result": null} when an NX/XX condition stopped the write. Use this to write one key. Use upstashredis_string_set_many for several keys, and upstashredis_key_expire to change only the expiry. Needs the standard (read-write) REST token; a read-only token gets a 403 NOPERM error, and the connection stays active.
- Idempotent
Inputs
keystringrequired- The Redis key name. Any characters are allowed, including slashes and colons. Example: user:42.
valuestringrequired- The value to store, as a string. Slashes and special characters are sent safely in the JSON body. Example: {"plan":"pro"} or hello world.
conditionstring- Optional write condition. NX writes only if the key does not exist; XX writes only if it already exists.one of
NXXX exinteger- Optional time to live in seconds (EX). Do not combine with px or keep_ttl. Example: 60.
keep_ttlboolean- If true, keep the key's existing time to live (KEEPTTL) instead of clearing it. Do not combine with ex or px.
pxinteger- Optional time to live in milliseconds (PX). Do not combine with ex or keep_ttl. Example: 1500.
upstashredis_string_set_manySet several keys to string values in one atomic call (Redis MSET), replacing existing values.DestructiveSet Multiple String Values
Set several keys to string values in one atomic call (Redis MSET), replacing existing values. Returns {"result": "OK"}. Use this to write several keys at once with no expiry. Use upstashredis_string_set for one key or to set an expiry or NX/XX condition. Needs the standard (read-write) REST token; a read-only token gets a 403 NOPERM error, and the connection stays active.
- Idempotent
Inputs
entriesobjectrequired- The keys and values to set, as a JSON object mapping each key name to its value. Non-string values are stored as their JSON text. Example: {"user:42:name": "Ada", "user:42:plan": "pro"}.
No tools match.