Tulip Logo IconTulip
Concepts

Concepts

How agents, tools, runs, approvals, chat and MCP fit together.

The AI package is built around a few ideas that hold for every way an agent is used: in the in-app chat, from a button, on a domain event, on a schedule, or as tools for an MCP app.

IdeaWhat it is
ToolOne action in the app, defined once with tool(): what it does, its permission, how it is confirmed.
AgentWho does the work: a model, instructions and tools, made with defineAgent. Defined in code.
PrincipalWhose permissions a run uses: a user's, or the agent's own grants when it runs as itself.
TriggerWhat started a run: a chat, an MCP app, a user action, an event or a schedule.
RunOne time an agent did a job: its principal, trigger, status, output and error.
ApprovalA tool call that waits for a person, in the chat or outside it.

How a run is checked

Every tool call goes through the same checks, whatever started the run:

  1. The agent is active. Agents are defined in code, but only run once an admin activated them for the workspace (Agents).
  2. The principal may do it. For a user, the tool base's authorize checks the tool's permission. For an agent running as itself, only its own identity.grants count.
  3. The agent may do it. The workspace's setting for the agent and tool: allowed, asked first, or not allowed. MCP apps are set per user instead.
  4. It is confirmed. A tool that is asked first waits for an approval; one that needs a passkey only runs with a verified proof.

Where the pieces live

  • tools: the tool base (toolBuilder) and tool definitions.
  • agents: defineAgent, and Agents: runs, approvals and what agents may do.
  • chat: Chat for saved chats on the server, and the chat hook and components.
  • mcp: Mcp, serving the tools to MCP apps with per-user settings.
  • drizzle: the database adapters for the services' tables.
  • context: the page the user opened the chat from.
  • types: the types server and client share.

Agents, Chat and Mcp are independent services: Chat needs Agents, Mcp needs neither. See Services.

Pages

On this page