FrontMCP vs Mastra's MCP server
Mastra is a TypeScript framework for building agents and the applications around them: agents with memory, a workflow engine, routing to many model providers, evals, tracing, a Studio UI and a server. Its @mastra/mcp package holds an MCP client and an MCP server, MCPServer, which exposes Mastra tools, agents and workflows to MCP clients. This page compares that server with FrontMCP: the same tool in both, the criteria of the comparison overview, and when each is the better choice. It doesn't compare Mastra's agent framework as a whole, which does much more than its MCP server.
This site documents FrontMCP, so read it knowing who wrote it. Every Mastra fact below comes from Mastra's documentation at mastra.ai and from the @mastra/mcp changelog, package.json and license at the 2.11.0 release tag, checked on 2026-12-01, and links to them. Every FrontMCP fact links to the page on this site that shows FrontMCP 1.15.2 doing it, or to how this was checked.
Quick answer
Choose Mastra's MCP server when you already build agents, workflows and tools in Mastra and want MCP clients to call them: one constructor turns each of them into an MCP tool, and the Mastra server's auth, Studio and tracing cover the MCP endpoint too. Choose FrontMCP over it when your clients speak MCP 2025-11-25 or earlier over stdio, or need sessions, sampling or roots, when you want FrontMCP to be the OAuth server, or when the MCP server is the product rather than a way into an agent application.
What Mastra's MCP server is
Mastra describes itself as a framework for building applications and agents in TypeScript (README). Its README lists model routing to more than 40 providers, agents, a graph-based workflow engine, suspend and resume for human input, memory, evals and observability, and MCP servers as one item among them (Why Mastra?). It's one monorepo, copyright Kepler Software, Inc. Content in directories named ee/ has its own enterprise license; everything else, packages/mcp included, is Apache-2.0 (LICENSE.md).
The MCP package is @mastra/mcp, first published on 2025-01-14. Version 2.0.0 came out on 2026-09-22, and 2.11.0, the version checked here, on 2026-11-25 (npm). It's built on v2 of the official SDK: its package.json pins @modelcontextprotocol/server, client and core 2.4.0 and depends on @modelcontextprotocol/ext-apps for MCP Apps (package.json). It needs @mastra/core 1.83 or later and zod 4.2 or later as peer dependencies, and Node 22.13.0 or later (engines).
Version 2.0.0 "rebuilt @mastra/mcp on the MCP 2026-07-28 revision. Servers serve that revision only, and every request is self-contained: there is no initialize handshake, session header, ping, or standalone HTTP+SSE transport" (CHANGELOG). It removed sessions, the SSE transport, roots and sampling (CHANGELOG). Version 2.6.0 added legacy: 'stateless', which answers 2025-era clients over HTTP without a session; the default, 'reject', still turns them away (CHANGELOG).
A Mastra application can serve MCP in two ways. An MCPServer you define serves the tools, agents and workflows you list, with your own resources and prompts, over stdio or HTTP; registered on the Mastra instance, it's served at /api/mcp/:serverId/mcp (Expose a Mastra MCP server). The Mastra server also has a built-in endpoint at /api/mcp that exposes every agent, workflow and tool of the application, through the same auth and permission checks as its HTTP API (Built-in MCP server). This page compares MCPServer.
On 2026-12-01, the mastra-ai/mastra repository, the whole of Mastra, had 29,929 GitHub stars (GitHub API), and npm counted 1,170,458 downloads of @mastra/mcp in the week of 2026-11-23 to 2026-11-29 (npm API). That count includes every application that uses the package as an MCP client, and doesn't separate client use from server use. FrontMCP had 154 stars and 12,061 downloads of @frontmcp/sdk in the same week.
The same tool in both
One tool, add, that takes two numbers and returns their sum, called with { "a": 2, "b": 3 }.
In Mastra
This follows the MCPServer reference: a tool made with createTool() from @mastra/core, listed in the server's tools, served with startStdio() or, inside a Node HTTP server, with startHTTP(). We ran it with @mastra/mcp 2.11.0, @mastra/core 1.86.0, zod 4.6.7 and tsx 4.23.15, in a project with "type": "module":
import http from "node:http";
import { createTool } from "@mastra/core/tools";
import { MCPServer } from "@mastra/mcp";
import { z } from "zod";
const add = createTool({
id: "add",
description: "Add two numbers",
inputSchema: z.object({ a: z.number(), b: z.number() }),
execute: async ({ a, b }) => String(a + b),
});
const server = new MCPServer({
id: "calc",
name: "Calculator",
version: "1.0.0",
tools: { add },
});
if (process.env.PORT) {
const port = Number(process.env.PORT);
http
.createServer(async (req, res) => {
await server.startHTTP({
url: new URL(req.url || "", `http://localhost:${port}`),
httpPath: "/mcp",
req,
res,
});
})
.listen(port);
} else {
await server.startStdio();
}npx tsx server.ts serves it over stdio, and PORT=3207 npx tsx server.ts at http://localhost:3207/mcp. Mastra's own client, MCPClient from the same package, started one over stdio, connected to the other over HTTP and called add on both:
import { MCPClient } from "@mastra/mcp";
const mcp = new MCPClient({
servers: {
overStdio: { command: "npx", args: ["tsx", "server.ts"] },
overHttp: { url: new URL("http://127.0.0.1:3207/mcp") },
},
});
const tools = await mcp.listTools();
console.log("stdio", JSON.stringify(await tools.overStdio_add.execute({ a: 2, b: 3 })));
console.log("http", JSON.stringify(await tools.overHttp_add.execute({ a: 2, b: 3 })));
await mcp.disconnect();stdio {"_meta":{"io.modelcontextprotocol/serverInfo":{"name":"Calculator","version":"1.0.0"}},"content":[{"type":"text","text":"5"}],"isError":false}
http {"_meta":{"io.modelcontextprotocol/serverInfo":{"name":"Calculator","version":"1.0.0"}},"content":[{"type":"text","text":"5"}],"isError":false}
Both connections used MCP 2026-07-28. A client that opens with initialize, as clients on 2025-11-25 and earlier do, got -32022 Unsupported protocol version for every older revision, over stdio and over HTTP (with status 400), as the docs say for the default legacy: 'reject' (MCPServer options). With legacy: "stateless" added to the constructor, the HTTP server answered initialize for 2024-11-05 to 2025-11-25 and returned 5, without an Mcp-Session-Id. Over stdio the option changed nothing: the older revisions still got -32022. The docs describe legacy for HTTP requests only.
In FrontMCP
The same tool, in a one-app FrontMCP server. The Playground runs it and calls add; the Tests tab runs the checks below it.
import { App, FrontMcp, Tool, ToolContext, z } from "@frontmcp/sdk";
@Tool({
name: "add",
description: "Add two numbers",
inputSchema: { a: z.number(), b: z.number() },
})
export class Add extends ToolContext {
async execute({ a, b }: { a: number; b: number }) {
return { sum: a + b };
}
}
@App({ id: "calc", name: "Calculator", tools: [Add] })
export class CalcApp {}
@FrontMcp({ info: { name: "calc", version: "1.0.0" }, apps: [CalcApp] })
export default class Server {}Starting FrontMCP in your browser…
FrontMCP starts when this example comes into view.
Mastra declares a tool with a function call and lists it in the server; FrontMCP declares a class and lists it in an app, which the server lists. A Mastra tool that returns a string sends it as text; FrontMCP's returns an object, which arrives as structuredContent with a text copy (Your First Tool). FrontMCP needs Node 24 or later and TypeScript's decorator settings (Installation), and frontmcp dev runs it. On 2026-12-01, npm install @mastra/mcp@2.11.0 added 156 packages, including the peer dependencies npm installs with it, @mastra/core 1.86.0 and zod 4.6.7; npm install @frontmcp/sdk@1.14.0 added 128.
Side by side
Mastra MCPServer (@mastra/mcp 2.11.0) | FrontMCP 1.15.2 | |
|---|---|---|
| MCP revisions served | 2026-07-28; legacy: 'stateless' adds 2024-11-05 to 2025-11-25 over HTTP, without sessions (MCPServer options). Over stdio, only 2026-07-28 in our run, with or without it | 2024-11-05 to 2026-07-28 over Streamable HTTP and stdio (except 2026-07-28 on stdio servers with Claude Code channels), with a session for the older four (Protocol versions) |
| Declaring a tool | createTool({ id, inputSchema, execute }) from @mastra/core, listed in tools; agents become ask_<key> tools and workflows run_<key> tools (Constructor, Exposing agents as tools) | A @Tool class, or the tool() function, listed in an @App |
| Schemas | Standard JSON Schema: Zod, Valibot, ArkType; advertised as JSON Schema 2020-12, and outputSchema checked before a result is sent (createTool(), Tool schemas) | Zod 4; outputSchema checks every result (Schemas Are Contracts, Shaping Tool Results) |
| Shared services | No container documented. Tools get a requestContext "for accessing shared state and dependencies", and context.mcp with the caller's auth (createTool() parameters, MCP context) | @Provider services, read with this.get(); hooks and plugins |
| Auth | createOAuthMiddleware in front of startHTTP(): protected-resource metadata, 401 challenges, and a static, introspection or custom token check (OAuth protection). On a Mastra server, its server.auth providers, RBAC and fine-grained authorization; "Mastra doesn't act as an authorization server" (Built-in MCP server, Authentication guide) | Five modes: public, static keys, JWTs from your identity provider, and FrontMCP as the OAuth server, with its own sign-in page or an upstream provider's (Auth modes); per-entry rules (Authorities) |
| Asking the client for input | A tool calls context.suspend() and declares a resumeSchema; the server answers input_required and runs the tool again with the answer, for 2026-07-28 clients (Asking the caller for input); sampling and roots were removed in 2.0 (Migration) | this.elicit(), which becomes input_required for 2026-07-28 clients; this.sample() and this.listRoots() for clients that offer them |
| Testing | Studio lists MCP servers and their tools and runs tools; executeTool() runs a tool without a protocol client; evals score agents and workflows; no MCP test library documented (Studio, executeTool(), Evals) | @frontmcp/testing with MCP matchers, run by frontmcp test (Testing) |
| Resources, prompts, completions | Resources and templates, prompts, with change notifications; completion not documented (Resource handling, Prompt handling) | Resources and templates, prompts, completion of template parameters (@Resource, @Prompt, completers) |
| Agents, jobs, workflows, tasks | Mastra agents and workflows served as tools; tools, agents and workflows as MCP tasks, experimental (Exposing agents as tools, Tasks) | @Agent, @Job, @Workflow; background tasks |
| Widgets (MCP Apps) | appResources: ui:// HTML apps through @modelcontextprotocol/ext-apps, rendered by MCP Apps hosts and in Mastra Studio; appsRequireClientSupport hides them from other clients (MCP Apps, Build MCP Apps) | A tool's ui option, for MCP Apps hosts and the OpenAI Apps SDK (Tool UI, Hosts) |
| Transports | stdio; Streamable HTTP, stateless, through startHTTP() with Node request and response objects (startHTTP()); the HTTP+SSE transport was removed in 2.0 (Migration) | Streamable HTTP with or without sessions, the older HTTP+SSE, stdio, a Unix socket, in-memory (FrontMcpInstance, transport) |
| Runtimes and deployment | Node 22.13+; a registered server runs in the Mastra server, built with mastra build, with deployers for Vercel, Netlify and Cloudflare, or on Mastra platform's Server (Deploy); startHTTP() on serverless platforms through a fetch-to-Node adapter (startHTTP()) | Node 24+; frontmcp build targets for Node, Vercel, AWS Lambda, Cloudflare Workers and a browser module (Production build); @frontmcp/edge for Cloudflare Workers with Durable Object sessions; a fetch handler for other runtimes (createFetchHandler()) |
| CLI | create-mastra; mastra dev with Studio, build, start, server deploy, and mastra api mcp tool execute (mastra CLI); npx @mastra/mcp generate writes types for the client (Generate types) | frontmcp create, dev, build, test, inspector (CLI); an Nx plugin |
| License | Apache-2.0; the repository's ee/ directories, which don't include packages/mcp, have their own license (LICENSE.md) | Apache-2.0 |
What each does that the other doesn't
What Mastra documents, or did in our run, and this site doesn't show for FrontMCP:
- An agent framework around the server. Agents with memory, a workflow engine with branching, parallel steps and suspend and resume, model routing across many providers, evals and observability, and Studio to try them. An agent or workflow built there becomes an MCP tool when you add it to
agentsorworkflows. FrontMCP's agents run a model loop with adapters for two model providers (Connecting a Real Model), and its workflows chain jobs. - A built-in MCP endpoint at
/api/mcpthat serves every agent, workflow and tool of a Mastra application, filtered per caller by the same permissions as its HTTP API, for 2026-07-28 and 2025-era clients (Built-in MCP server). We didn't run it. - An MCP client in the same package.
MCPClientgives Mastra agents the tools of other MCP servers over stdio or HTTP (Connect to MCP servers). FrontMCP'sconnect()adapters connect to your own server, in-process. - A choice of schema library through Standard JSON Schema: Zod, Valibot or ArkType (
createTool()). FrontMCP's pages use Zod 4 only. - Input rounds that resume on any instance. The state of an
input_requiredround travels signed in the request, so every instance that shares the key can answer it (Continuation state). - Traces of MCP requests in Mastra's observability, linked to the trace of the agent or workflow on the client that made the call (Tracing).
What FrontMCP does that Mastra's MCP docs don't document, or list as removed:
- Clients on 2025-11-25 and earlier, over stdio and with sessions. Mastra's
MCPServerserved only 2026-07-28 over stdio in our run, and answers older HTTP clients without a session whenlegacy: 'stateless'is set. FrontMCP serves all five revisions over both transports, and keeps sessions for older clients, in Redis if you like. - Requests from the server to the client:
this.sample()andthis.listRoots(), which Mastra removed in 2.0 (Migration). - An OAuth server. Mastra's docs say it "doesn't act as an authorization server". FrontMCP can issue the tokens itself, with its own sign-in page and your check of the user, or after a sign-in at an upstream provider (Local auth, Remote and proxied auth).
- A dependency container: providers with scopes, which tools, resources and prompts get with
this.get(). - A test library with MCP matchers and fixtures (Testing Your Server).
- Completion of resource template parameters (completers).
- The older HTTP+SSE transport and a Unix socket (
FrontMcpInstance).
Both expose agents as tools (Mastra's ask_<key>, FrontMCP's invoke_<name>), serve MCP Apps widgets, run tools as MCP tasks (experimental in Mastra), and publish events through the draft SEP-3415 extension (Mastra, experimental; FrontMCP). Both can serve the tools of other MCP servers (Mastra, FrontMCP).
When to choose Mastra's MCP server
- You already build agents, workflows and tools in Mastra and want Cursor, VS Code or another MCP client to call them: list them in an
MCPServer, or turn on the built-in/api/mcpendpoint, without rewriting them. - You want an agent framework with memory, workflows, model routing, evals, Studio and tracing, and MCP as one way into it, behind the same auth, RBAC and fine-grained authorization as your HTTP API.
- Your clients speak MCP 2026-07-28, or answering older HTTP clients without a session is enough.
- You also want an MCP client for your agents, from the same package, or Valibot or ArkType rather than Zod.
- You want the more widely used of the two today: in the week of 2026-11-23 to 2026-11-29, npm counted 1,170,458 downloads of
@mastra/mcpand 12,061 of@frontmcp/sdk, though the first figure includes its client use.
When to choose FrontMCP
- Your clients use MCP 2025-11-25 or earlier over stdio, or need a session: a server that asks them for sampling or roots, or several instances that share sessions.
- You want FrontMCP to be the OAuth server, rather than relying on an identity provider.
- The MCP server is the product, and you want shared services, several apps, hooks, plugins and a test library to organise it (Structuring a Server), without an agent framework around it.
- You want completions, the older HTTP+SSE transport, a Unix socket, or a build that runs the server in the browser (Production build).
How this was checked
On 2026-12-01 we installed @mastra/mcp 2.11.0 with @mastra/core 1.86.0, zod 4.6.7 and tsx 4.23.15, on Node 24.22.1 and npm 11.19.1, ran the server above over stdio and Streamable HTTP, and called add with MCPClient from @mastra/mcp 2.11.0. We then sent each server an initialize request for every MCP revision from 2024-11-05 to 2025-11-25, and the 2026-07-28 server/discover and tools/call requests, with the MCP-Protocol-Version: 2026-07-28 header and the revision in _meta. Over both transports, server/discover listed only 2026-07-28 in supportedVersions and the 2026-07-28 call returned 5; the four older revisions got -32022. With legacy: "stateless", the four older revisions were answered over HTTP without an Mcp-Session-Id and returned 5, and still got -32022 over stdio. We didn't run a server registered on a Mastra instance, the built-in /api/mcp endpoint, Studio or a deployment.
FrontMCP serves all five revisions over Streamable HTTP and stdio, except stdio servers with Claude Code channels, which decline 2026-07-28. Its stdio router returns discovery and resultType results for 2026-07-28, and keeps initialize sessions for older clients. The overview describes the method for every library.