Mastra MCP server for AI agents and assistants

Securely connect your AI agents and chatbots (Claude, ChatGPT, Cursor, etc) with Mastra MCP or direct API to manage projects, check deployments, review feedback, and query observability metrics through natural language.

Mastra logoMastra
Api Key

Mastra is a platform for managing AI agent projects, deployments, and observability. It helps teams monitor agent performance with hosted metrics and feedback APIs.

35 Tools

Try Mastra now

Type what you want done — sign in and watch it run live in the Tool Router playground.

TOOL ROUTER PLAYGROUND
Mastra
Try asking
TOOLS

Supported Tools

Every Mastra action and event your agent gets out of the box.

Add Server Domain

Add a custom domain to a hosted Mastra Server project and return its required DNS records.

Analyze Feedback

Calculate an aggregate, grouped breakdown, time series, or percentile series over numeric Mastra feedback without creating data.

Analyze Metrics

Calculate an aggregate, grouped breakdown, time series, or percentile series over hosted Mastra metrics without creating data.

Cancel Server Deployment

Cancel a queued or in-progress Mastra hosted Server deployment.

Confirm Deploy Upload

Confirm that a deployment ZIP has already been uploaded to the signed URL returned by Create Deployment Upload.

Create API Token

Create a Mastra organization API token.

Create Deployment Upload

Create a legacy Mastra Studio or hosted Server deployment upload reservation.

Create Server Project

Create a hosted Mastra Server project.

Create Studio Project

Create a Mastra Studio project.

Delete Project

Permanently delete a Mastra Studio project and all its deployments, or a hosted Server project and its provisioned resources.

Discover Metrics

Discover metric names, labels, and shared observability dimensions without creating data.

Get Authentication Context

Return the user, organization, role, and authentication type associated with the connected Mastra API key.

Get Deployment

Get the status and details of one Mastra Studio or hosted Server deployment.

Get Deployment Logs

Get logs for one Mastra Studio or hosted Server deployment; Studio calls may limit the number of recent lines.

Get Project

Get one Mastra Studio or hosted Server project and its deployment history.

Get Server Environment Variables

SENSITIVE: Get environment variables for a hosted Mastra Server project.

Get Server Runtime Logs

Get current runtime log records for a hosted Mastra Server project.

Invite Organization Member

Send an invitation to join the connected Mastra organization with a member or admin role.

List API Tokens

List metadata for Mastra organization API tokens.

List Feedback

List hosted Mastra feedback records with page or durable delta continuation.

List Organization Invitations

List all pending invitations for the connected Mastra organization.

List Organization Members

List members of the connected Mastra organization, including their roles and membership status.

List Metrics

List raw hosted Mastra metric records with page or durable delta continuation.

List Organizations

List Mastra organizations available to the connected API-key bearer credential.

List Projects

List Mastra Studio or hosted Server projects in the connected organization.

List Server Domains

List custom domains configured for a hosted Mastra Server project.

Redeploy Server Project

Trigger a new deployment for a hosted Mastra Server project.

Remove Organization Member

Remove a member from the connected Mastra organization.

Revoke API Token

Revoke a Mastra organization API token so it can no longer authenticate.

Revoke Organization Invitation

Revoke a pending invitation to the connected Mastra organization.

Set Server Environment Variables

SENSITIVE SECRET MUTATION: Replace environment variables for a hosted Mastra Server project.

Set Server Environment Variables and Restart

SENSITIVE, IRREVERSIBLE RUNTIME OPERATION: Replace secret environment variables for a hosted Mastra Server project and immediately restart its running service.

Stop Server Deployment

Stop a Mastra hosted Server deployment.

Update Organization Member Role

Change an existing member's role in the connected Mastra organization.

Verify Project Ingest Access

Verify that the connected Mastra organization API key can ingest telemetry for one project without changing provider state.

SETUP GUIDE

Connect Mastra MCP Tool with your Agent

1

Install Composio

typescript
npm install @composio/core ai @ai-sdk/mcp @ai-sdk/openai
Install the Composio SDK and your agent framework
2

Create a session with MCP enabled

typescript
import { Composio } from "@composio/core";

const composio = new Composio();
const { mcp } = await composio.create("your-user-id", {
  toolkits: ["mastra"],
  mcp: true,
});
Create a session scoped to Mastra and read its MCP URL and headers
3

Connect your agent to the MCP server

typescript
import { createMCPClient } from "@ai-sdk/mcp";
import { openai } from "@ai-sdk/openai";
import { generateText, stepCountIs } from "ai";

const client = await createMCPClient({
  transport: { type: "http", url: mcp.url, headers: mcp.headers },
});

const { text } = await generateText({
  model: openai("gpt-5.6-sol"),
  tools: await client.tools(),
  prompt: "List my Mastra projects and show the deployment status for each one",
  stopWhen: stepCountIs(10),
});

console.log(text);
await client.close();
Pass the session's MCP URL and headers to your agent and run a Mastra request
SETUP GUIDE

Connect Mastra API Tool with your Agent

1

Install Composio

typescript
npm install @composio/core @composio/openai openai
Install the Composio SDK, the OpenAI provider, and the OpenAI SDK
2

Create a Composio session

typescript
import OpenAI from "openai";
import { Composio } from "@composio/core";
import { OpenAIResponsesProvider } from "@composio/openai";

const composio = new Composio({ provider: new OpenAIResponsesProvider() });
const client = new OpenAI();

const session = await composio.create("your-user-id", { toolkits: ["mastra"] });
const tools = await session.tools();
Initialize Composio with the OpenAI Responses provider and create a session scoped to Mastra
3

Run Mastra tools with your agent

typescript
let response = await client.responses.create({
  model: "gpt-5.6-sol",
  tools,
  input: [{ role: "user", content: "List my Mastra projects and show the deployment status for each one" }],
});

while (response.output.some((o) => o.type === "function_call")) {
  const outputs = await composio.provider.handleToolCalls(session, response.output);
  response = await client.responses.create({
    model: "gpt-5.6-sol",
    tools,
    previous_response_id: response.id,
    input: outputs,
  });
}

console.log(response.output_text);
Send a request, execute the Mastra tool calls through the session, and print the final answer

Why Use Composio?

AI Native Mastra Integration

  • Supports both Mastra MCP and direct API based integrations
  • Structured, LLM-friendly schemas for reliable project, deployment, feedback, and metrics operations
  • Rich coverage for managing Mastra projects and querying hosted observability data

Managed Auth

  • Securely stores and uses your Mastra API key for agent requests
  • Central place to manage, scope, and revoke Mastra access
  • Per user and per environment credentials instead of hard-coded keys

Agent Optimized Design

  • Tools are tuned using real error and success rates to improve reliability over time
  • Comprehensive execution logs so you always know what ran, when, and on whose behalf

Enterprise Grade Security

  • Fine-grained RBAC so you control which agents and users can access Mastra
  • Scoped, least privilege access to Mastra resources
  • Full audit trail of agent actions to support review and compliance
FRAMEWORKS

Use Mastra with any AI Agent Framework

Choose a Framework you want to connect Mastra with

Rolling this out across your team?

Give your team centralized access control across every framework with Composio’s MCP Gateway.

EXPLORE MCP GATEWAY
FAQ

Frequently asked questions

Start with Mastra.It takes 30 seconds.

Managed auth, hosted MCP servers, and every Mastra tool your agent needs.Free to start.

Start building