mirror of
https://github.com/morluto/rea.git
synced 2026-12-02 11:33:10 +00:00
* fix(setup): report Mastra Code's MASTRACODE_DISABLE_MCP switch Mastra Code reads MASTRACODE_DISABLE_MCP at startup and stops loading every MCP source. REA's client table has no such fact, so doctor kept reporting ~/.mastracode/mcp.json as aligned while Mastra started no server, and setup rewrote a registration the running client ignores. readClientPolicyBlock now answers for mastracode through a small module of its own. The value is truthy only for 1/true/yes/on, case-insensitively and after trimming, matching Mastra Code's isTruthyEnv. Doctor, setup's inspect/configure and mcp add pass the launcher environment they already resolve, so a supplied environment decides the outcome instead of the host process.env. The documented load order also lists the project .mcp.json, which this change does not read yet; #15038 stays open for that half. Tests: mastracodePolicySources (13, new) covers the value table; mastracodeDisabledRegistration (2, new) covers status, setup refusal and an unchanged file; geminiPolicySources (4) and setupPolicySnapshot (7) still pass. check:fast is green across 3328 files. The CLI boundary suite mcpAddClientPolicy needs a compiled dist/cli-runtime and was not run. Refs #15038 (cherry picked from commit 4e5ea523f4a4c3040c7d172758558fb6a0241966) * fix(setup): enforce the Mastra flag for project MCP registration * style(test): format Mastra MCP regression * test(doctor): prove the Mastra disable policy gates a valid launcher --------- Co-authored-by: 2SinceJuly <202121119+2SinceJuly@users.noreply.github.com>
21 lines
957 B
TypeScript
21 lines
957 B
TypeScript
export const MASTRACODE_DISABLE_MCP = "MASTRACODE_DISABLE_MCP";
|
|
|
|
// Mastra Code reads the switch with the same truthy set for its other
|
|
// MASTRACODE_DISABLE_* variables, so "0" and "false" leave MCP enabled.
|
|
const truthy = new Set(["1", "true", "yes", "on"]);
|
|
|
|
export const mastracodeMcpDisabled = (
|
|
environment: Readonly<NodeJS.ProcessEnv>,
|
|
): boolean => {
|
|
const value = environment[MASTRACODE_DISABLE_MCP]?.trim().toLowerCase();
|
|
return value !== undefined && truthy.has(value);
|
|
};
|
|
|
|
/** Why Mastra Code will start no MCP server despite the saved registration. */
|
|
export const mastracodeMcpDisabledPolicy = (
|
|
environment: Readonly<NodeJS.ProcessEnv>,
|
|
): string | undefined =>
|
|
mastracodeMcpDisabled(environment)
|
|
? `${MASTRACODE_DISABLE_MCP} turns off every MCP source in Mastra Code, so this registration is not loaded in an environment that sets it. Unset ${MASTRACODE_DISABLE_MCP} or set it to 0, then restart Mastra Code.`
|
|
: undefined;
|