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 clientDirect 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.
- Claude Code
- Claude Desktop
- Codex
- Codex desktop
- Other clients
-
Add the server:
claude mcp add --transport http mastra https://platform.mastra.ai/v1/mcp -
Start Claude Code and run
/mcp. -
Select mastra, then select the option to authenticate.
-
Go to Customize > Connectors, select + Add, then select Add custom connector.
-
Enter
mastraas the name andhttps://platform.mastra.ai/v1/mcpas the URL, then confirm to add the connector. -
Keep the authentication settings Claude detects and follow the prompts to sign in.
On Team and Enterprise plans, an organization Owner may need to add the connector first. See Get started with custom connectors using remote MCP for details.
-
Add the server:
codex mcp add mastra --url https://platform.mastra.ai/v1/mcp -
Sign in:
codex mcp login mastra
-
Open Plugins, then select Add plugin.
-
Select Custom MCP server.
-
Enter
mastraas the name andhttps://platform.mastra.ai/v1/mcpas the URL, then save the server. -
Follow the prompt to authenticate the mastra server.
-
Add the server to your client's MCP configuration file. This example uses the
mcpServersformat that many clients accept. Some clients use a different format, such as VS Code, which expects aserversobject in.vscode/mcp.json. Check your client's documentation for its file location and format.mcp.json{"mcpServers": {"mastra": {"type": "http","url": "https://platform.mastra.ai/v1/mcp"}}} -
Restart the client and follow its prompt to authenticate the mastra server.
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 questionsDirect 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 projectDirect 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 toolsDirect link to Available tools
The tools only read data. They can't change anything in your organization.
Traces and spansDirect link to Traces and spans
| Tool | Description |
|---|---|
query_traces | Search traces by entity, status, time range, metadata, and other fields. |
aggregate_traces | Count traces and compute durations and error rates, optionally grouped and bucketed over time. |
get_trace_query_fields | List the fields that query_traces can filter and group on. |
get_trace_query_values | List the values recorded for one trace query field. |
get_trace | Get the spans in a trace, with their parent, name, type, timing, and status. |
get_span | Get one span, including its input, output, and attributes. |
query_spans | Search individual spans, such as model calls, tool calls, and workflow steps, across traces. |
aggregate_spans | Count spans and compute durations and token usage, optionally grouped and bucketed over time. |
query_threads | Search conversation threads by the traces recorded in them. |
Logs, metrics, scores, and feedbackDirect link to Logs, metrics, scores, and feedback
| Tool | Description |
|---|---|
list_logs | List log records, filtered by level, trace, entity, or time range. |
list_scores | List scorer results, filtered by scorer, trace, entity, or time range. Needs a project. |
list_feedback | List user feedback, filtered by trace, entity, or time range. |
analyze_metrics | Aggregate metrics such as tokens, cost, latency, and counts as a single value, a breakdown by label, a time series, or percentiles. |
analyze_scores | Aggregate scorer results as a single value, a breakdown, a time series, or percentiles. Needs a project. |
analyze_feedback | Aggregate user feedback as a single value, a breakdown, a time series, or percentiles. |
list_metric_names | List metric names, a metric's label keys, or a label's values. |
ProjectsDirect link to Projects
| Tool | Description |
|---|---|
list_projects | List the organization's projects. |