Mastra/mcp

official

Client implementation for Mastra, providing seamless integration with MCP-compatible AI models and tools.

What can you do with Mastra MCP?

  • Connect agents to external MCP servers — use MCPClient to let an agent call tools and access resources from one or more MCP-compatible servers.
  • Expose Mastra tools as MCP tools — create an MCPServer that publishes your existing Mastra tools for any MCP client to discover and invoke.
  • Expose Mastra agents via MCP — serve agents through an MCPServer so external systems can interact with them over the protocol.
  • Expose workflows and prompts — publish Mastra workflows and prompts as MCP resources that clients can retrieve and execute.

Documentation

@mastra/mcp

Mastra supports the Model Context Protocol (MCP), an open standard for connecting AI agents to external tools and resources. It serves as a universal plugin system, enabling agents to call tools regardless of language or hosting environment.

Mastra can also be used to author MCP servers, exposing agents, tools, and other structured resources via the MCP interface. These can then be accessed by any system or agent that supports the protocol.

Installation

To use MCP, install the required dependency:

npm install @mastra/mcp@latest

Overview

Mastra currently supports two MCP classes:

  • MCPClient: Connects to one or many MCP servers to access their tools, resources, prompts, and handle elicitation requests.
  • MCPServer: Exposes Mastra tools, agents, workflows, prompts, and resources to MCP-compatible clients.

Read the official MCP documentation to learn more.