Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Connect AI agents to Upstash Redis

Scalekit connector
Open markdown

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

Setup

  1. Install the SDK

    Terminal window
    npm install @scalekit-sdk/node dotenv
  2. Set your credentials

    Add your Scalekit credentials to your .env file. 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>
  3. Create the Upstash Redis connection

    In AgentKit > Connections, create an Upstash Redis connection. The name you give it is the connection_name your code passes. See Configure connections.

  4. 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.actions
    const connector = 'upstashredis'
    const identifier = 'user_123'
    // Generate an authorization link for the user
    const { 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 call
    const result = await actions.executeTool({
    connector,
    identifier,
    toolName: 'upstashredis_database_size_get',
    toolInput: {},
    })
    console.log(result)
    Terminal window
    npx tsx quickstart.mts

    Each 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 to execute_tool
Try in PlaygroundRequest a tool
  • upstashredis_database_size_getGet the number of keys in the database (Redis DBSIZE).Read-only

    Get 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-only

    Get 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-only

    Get 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-only

    Check 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-only

    Scan 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-only

    Get 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-only

    Get 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-only

    Get 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.