Skip to main content

MCP server on Mastra platform

The Mastra platform MCP server lets an AI assistant read your organization's Observability data through the Model Context Protocol (MCP). Connect it to Claude, Codex, or another MCP client, then ask about your traces, logs, metrics, scores, and feedback in chat.

Connect your MCP client
Direct link to Connect your MCP client

Before you start, ensure that you have a Mastra platform account and belong to the organization whose data you want to query.

  1. Add the server:

    claude mcp add --transport http mastra https://platform.mastra.ai/v1/mcp
  2. Start Claude Code and run /mcp.

  3. Select mastra, then select the option to authenticate.

When you authenticate, your browser opens the Mastra sign-in page. Sign in and select an organization. The connection then acts as you in that organization and can read only the data you can read. If you leave the organization or someone removes you from it, the connection loses access on its next request.

Ask questions
Direct link to Ask questions

Ask in plain language. The assistant picks the tools and fills in their parameters. For example:

  • "How many traces failed in the last 24 hours, grouped by agent?"
  • "Which tool calls were slowest this week, and what did they return?"
  • "What was the token cost per model over the last 7 days?"

Query one project
Direct link to Query one project

By default, tools read data from the whole organization. To query one project, name it in your request, for example "in the checkout project". The assistant looks up the project with list_projects and passes its ID or slug to each tool.

list_scores and analyze_scores always need a project, so name one when you ask about scores.

Available tools
Direct link to Available tools

The tools only read data. They can't change anything in your organization.

Traces and spans
Direct link to Traces and spans

ToolDescription
query_tracesSearch traces by entity, status, time range, metadata, and other fields.
aggregate_tracesCount traces and compute durations and error rates, optionally grouped and bucketed over time.
get_trace_query_fieldsList the fields that query_traces can filter and group on.
get_trace_query_valuesList the values recorded for one trace query field.
get_traceGet the spans in a trace, with their parent, name, type, timing, and status.
get_spanGet one span, including its input, output, and attributes.
query_spansSearch individual spans, such as model calls, tool calls, and workflow steps, across traces.
aggregate_spansCount spans and compute durations and token usage, optionally grouped and bucketed over time.
query_threadsSearch conversation threads by the traces recorded in them.

Logs, metrics, scores, and feedback
Direct link to Logs, metrics, scores, and feedback

ToolDescription
list_logsList log records, filtered by level, trace, entity, or time range.
list_scoresList scorer results, filtered by scorer, trace, entity, or time range. Needs a project.
list_feedbackList user feedback, filtered by trace, entity, or time range.
analyze_metricsAggregate metrics such as tokens, cost, latency, and counts as a single value, a breakdown by label, a time series, or percentiles.
analyze_scoresAggregate scorer results as a single value, a breakdown, a time series, or percentiles. Needs a project.
analyze_feedbackAggregate user feedback as a single value, a breakdown, a time series, or percentiles.
list_metric_namesList metric names, a metric's label keys, or a label's values.

Projects
Direct link to Projects

ToolDescription
list_projectsList the organization's projects.
On this page