Skip to content

Mastra Support #295

@zahlekhan

Description

@zahlekhan

Is your feature request related to a problem? Please describe.
Mastra is a growing TypeScript AI agent framework with its own streaming and tool-calling patterns. OpenUI currently has no adapter for Mastra's output format, so users building agentic applications with Mastra cannot connect their agents to OpenUI's streaming renderer and chat interfaces without writing custom integration code.

Describe the solution you'd like
Add Mastra support to OpenUI, consisting of:

  1. Streaming adapter — A mastraAdapter in @openuidev/react-headless implementing StreamProtocolAdapter that parses Mastra's streaming response format and converts it into OpenUI's internal event stream. This should handle Mastra's agent streaming output, including tool calls and multi-step agent runs. Usable via streamProtocol="mastra" on ChatProvider.

  2. Message format converter — A mastraMessageFormat converter so OpenUI's chat message history is compatible with Mastra's expected message format.

  3. Example app — A standalone example in examples/ (e.g., examples/mastra-chat) demonstrating OpenUI + Mastra integration. The example should be a full working Next.js app showing how to wire a Mastra agent backend to OpenUI's generative UI frontend, following the same structure as examples/openui-chat.

Describe alternatives you've considered

  • Users could add a server-side translation layer that converts Mastra streams into a format an existing adapter (e.g., AG-UI or OpenAI) understands, but this adds unnecessary complexity and may lose Mastra-specific features like agent tool call semantics.
  • Documentation-only guidance without runnable code, but a working adapter and example are far more useful for adoption.

Additional context
Existing adapters live in packages/react-headless/src/stream/adapters/. The adapter should follow the same StreamProtocolAdapter pattern (implementing async *parse(response): AsyncIterable<AGUIEvent>). Mastra's documentation: https://mastra.ai/docs

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Next

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions