docs/src/content/en/guides/migrations/upgrade-to-v1/mcp.mdx
MCP (Model Context Protocol) tool execution context has been reorganized, and deprecated client classes have been removed.
getMCPServers to listMCPServersThe mastra.getMCPServers() method has been renamed to mastra.listMCPServers(). This change aligns with the naming convention used across the API where plural getter methods use the list prefix.
To migrate, replace all calls to mastra.getMCPServers() with mastra.listMCPServers().
- const servers = await mastra.getMCPServers();
+ const servers = await mastra.listMCPServers();
:::tip[Codemod]
You can use Mastra's codemod CLI to update your code automatically:
npx @mastra/codemod@latest v1/mastra-plural-apis .
:::
getTools to listToolsThe mcp.getTools() method has been renamed to mcp.listTools(). This change aligns with the naming convention used across the API where plural getter methods use the list prefix.
To migrate, replace all calls to mcp.getTools() with mcp.listTools().
- const tools = await mcp.getTools();
+ const tools = await mcp.listTools();
:::tip[Codemod]
You can use Mastra's codemod CLI to update your code automatically:
npx @mastra/codemod@latest v1/mcp-get-tools .
:::
getToolsets to listToolsetsThe mcp.getToolsets() method has been renamed to mcp.listToolsets(). This change aligns with the naming convention used across the API where plural getter methods use the list prefix.
To migrate, replace all calls to mcp.getToolsets() with mcp.listToolsets().
- const toolsets = await mcp.getToolsets();
+ const toolsets = await mcp.listToolsets();
:::tip[Codemod]
You can use Mastra's codemod CLI to update your code automatically:
npx @mastra/codemod@latest v1/mcp-get-toolsets .
:::
Context properties in MCP tools are now organized under the context.mcp namespace. This change provides better organization and clearer API surface for MCP-specific functionality.
To migrate, access MCP-specific properties like elicitation and extra through context.mcp instead of directly from the context parameter.
createTool({
id: 'account-balance',
- execute: async ({ context, elicitation, extra }) => {
- await checkAuth(extra.authInfo);
- const result = await elicitation.sendRequest({
- message: `Is it ok to fetch account ${context.accountId}?`,
- });
- },
+ execute: async (inputData, context) => {
+ await checkAuth(context?.mcp?.extra.authInfo);
+ const result = await context?.mcp?.elicitation.sendRequest({
+ message: `Is it ok to fetch account ${inputData.accountId}?`,
+ });
+ },
});
The MastraMCPClient and related deprecated APIs have been removed from @mastra/mcp. This change consolidates on the new MCP client API.
To migrate, use the new MCPClient class instead of deprecated classes.
- import { MastraMCPClient, MCPConfiguration } from '@mastra/mcp/client';
+ import { MCPClient } from '@mastra/mcp/client';
- const client = new MastraMCPClient({ ... });
- const config = new MCPConfiguration({ ... });
+ const client = new MCPClient({ ... });