Skip to main content

Reasoning Engine MCP Server

Overview

The Reasoning Engine MCP Server exposes tools for multi-step analytical reasoning, including correlation analysis, temporal pattern detection, and domain-specific validation. In the current source, env.includeReasoningEngine reads MASTRA_INCLUDE_REASONING_ENGINE=true; when enabled, the Reasoning Engine artifact loader attaches this MCP server.

Server Metadata

PropertyValue
FactorycreateReasoningEngineMcpServer()
Sourcesrc/mastra/mcp-servers/reasoning-engine-server.ts
Version1.0.0
Tool Count8
GateMASTRA_INCLUDE_REASONING_ENGINE=true through env.includeReasoningEngine
Tool Registrysrc/mastra/tools/reasoning-engine/index.ts

Factory Implementation

// src/mastra/mcp-servers/reasoning-engine-server.ts
import { MCPServer } from '@mastra/mcp';
import { reasoningEngineTools } from '../tools/reasoning-engine/index.ts';

export const createReasoningEngineMcpServer = () =>
new MCPServer({
name: 'Reasoning Engine MCP Server',
version: '1.0.0',
description: 'Exposes the reasoning-engine tools such as the correlation tool.',
tools: reasoningEngineTools,
});

Tool Registry

All 8 tools are exported from src/mastra/tools/reasoning-engine/index.ts:

Tool IDDescription
reasoning-engine-orchestratorTop-level orchestrator that coordinates multi-step reasoning workflows
reasoning-engine-normalize-checkin-datasetNormalize and clean check-in datasets for analysis
reasoning-engine-multi-factor-correlationPerform multi-factor correlation analysis across data dimensions
reasoning-engine-temporal-analysisAnalyze temporal patterns and trends in time-series data
reasoning-engine-pattern-recognitionDetect recurring patterns and anomalies in structured data
reasoning-engine-domain-retrievalRetrieve domain-specific context and reference data
reasoning-engine-explanationGenerate human-readable explanations of analytical findings
reasoning-engine-validationValidate reasoning outputs against domain rules and constraints

Implementation Notes

Loader Behavior

src/mastra/config/env.ts exposes includeReasoningEngine, which reads MASTRA_INCLUDE_REASONING_ENGINE directly and returns true only for true. When enabled, src/mastra/artifacts/reasoning-engine.loader.ts returns the server:

const mcpServers = {
'reasoning-engine': createReasoningEngineMcpServer(),
};

Orchestrator Pattern

The reasoning-engine-orchestrator tool acts as a meta-tool that coordinates the other 7 tools in a multi-step reasoning pipeline. A typical orchestration flow:

The orchestrator determines which steps are needed based on the input data and reasoning request, then executes them in the appropriate order.

Target Gating

The audited MASTRA_TARGET schema supports k12, tap, sdac, handbook, and all. It does not include a separate reasoning-engine target in that enum. Reasoning Engine availability is controlled by MASTRA_INCLUDE_REASONING_ENGINE=true.

Database Dependencies

The Reasoning Engine tools use the REASONING schema in Azure SQL for:

  • Persisting reasoning session state
  • Storing step outputs in data_WorkflowStepOutputs
  • Recording task, step, and error logs when SQL logging is enabled

Domain retrieval does not cache to the reasoning schema in the committed implementation. It uses Perplexity-backed retrieval when configured and a local/stub fallback otherwise.

Code Locations

  • Server factory: src/mastra/mcp-servers/reasoning-engine-server.ts
  • Tool registry: src/mastra/tools/reasoning-engine/index.ts
  • Individual tools: src/mastra/tools/reasoning-engine/**
  • Tests: tests/shared/unit/mcp-servers/mcp-servers.test.ts (Reasoning Engine MCP Server describe block)