Skip to main content

MCP Servers Documentation

MCP Server Layer Overview

The MCP server layer exposes Mastra tool registries to Model Context Protocol clients. Each server is created by a source-owned factory and enters the runtime through the active artifact loaders, not through a single central composition array in src/mastra/mcp-servers/index.ts.

The current composition flow is:

src/mastra/mcp-servers/index.ts is a barrel export. It is not the active composition point.

Factories

Each factory returns a fresh MCPServer instance with a name, version, description, and tool registry:

export function createAdminMcpServer(): MCPServer {
return new MCPServer({
name: 'Admin MCP Server',
version: '1.0.0',
description: 'Restricted MCP surface that exposes admin-only tooling for prompts, overrides, and health checks.',
tools: adminTools,
});
}

Environment Flags

VariableEffect
MASTRA_SKIP_ADMIN_MCPDisable the Admin MCP server.
MASTRA_SKIP_K12_MCPDisable the K12 Safety MCP server.
MASTRA_SKIP_DOCS_MCPDisable global and scoped documentation MCP servers.
MASTRA_SKIP_DOCS_CHAT_WARMUPSkip docs-chat index warmup; does not disable MCP servers by itself.
MASTRA_INCLUDE_REASONING_ENGINEEnables Reasoning Engine agents/tools/workflows/MCP when set to true; read by env.includeReasoningEngine.

The audited environment schema supports MASTRA_TARGET values k12, tap, sdac, handbook, and all. It does not include a separate reasoning-engine target in that enum. Reasoning Engine MCP availability follows env.includeReasoningEngine.

Discovery And Transport

When runtime directory routes are enabled, the runtime exposes:

curl http://localhost:4111/mcp-servers.json

The source-backed route returns JSON metadata for registered MCP servers. The audited route factory does not expose a separate /mcp-servers HTML endpoint.

MCP transport paths are owned by the Mastra runtime/APIM deployment layer. Direct runtime paths use /api/mcp/{serverId}/mcp and /api/mcp/{serverId}/sse; testing APIM prefixes those paths with /ai. The 2026-06-23 smoke confirmed /ai/api/mcp/* transport reachability, while /ai/mcp-servers.json still returns 401 through APIM and should not be used as the Replit discovery source until registry auth is reconciled.

Server Inventory

ServerServer IDFactorySourceToolsGate
AdminadmincreateAdminMcpServer()src/mastra/mcp-servers/admin-server.ts11MASTRA_SKIP_ADMIN_MCP
K12 Safetyk12-safetycreateK12SafetyMcpServer()packages/domain-k12/src/mcp-server.ts28MASTRA_SKIP_K12_MCP
Reasoning Enginereasoning-enginecreateReasoningEngineMcpServer()src/mastra/mcp-servers/reasoning-engine-server.ts8MASTRA_INCLUDE_REASONING_ENGINE=true
DocsdocscreateDocsMcpServer()src/mastra/mcp-servers/docs-server.ts4MASTRA_SKIP_DOCS_MCP
K12 Docsk12-docscreateK12DocsMcpServer()src/mastra/mcp-servers/domain-docs-server.ts4MASTRA_SKIP_DOCS_MCP
SDAC Docssdac-docscreateSdacDocsMcpServer()src/mastra/mcp-servers/domain-docs-server.ts4MASTRA_SKIP_DOCS_MCP
TAP Docstap-docscreateTapDocsMcpServer()src/mastra/mcp-servers/domain-docs-server.ts4MASTRA_SKIP_DOCS_MCP
RE Docsreasoning-engine-docscreateReasoningEngineDocsMcpServer()src/mastra/mcp-servers/domain-docs-server.ts4MASTRA_SKIP_DOCS_MCP

Total source-backed tools across the listed runtime MCP servers: 67. The separate token-gated diagnostics MCP server exposes 9 additional tools, so the generated MCP inventory tracks 76 tools total when diagnostics is included.

Code Locations

  • Server factories: src/mastra/mcp-servers/** and packages/domain-k12/src/mcp-server.ts
  • Artifact loaders: src/mastra/artifacts/*.loader.ts and domain package loaders
  • Runtime merge point: apps/runtime/src/mastra-runtime.ts
  • Runtime registry route: packages/platform-runtime/src/server/routes/runtime-registries.routes.ts
  • Docs search tools: src/mastra/tools/docs-search/**
  • Diagnostics MCP adapter: packages/diagnostics-mcp/**
  • Validation notes: docs/internal/documentation-revival/mcp-docs-chat-validation.md

Next Steps