Save your spot

Live eventA single Agent, 3 surfaces

How to Bring Your Mastra Agents into OpenBot as AI Coworkers

By Jerel Velarde
January 1, 1970
How to Bring Your Mastra Agents into OpenBot as AI Coworkers

By Jerel Velarde, Growth Team Staff Engineer at CopilotKit. Last updated December 3, 2026.

To bring a Mastra agent into OpenBot, deploy your Mastra server with Mastra's own auth turned on, then click New Bot in OpenBot, choose Mastra, and paste the server's address and key. OpenBot runs the agent through Mastra's own API, so you don't write an AG-UI endpoint, and your agent's instructions, tools and model stay as you wrote them.

OpenBot™ by CopilotKit (open.bot) is an open-source workspace where AI coworkers, called Bots, work in a sandboxed computer with a browser, a shell and files. A Mastra agent you connect becomes one of those Bots: you chat with it in OpenBot, and it can use OpenBot's tools and ask your other Bots for help. It isn't OpenBot by Synthetify Labs in Poland or the openbot.org robot kit.

When a Bot uses OpenBot's tools, by default it asks before sending, deleting, sharing, posting or paying in its browser or your connected apps, and OpenBot keeps a record. Your Mastra agent's own tools run in your server, outside those approvals.

Try OpenBot in your browser at my.open.bot, or download it at open.bot, free for personal use on a Mac or Windows PC.

We make OpenBot by CopilotKit. Checked against OpenBot 1.2.10 and Mastra 1.86 on December 3, 2026. Spot a mistake? Tell us on X at @0penBot.

What do you need to connect a Mastra agent to OpenBot?

  • OpenBot. Use it in your browser at my.open.bot, or in OpenBot Desktop for Mac or Windows. There's no Linux desktop app, so on Linux use my.open.bot or run OpenBot from source.
  • A Mastra server that runs one agent, with Mastra's auth turned on. Step 1 builds one in three files, on Node 22.13 or later.
  • An address OpenBot can reach. For OpenBot in the browser, that's a public HTTPS address, so you deploy the server in step 2.

How does OpenBot connect to a Mastra agent?

OpenBot runs your agent through Mastra's own API, the one mastra dev and mastra build already serve, so you don't write an AG-UI endpoint. Three optional pieces from @ag-ui/mastra, the AG-UI package for Mastra, hand your agent the Bot's role and OpenBot's tool guidance. They're an input processor on the agent, a route that tells OpenBot the agent accepts them, and a middleware that marks OpenBot's runs as trusted. Step 1 includes all three.

Diagram: a Mastra server with one agent, behind Mastra's own auth, on the left and OpenBot on the right. OpenBot checks the address and key before it makes the Bot. Each run, it sends the conversation, its tools and the Bot's role through Mastra's own API with the key, and the answers and tool steps stream back into the chat.
  • When you create the Bot, OpenBot asks your server which agents it runs, with the key. If the server refuses the key, there's no Bot.
  • On every message, OpenBot sends the conversation, its own tools and the Bot's role, with the same key, and the answer streams back into the chat.

Step 1: Build a Mastra server that checks OpenBot's key

This example is a Release Notes agent with one tool that reads the draft of the next release. Install Mastra and @ag-ui/mastra at the versions this guide was checked with:

npm install @mastra/core@1.86.0 @ag-ui/mastra@2.1.0 zod@4.6.7
npm install --save-dev mastra@1.40.2

The tool, in src/mastra/tools/release-draft.ts:

import { createTool } from "@mastra/core/tools";
import { z } from "zod";

// Sample data: what has merged so far for the next release.
const draft = {
  version: "0.4",
  changes: [
    { area: "Sync", note: "Offline edits merge when you reconnect" },
    { area: "Sync", note: "Conflicts show both versions side by side" },
    { area: "API", note: "Breaking: /v1/notes now pages with a cursor" },
    { area: "API", note: "Breaking: tags are lowercase everywhere" },
    { area: "Editor", note: "Paste keeps headings and lists" },
  ],
};

