MCP client - Mastra - verified
How to add an MCP server to Mastra
Where to add MCP servers in Mastra: In code: new MCPClient({ servers }) from @mastra/mcp (docs example path src/mastra/mcp/client.ts). Its docs list support for stdio and Streamable HTTP and say SSE is not supported. It handles OAuth sign-in for remote servers.
Mastra homepage - Mastra in our tools directory - Compare all MCP clients
- Kind
- SDK or framework
- stdio
- Yes
- Streamable HTTP
- Yes
- SSE
- No
Add a server
- Where the config lives
- In code: new MCPClient({ servers }) from @mastra/mcp (docs example path src/mastra/mcp/client.ts)
The example from the Mastra docs, copied verbatim. Swap in your server's name, command or URL.
const mcpClient = new MCPClient({
servers: {
github: {
url: new URL('https://github.example.com/mcp'),
requireToolApproval: true,
},
},
})Source: mastra.ai/docs/connections/mcp
Which server?
Pick a server from the verified directory of official MCP servers. Each one lists its transport, auth and the setup snippets its vendor publishes, so you can match it to what Mastra supports.
MCP support
What the Mastra docs say it supports. Not stated means the docs do not say either way.
| Feature | Value | Source |
|---|---|---|
| ToolsCalls the functions a server exposes. | Yes | mastra.ai/reference/tools/mcp-client |
| ResourcesReads data and files a server exposes as resources. | Yes | mastra.ai/reference/tools/mcp-client |
| PromptsOffers a server's prompt templates to the user. | Yes | mastra.ai/reference/tools/mcp-client |
| SamplingLets a server ask the client's model for a completion. | No | mastra.ai/reference/tools/mcp-client |
| RootsTells a server which directories it may work in. | No | mastra.ai/reference/tools/mcp-client |
| ElicitationLets a server ask the user for input mid-task. | Yes | mastra.ai/reference/tools/mcp-client |
| DiscoveryPicks up tools, prompts or resources a server adds or removes while connected. | Yes | mastra.ai/reference/tools/mcp-client |
| InstructionsUses the instructions a server sends when it connects. | Yes | mastra.ai/reference/tools/mcp-client |
| stdioStarts a local server as a subprocess. | Yes | mastra.ai/docs/connections/mcp |
| Streamable HTTPConnects to a remote server over the current HTTP transport. | Yes | mastra.ai/docs/connections/mcp |
| SSEConnects over the older HTTP+SSE transport. | No | mastra.ai/reference/migrations/mcp-v2 |
| OAuthSigns in to remote servers with OAuth. | Yes | mastra.ai/reference/tools/mcp-client |
Worth knowing
@mastra/mcp 2.x speaks MCP 2026-07-28 over stdio and Streamable HTTP, falls back to the legacy initialize handshake for older servers, and no longer falls back to the standalone HTTP+SSE transport.
Other SDKs and frameworks
FAQ
Where is the Mastra MCP config?
In code: new MCPClient({ servers }) from @mastra/mcp (docs example path src/mastra/mcp/client.ts). The example on this page is copied from https://mastra.ai/docs/connections/mcp
Does Mastra support remote MCP servers over Streamable HTTP?
Yes, per https://mastra.ai/docs/connections/mcp. Its docs list support for stdio and Streamable HTTP and say SSE is not supported.
Does Mastra support OAuth for MCP servers?
Yes. It handles OAuth sign-in for remote servers. Source: https://mastra.ai/reference/tools/mcp-client
Which MCP features does Mastra support?
Its docs list Tools, Resources, Prompts, Elicitation, Discovery and Instructions. They say Sampling and Roots are not supported.
Sources
Last verified from the pages below.
- Mastra docs: MCP connections - mastra.ai
- Mastra reference: MCPClient - mastra.ai
- Mastra migration: @mastra/mcp v1 to v2 - mastra.ai
Newsletter
New MCP servers, the week they ship
One email per week. New official MCP servers, the coding tools that support them and how developers wire them up.