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 to remote MCP servers — Ask your assistant to connect to an external MCP server by URL using MCPClient and list its available tools.
  • Use local MCP tools via stdio — Configure an MCP server through a stdio command so your assistant can call tools from local processes.
  • Expose agents as MCP servers — Author an MCP server with Mastra to make your agents and tools accessible to any MCP-compatible system.

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

npm install @mastra/mcp

Usage

Provide an MCP server URL or stdio command.

import { MCPClient } from '@mastra/mcp';

const client = new MCPClient({
  servers: { docs: { url: new URL('https://example.com/mcp') } },
});
const tools = await client.listTools();

Documentation

Changelog

See the package changelog for version history and release notes.

Support

We have an open community Discord. Come and say hello and let us know if you have any questions or need any help getting things running.