export const releaseDraft = createTool({
  id: "release-draft",
  description: "Read the draft of the next release notes: every change merged so far.",
  inputSchema: z.object({}),
  execute: async () => draft,
});

The agent, in src/mastra/agents/release-notes.ts:

import { Agent } from "@mastra/core/agent";
import { mastraRunGuidanceProcessor } from "@ag-ui/mastra/run-guidance";
import { releaseDraft } from "../tools/release-draft";

export const releaseNotes = new Agent({
  id: "release-notes",
  name: "Release Notes",
  instructions:
    "You keep the draft of the next release notes. Answer from the draft, briefly, and lead with breaking changes.",
  model: "openai/gpt-5.5",
  tools: { releaseDraft },
  // Hands the model the Bot's role and tool guidance that OpenBot sends with each run.
  inputProcessors: [mastraRunGuidanceProcessor],
});

And the server, in src/mastra/index.ts:

import { timingSafeEqual } from "node:crypto";
import { Mastra } from "@mastra/core/mastra";
import { MastraAuthProvider } from "@mastra/core/server";
import {
  registerMastraRunGuidanceCapabilities,
  withMastraRunGuidanceAuthority,
} from "@ag-ui/mastra/run-guidance";
import { releaseNotes } from "./agents/release-notes";

const key = process.env.AGENT_API_KEY;
if (!key) throw new Error("Set AGENT_API_KEY");
const expected = Buffer.from(key);

type Caller = { id: string };

// Mastra's own auth: requests to the agent need the key, which OpenBot sends as the Bot's Key.
class AgentKey extends MastraAuthProvider<Caller> {
  async authenticateToken(token: string): Promise<Caller | null> {
    const offered = Buffer.from(token.replace(/^Bearer\s+/i, "").trim());
    const match = offered.length === expected.length && timingSafeEqual(offered, expected);
    return match ? { id: "openbot" } : null;
  }
  async authorizeUser(caller: Caller): Promise<boolean> {
    return caller.id === "openbot";
  }
}

export const mastra = new Mastra({
  agents: { releaseNotes },
  server: {
    host: process.env.MASTRA_HOST ?? "0.0.0.0",
    auth: new AgentKey(),
    // Tells OpenBot this agent takes its role and tool guidance. Behind the same key.
    apiRoutes: [registerMastraRunGuidanceCapabilities("release-notes")],
    middleware: [
      // Runs before Mastra's key check, which still refuses any request without the key,
      // so every run that reaches the agent is OpenBot's.
      async (c, next) => {
        const body =
          c.req.method === "POST"
            ? await c.req.raw.clone().json().catch(() => undefined)
            : undefined;
        return withMastraRunGuidanceAuthority(true, next, body?.requestContext);
      },
    ],
  },
});

What each piece does:

  • auth: new AgentKey() turns on Mastra's own auth. Mastra now refuses requests to the agent, its memory and the route you add unless they carry the key. Mastra's built-in SimpleAuth is marked for development and testing, so this guide checks the key with MastraAuthProvider.
  • The @ag-ui/mastra lines are optional.mastraRunGuidanceProcessor and registerMastraRunGuidanceCapabilities let the agent take the Bot's role and OpenBot's tool guidance. withMastraRunGuidanceAuthority marks each run as trusted, so the role and tool guidance reach the model as system instructions. The middleware runs before Mastra's key check, but that check still refuses any request without the key, so only OpenBot's runs are trusted. Without these lines the agent still answers in OpenBot, but its model doesn't get the Bot's role.

Step 2: Deploy the Mastra server

Set the package's scripts to Mastra's production build, in package.json:

{
  "type": "module",
  "scripts": {
    "build": "mastra build",
    "start": "node .mastra/output/index.mjs"
  }
}

Where the server runs, set:

  • AGENT_API_KEY: a long random key, for example from openssl rand -hex 32. OpenBot will send it.
  • OPENAI_API_KEY: the agent's model calls OpenAI.

