Mastra

Trace Mastra AI agent workflows with Respan.
  1. Sign up — Create an account at platform.respan.ai
  2. Create an API key — Generate one on the API keys page
  3. Add credits or a provider key — Add credits on the Credits page or connect your own provider key on the Integrations page

Add the Docs MCP to your AI coding tool to get help building with Respan. No API key needed.

1{
2 "mcpServers": {
3 "respan-docs": {
4 "url": "https://mcp.respan.ai/mcp/docs"
5 }
6 }
7}

What is Mastra?

Mastra is a TypeScript framework for building AI agents and workflows. It provides structured agent orchestration, tool management, and built-in telemetry via OpenTelemetry.

Example project: GitHub Link

Setup

1

Install packages

$npm install mastra @respan/exporter-vercel
2

Set environment variables

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
$export OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
3

Configure Mastra with Respan

1import { Mastra } from 'mastra';
2import { RespanExporter } from '@respan/exporter-vercel';
3
4const mastra = new Mastra({
5 telemetry: {
6 serviceName: 'my-mastra-app',
7 enabled: true,
8 export: {
9 type: 'custom',
10 exporter: new RespanExporter({
11 apiKey: process.env.RESPAN_API_KEY!,
12 baseUrl: process.env.RESPAN_BASE_URL,
13 debug: true, // enable for troubleshooting
14 }),
15 },
16 },
17});
4

View your trace

Open the Traces page to see your agent traces.

Configuration

Mastra uses the RespanExporter from @respan/exporter-vercel. See the Vercel Exporter SDK reference for exporter configuration.

Mastra configTypeDescription
telemetry.serviceNamestringApplication name for traces.
telemetry.enabledbooleanEnable/disable telemetry.
telemetry.export.type"custom"Must be "custom" for Respan.
telemetry.export.exporterSpanExporterRespanExporter instance.

Run the Mastra development playground to test your agent:

$mastra dev