Detected country: US
logo
Sign InBook a Demo
GuideRecipesDeveloper

Developer Docs

  • Developer foundations
    • How do I authenticate with the Ballet API?
    • How do I connect to Ballet's MCP endpoint?
    • How do I run a playbook over the REST API?
    • How do I stream playbook run events?
    • How do I trigger and react to playbooks with webhooks?
    • How do I wake a suspended run with reply or resume?
  • How do I use Ballet playbooks in an agent framework?
    • How do I call Ballet playbooks from Google ADK?
    • How do I call Ballet playbooks from LangChain?
    • How do I call Ballet playbooks from Mastra?
    • How do I call Ballet playbooks from Pydantic AI?
    • How do I call Ballet playbooks from the Vercel AI SDK?
  • How do playbooks connect to external systems?
    • How do I call external APIs and SDKs from a playbook?
    • How do I connect external MCP servers to playbooks?
    • How do I use secrets and env vars in steps?
  • Introduction
Loading…
logo

Powered by

How do I use Ballet playbooks in an agent framework?

TL;DR: Expose your Ballet playbooks as tools inside any agent framework two ways. The MCP path points the framework's MCP client at https://api.ballet.dev/mcp and auto-imports tools like run_playbook and get_run. The REST path defines a single custom tool that calls POST /api/playbooks/:id/execute. Both authenticate with a workspace API token.

Who this is for

Developers building agents that should be able to run Ballet playbooks as part of their reasoning loop.

What are the two integration patterns?

MCP — point the framework's MCP client at https://api.ballet.dev/mcp and Ballet's tools (list_playbooks, run_playbook, get_run, and the rest) are imported automatically. Best when you want the agent to discover and manage playbooks, or you are already using MCP.

REST custom tool — define one tool in your framework that POSTs to the execute endpoint. Best when you want to expose exactly one playbook with a tight schema.

Both use the same auth: send a workspace API token as Authorization: Bearer mt_live_…. See authentication. The MCP endpoint also supports browser-based OAuth for interactive clients — see the MCP endpoint.

Both surfaces are served from api.ballet.dev. app.ballet.dev serves Ballet Studio and will not answer API or MCP requests.

Which framework are you using?

  • Vercel AI SDK — TypeScript, createMCPClient or a tool() definition.
  • LangChain / LangGraph — Python, MultiServerMCPClient or a @tool.
  • Mastra — TypeScript, MCPClient or createTool.
  • Google ADK — Python, McpToolset or a FunctionTool.
  • Pydantic AI — Python, MCPServerStreamableHTTP toolset or a function tool.

Tips that apply everywhere

  • Start with the MCP path to let the agent see all playbooks, then narrow with a tool filter once you know which it needs.
  • For the REST path, give the tool a clear name and description so the model knows when to run the playbook.
  • Treat the playbook's run_stop.output as the tool result; surface success so the agent can handle failures.

Related articles

  • The MCP endpoint
  • Run playbooks over the REST API
  • How do I authenticate with the Ballet API?