Mastra listens on the PORT your host gives it, or on 4111. We deployed ours on Railway: railway up from the project folder, the two keys as service variables, and railway domain for a public HTTPS address. Any host that runs Node 22.13 or later and npm start works.

Check the key before you open OpenBot:

curl -i https://your-mastra-server.example.com/api/agents
curl -H "Authorization: Bearer $AGENT_API_KEY" https://your-mastra-server.example.com/api/agents

The first answers 401. The second lists one agent, release-notes.

Mastra keeps its own storage in memory unless you add a storage adapter, and it says so when it starts. This agent stores nothing there, but add an adapter, such as Mastra's Postgres one, before you give an agent memory or workflows.

Step 3: Create the Bot in OpenBot

1. Click New Bot and give it a name and instructions. We called ours "Release Notes", with the instructions "Keeps the draft of the next release notes."

OpenBot 1.2.10's New Bot panel with the name Release Notes and the instructions

2. At the bottom of the panel, click Bring your own agent, then choose Mastra.

3. Under Agent address, paste your server's address. Under Key, type Bearer, a space and your AGENT_API_KEY.

OpenBot's New Bot panel after choosing Mastra. The Agent address field holds the Mastra server's address. The help text says the server needs to run one agent, and that for the Bot to get its full role and tool guidance the agent has to trust OpenBot. Below it is the optional Key field,

4. Click Create Bot. OpenBot asks the server which agents it runs, with the key, then makes the Bot. The Bot's page says Powered by Mastra.

The Release Notes Bot's page in OpenBot, marked

What OpenBot does when you click Create Bot:

Unknown block type "table", specify a component for it in the `components.types` option
OpenBot's New Bot panel with the Mastra server's address in red and the message

To change the key later, open the Bot's Setup, then Key under Connection, to replace or remove it. You can skip Key for tools: it's only for an agent that calls OpenBot's tools itself.

The Connection section of a Mastra Bot's Setup in OpenBot: the Agent URL, a Key row that says

Step 4: Chat with your Mastra Bot

Open the Bot and ask it something, like "What's going into 0.4 so far?" The Mastra agent calls its own tool and answers in the chat under the Bot's name.

The Release Notes Bot in OpenBot 1.2.10. Asked

What does a Mastra Bot get in OpenBot?

A Mastra Bot gets the Bot's role, dozens of OpenBot's tools on every run, and the other Bots you let it ask. We checked each in OpenBot Cloud 1.2.10 with the Release Notes agent:

  • The Bot's role and OpenBot's tool guidance, because the server in step 1 trusts OpenBot's key.
  • OpenBot's tools, next to your agent's own: 97 to 106 of them per run in our test. The model decides whether to call them. Ours drew a chart, showed an approval card and opened a page in the Bot's browser when we asked.
  • Approvals, when your agent asks. The card offers Approve, Decline or Tell the Bot something else. When we declined, the agent was told and stopped.
  • A browser on your OpenBot computer. In OpenBot Cloud each person has one computer that their Bots share. Isolated Bots, in OpenBot for Business (in early access), get one of their own.
  • Help from your other Bots, once you pick them under Bots it can ask in its Setup (none are picked at first). Their answers come back in the same conversation under their own names.
  • Who is asking. Each run carries the person's name and email as the AG-UI context entry OpenBot person. It reaches your server but not the model, so read it from the run's request context if you need it.
The Release Notes Bot answering
Asked to get approval before pretending to post the 0.4 draft, the Release Notes Bot shows OpenBot's approval card

When is another setup a better fit?

  • You only want to try the agent yourself. Mastra Studio, which mastra dev opens, chats with the agent without OpenBot (Mastra docs).
  • Your server runs several agents. New Bot takes a server with one agent. Run one server per agent, or, if you run your own OpenBot server, list each agent in its agents.yaml with remote_agent_id (configuration docs).
  • Your agent must act with each person's own credentials. OpenBot sends one key per Bot. Your server knows the call came from OpenBot, and OpenBot says who is asking, but your server never sees that person's own login.

