Skip to main content

Connect your MCP client to Mastra

The proposed launcher would connect an external Model Context Protocol (MCP) client to your running Mastra API. Your client would start one local process and communicate with it through standard input and output (stdio). That process would forward tool calls to Mastra over HTTP. You wouldn't need to host a separate MCP service.

One launcher would expose the supported subset of the 60 tools listed below. You wouldn't configure a separate process for each agent, workflow, or tool.

Start your Mastra API
Direct link to Start your Mastra API

You need an existing Mastra project and Node.js with npx available. In your project directory, start the development server with the existing command:

npx mastra dev

Keep that terminal process running. The proposed configuration below assumes the default API port, 4111. The API must stay running for the MCP client to connect, but you can close the Studio browser tab.

Proposed client configuration
Direct link to Proposed client configuration

This configuration is for review only. It won't work until the launcher is implemented.

In a client that accepts an mcpServers configuration, the proposed stdio entry would be:

{
"mcpServers": {
"mastra": {
"command": "npx",
"args": ["-y", "mastra", "mcp", "--url", "http://localhost:4111"]
}
}
}

The client would launch the command itself. The --url value would point to the Mastra server base URL, not a Studio page or an MCP endpoint. Configuration locations vary by client. Use your client's instructions for adding a local stdio server.

Here, localhost refers to the machine running the launcher. A client running in a container or on another machine would need a URL that can reach your Mastra API from that environment.

Proposed optional authentication
Direct link to Proposed optional authentication

For an API protected by bearer-token authentication, the proposed launcher would read MASTRA_API_TOKEN from its environment. A client entry could include an env object alongside command and args:

{
"mcpServers": {
"mastra": {
"command": "npx",
"args": ["-y", "mastra", "mcp", "--url", "http://localhost:4111"],
"env": {
"MASTRA_API_TOKEN": "your-api-token"
}
}
}
}

This environment-variable behavior isn't implemented in a launcher. The existing programmatic API accepts authentication through its headers option. Keep real tokens out of version control and shared configuration. Omit the proposed env entry for an API that doesn't require authentication.

Tool discovery and permissions
Direct link to Tool discovery and permissions

The implemented API bridge reads the target server's API schema at startup and registers matching operations from its generated catalog. The proposed launcher would use this bridge, so the available tools would depend on the target server. The catalog covers API-prefixed Mastra routes, not Factory or platform commands outside that scope.

Once a launcher is implemented, the first verification would be to open the client's tool list and call agent_list. An empty agent list can be valid if the project has no agents. A missing tool is different: its route might not be supported by the target API.

Review client approvals before allowing tool calls. Some tools create, update, or delete data; agent, workflow, experiment, and tool execution can also have external effects. The current bridge marks all non-GET operations as potentially destructive. MCP annotations are hints, not authorization checks. The target API must enforce access permissions.

Full tool catalog
Direct link to Full tool catalog

These are all 60 tools in the generated Mastra API operations catalog, grouped by function. This is the catalog inventory, not a promise that every target server exposes every tool. Inputs come from the target server's route schemas.

Agents
Direct link to Agents

ToolPurpose
agent_listList available agents
agent_getGet agent details
agent_runRun an agent with JSON input

Workflows
Direct link to Workflows

ToolPurpose
workflow_listList available workflows
workflow_getGet workflow details
workflow_run_startStart a workflow run
workflow_run_listList workflow runs
workflow_run_getGet workflow run details
workflow_run_resumeResume a suspended workflow run
workflow_run_cancelCancel a workflow run

Tools and MCP servers
Direct link to Tools and MCP servers

ToolPurpose
tool_listList available tools
tool_getGet tool details and input schema
tool_executeExecute a tool with JSON input
mcp_listList MCP servers
mcp_getGet MCP server details
mcp_tool_listList tools for an MCP server
mcp_tool_getGet MCP tool details
mcp_tool_executeExecute an MCP tool with JSON input

For tool_execute and mcp_tool_execute, pass the tool's input inside the data field.

Threads and memory
Direct link to Threads and memory

ToolPurpose
thread_listList memory threads
thread_getGet thread details
thread_createCreate a memory thread
thread_updateUpdate a memory thread
thread_deleteDelete a memory thread
thread_messagesList messages in a memory thread
memory_searchSearch long-term memory
memory_current_getGet current working memory
memory_current_updateUpdate current working memory
memory_statusGet memory system status

Traces and logs
Direct link to Traces and logs

ToolPurpose
trace_listList observability traces
trace_getGet trace details
trace_spanGet a trace span
log_listList runtime logs

Trace list and get operations support verbose when the target schema includes both the light and full routes.

Metrics
Direct link to Metrics

ToolPurpose
metric_aggregateGet an aggregate metric value
metric_breakdownGet metric values grouped by a label or field
metric_timeseriesGet metric values over time
metric_percentilesGet metric percentile values over time
metric_namesList discovered metric names
metric_label_keysList label keys for a metric
metric_label_valuesList label values for a metric label key

Scores, datasets, and experiments
Direct link to Scores, datasets, and experiments

ToolPurpose
score_createCreate a score
score_listList scores
score_getGet score details
dataset_listList datasets
dataset_getGet dataset details
dataset_createCreate a dataset
dataset_itemsList dataset items
experiment_listList dataset experiments
experiment_getGet experiment details
experiment_runRun a dataset experiment
experiment_resultsList experiment results

Trace Intelligence
Direct link to Trace Intelligence

ToolPurpose
learning_entitiesList entities with Trace Intelligence output
learning_snapshotsList analysis snapshots for an entity and ordered trace signals
learning_flowGet the cross-signal theme flow for one snapshot
learning_pathsGet per-trace theme assignments for one snapshot
learning_theme_listList themes for one trace signal in one snapshot
learning_theme_getGet one theme in one snapshot
learning_theme_examplesList trace examples for one theme in one snapshot
learning_theme_historyGet lifecycle history for one durable theme
learning_noise_getGet the noise bucket for one trace signal in one snapshot
learning_noise_examplesList trace examples for the noise bucket in one snapshot

Troubleshooting
Direct link to Troubleshooting

The launcher-specific checks below describe the proposed experience. For a connection you can implement today, follow the programmatic MCP server API.

SymptomWhat to check
mastra mcp isn't recognizedThis is expected today. The launcher is proposed and not implemented. Changing client settings won't enable it.
The client can't find npxCheck that Node.js and npx are available in the environment used by the client, which may differ from your terminal.
The API connection is refusedKeep npx mastra dev running. Check the server's actual port and network access from the process running the client. An open browser tab isn't sufficient.
The API returns 401 or 403Check the API's authentication requirements and token permissions. The proposed launcher token variable isn't a replacement for configuring authentication on the server.
Schema discovery failsThe target must support GET /api/system/api-schema with a valid version-1 manifest. Check server compatibility and access to that route.
Fewer than 60 tools are listedOnly catalog operations with matching target API routes are registered. The catalog excludes Factory and platform routes.
A tool call fails input validationUse the tool schema returned by the target server. Execution tools require the underlying tool input in data.
A call times outCheck API logs and operation status before retrying. A timed-out mutation may already have changed data.