Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

AgentKit: Connect my agent to apps

Build a working agent that makes authenticated tool calls on behalf of users, using Gmail as the example connector.

Architecture diagram: an AI agent connects through Scalekit MCP Gateway with delegated auth, scoped permissions, and tool calls to SaaS apps such as Gmail, Slack, and Salesforce.

By the end of this guide, you’ll have a working agent that fetches a user’s last 5 unread Gmail messages (authenticated with their real account). Scalekit manages the OAuth flow, token storage, and API proxy so you focus on agent logic.

Complete these steps in the Scalekit dashboard before writing any code:

  1. Create a Scalekit account at app.scalekit.com.

  2. Configure a Gmail connector at Dashboard → AgentKit > Connections > Create Connection → select Gmail.

    Gmail is enabled by default in new Scalekit environments. To connect to other services, create a connection for each app under AgentKit > Connections > Create Connection.

  3. Copy your API credentials at Dashboard → Developers → Settings → API Credentials. Save these three values as environment variables:

    • SCALEKIT_CLIENT_ID
    • SCALEKIT_CLIENT_SECRET
    • SCALEKIT_ENV_URL

Install the Scalekit Auth Stack for your coding agent, complete the browser authorization when prompted, then paste the implementation prompt. The agent scaffolds connected account setup, the OAuth flow, and tool execution.

Terminal
claude plugin marketplace add scalekit-inc/claude-code-authstack && claude plugin install agent-auth@scalekit-auth-stack

Installing the plugin sets up Scalekit’s MCP server and triggers an OAuth authorization flow in your browser. Complete the authorization before continuing. This gives Claude Code direct access to your Scalekit environment to search docs, manage connections, and check connected account status. Then paste the prompt below.

Implementation prompt
Configure Scalekit agent authentication for Gmail. Provide code to create a connected account, generate an authorization link, and, once the user authorizes, fetch the last 5 unread emails using Scalekit's tool API.

Run your agent and confirm:

  • The connected account status is ACTIVE after the user completes the Gmail OAuth flow.
  • The tool response contains structured email data (subject, sender, snippet, and timestamp) ready for your agent to process.

If the connected account stays in a non-ACTIVE state, the user has not completed the OAuth flow. Regenerate the authorization link and try again.

  • Secure user verification: Confirm the OAuth identity matches your logged-in user before activating a connected account. Required for production.
  • Connected accounts: Manage user connections across multiple providers.
  • Tool calling: Use Scalekit’s optimized tools to call APIs without managing endpoints yourself.