In short

Give your Mastra server Mastra's own auth, deploy it, and add it in OpenBot as a Mastra Bot with its address and Bearer key.

More from us: All OpenBot guides · The best open-source AI agent workspaces · What is a Bot? · Which OpenBot? · OpenBot on GitHub · OpenBot's setup notes for Mastra

Page changes: December 3, 2026, for OpenBot 1.2.10, hosted with Mastra's own auth. November 30, 2026, for OpenBot 1.2.3. November 25, 2026, first version.

Frequently asked questions

Do I need an AG-UI endpoint to connect a Mastra agent to OpenBot?

No. OpenBot runs a Mastra agent through Mastra's own API, so you paste the server's address and key instead of writing an AG-UI endpoint. To give the agent the Bot's role, add the three @ag-ui/mastra pieces shown in step 1: the input processor, the route and the middleware.

What goes in the Key field for a Mastra Bot?

Bearer, a space and the key your Mastra server checks. OpenBot sends it as an Authorization header with every request and stores it encrypted. If the server refuses it, OpenBot doesn't make the Bot.

Can OpenBot in the browser reach a Mastra server on my laptop?

No. OpenBot in the browser needs an address it can reach over the internet, so deploy the server first. OpenBot Desktop can: run npx mastra dev with the same two keys, then give New Bot http://localhost:4111 and your key. We last checked that on OpenBot 1.2.3.

Does my Mastra agent get OpenBot's tools and approvals?

Yes, when its model calls them. OpenBot offers its tools with every run, next to your agent's own: 97 to 106 of them in our runs on OpenBot 1.2.10. There, the Mastra agent drew a chart, showed an approval card and opened a page in the Bot's browser when we asked. Your agent's own tools run in your Mastra server, outside OpenBot's approvals.

Which versions does this guide cover?

OpenBot 1.2.10, released December 3, 2026, with Mastra 1.86 (@mastra/core 1.86.0 and the mastra CLI 1.40.2) and @ag-ui/mastra 2.1.0. Checked December 3, 2026.

Top posts

See All
OpenBot vs Instinct: Open-Source Alternative to the AI Personal Assistant
Anmol Baranwal and Eli BermanDecember 3, 2026
OpenBot vs Instinct: Open-Source Alternative to the AI Personal AssistantOpenBot vs Instinct: an open-source alternative to the AI personal assistant you text or call. Instinct runs personal errands on undisclosed models, by invite only, while OpenBot gives every team AI coworkers for work, with any model and your own agents, in an enterprise-ready workspace. See how they compare on models, agents, data, controls and pricing, and when to choose which.
OpenBot vs Viktor: Open-Source Alternative With Self-Hosted AI Employees
Anmol Baranwal and Eli BermanDecember 3, 2026
OpenBot vs Viktor: Open-Source Alternative With Self-Hosted AI EmployeesOpenBot vs Viktor: a self-hosted, open-source alternative to the hosted AI employee. Viktor runs one shared AI employee per workspace in its own cloud on credits, while OpenBot gives every team AI coworkers with their own computers, any model and your own agents, in an enterprise-ready workspace priced per user. See how they compare on models, agents, data, controls and pricing, and when to choose which.
OpenBot vs Paperclip: Open-Source AI Agents With Their Own Computers
Anmol Baranwal and Eli BermanDecember 3, 2026
OpenBot vs Paperclip: Open-Source AI Agents With Their Own ComputersOpenBot vs Paperclip: an open-source alternative to the app for managing a team of AI agents. Paperclip organizes agents you bring and run yourself, while OpenBot comes with self-learning AI coworkers that are ready to work, each on its own computer. You can use any model and run your own agents under the hood. See how they compare on agents, setup, controls, sign-in and pricing, and when to choose which.
Are you ready?

Stay in the know

Subscribe to our blog and get updates on CopilotKit in your inbox.