> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.astropods.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.astropods.com/_mcp/server.

# Mastra

The `@astropods/adapter-mastra` package — the same one used to connect a Mastra agent to Astro messaging — auto-wires OpenTelemetry tracing when `OTEL_EXPORTER_OTLP_ENDPOINT` is set in the deployed container. Model calls, tool calls, and agent steps flow into the dashboard automatically.

## Install

```bash
bun add @astropods/adapter-mastra
```

## Use

```typescript
import { Agent } from "@mastra/core/agent";
import { serve } from "@astropods/adapter-mastra";

const agent = new Agent({
  name: "My Agent",
  model: "anthropic/claude-sonnet-4-5",
  instructions: "You are a helpful assistant.",
});

serve(agent);
```

Calling `serve()` registers the agent with the messaging service and configures observability in the same step. The agent's `name` is sent as the OpenTelemetry `service.name`; the platform-injected `OTEL_EXPORTER_OTLP_ENDPOINT` is used for export. No additional configuration is required.

If your project constructs its own `Mastra` instance (e.g. for multi-agent workflows), `serve()` registers Astro's OpenTelemetry observability alongside any existing observability instances on that Mastra.

## Verify

Deploy the agent, send it a message, then open the agent's detail page in the Astro dashboard. Traces appear within \~30 seconds.

If nothing shows up:

* Confirm `OTEL_EXPORTER_OTLP_ENDPOINT` is present in the deployed container.
* Check the agent container logs for OpenTelemetry export errors.