Forward enabled MCP server configuration through AI session creation and validation paths. - Resolve and materialize effective MCP servers with secret values at runtime for triage, execution, review, merge, evaluation, reflection, mission validation, and dashboard chat/planning lanes. - Add runtime support guards, Claude CLI MCP config generation, and a dashboard validation route for MCP server reachability probes. - Cover MCP forwarding, provider support behavior, settings resolution, validation, and pi extension config generation with targeted tests and docs. Files changed: .changeset/fn-7023-mcp-runtime-forwarding.md | 7 + docs/agents.md | 2 + docs/secrets.md | 1 + docs/settings-reference.md | 6 +- .../src/__tests__/mcp-lane-forwarding.test.ts | 79 +++++++++++ .../src/__tests__/mcp-validate-route.test.ts | 111 ++++++++++++++++ packages/dashboard/src/chat.ts | 3 + packages/dashboard/src/planning.ts | 5 + packages/dashboard/src/routes.ts | 90 ++++++++++++- .../src/__tests__/mcp-lane-forwarding.test.ts | 95 ++++++++++++++ .../engine/src/__tests__/mcp-resolution.test.ts | 104 +++++++++++++++ .../src/__tests__/mcp-runtime-support.test.ts | 44 +++++++ .../src/__tests__/mcp-validation-service.test.ts | 69 ++++++++++ packages/engine/src/__tests__/pi.test.ts | 65 +++++++++ packages/engine/src/agent-reflection.ts | 3 + packages/engine/src/agent-runtime.ts | 36 ++++- packages/engine/src/agent-session-helpers.ts | 2 + packages/engine/src/evaluator.ts | 3 + packages/engine/src/executor.ts | 14 ++ packages/engine/src/index.ts | 3 + packages/engine/src/mcp-resolution.ts | 81 ++++++++++++ packages/engine/src/mcp-runtime-support.ts | 41 ++++++ packages/engine/src/mcp-validation-service.ts | 146 +++++++++++++++++++++ packages/engine/src/merger-ai.ts | 5 + packages/engine/src/merger.ts | 14 ++ packages/engine/src/mission-execution-loop.ts | 3 + packages/engine/src/pi.ts | 44 +++++-- packages/engine/src/reviewer.ts | 3 + packages/engine/src/runtime-resolution.ts | 8 +- packages/engine/src/step-session-executor.ts | 6 +- packages/engine/src/triage.ts | 5 + packages/pi-claude-cli/index.ts | 20 ++- packages/pi-claude-cli/src/mcp-config.ts | 65 ++++++++- 33 files changed, 1150 insertions(+), 33 deletions(-) Fusion-Task-Id: FN-7023 Fusion-Task-Lineage: ea09c6c7-b3c3-4af6-9ca6-0ebbfec17139
42 lines
1.8 KiB
TypeScript
42 lines
1.8 KiB
TypeScript
import { MOCK_PROVIDER_ID } from "@fusion/core";
|
|
import { createLogger } from "./logger.js";
|
|
|
|
const mcpRuntimeLog = createLogger("mcp-runtime");
|
|
const SUPPORTED_RUNTIME_IDS = new Set(["pi", "default-pi", "claude", "claude-code", "claude-acp", "acp"]);
|
|
|
|
function normalizeId(value: string | undefined): string {
|
|
return value?.trim().toLowerCase() ?? "";
|
|
}
|
|
|
|
/**
|
|
* FNXC:McpConfig 2026-06-25-21:35:
|
|
* MCP server definitions may contain materialized secrets by the time they reach runtime forwarding, so support decisions must be pure and content-free. Only known MCP-capable pi/Claude/ACP runtimes receive servers; mock and unknown runtimes skip forwarding without inspecting or logging server definitions.
|
|
*/
|
|
export function runtimeSupportsMcp(runtimeId: string | undefined, provider?: string): boolean {
|
|
if (normalizeId(provider) === MOCK_PROVIDER_ID) return false;
|
|
const normalizedRuntimeId = normalizeId(runtimeId);
|
|
if (!normalizedRuntimeId) return false;
|
|
if (SUPPORTED_RUNTIME_IDS.has(normalizedRuntimeId)) return true;
|
|
// Vendor/plugin runtime ids often include their transport family in a prefix/suffix; keep this content-free fuzzy match so future Claude/ACP runtimes do not need to expose server definitions to prove support.
|
|
return normalizedRuntimeId.includes("claude") || normalizedRuntimeId.includes("acp");
|
|
}
|
|
|
|
export interface McpForwardingSkipDetails {
|
|
runtimeId?: string;
|
|
provider?: string;
|
|
skippedCount: number;
|
|
lane?: string;
|
|
}
|
|
|
|
export function logMcpForwardingSkipped(details: McpForwardingSkipDetails): void {
|
|
if (details.skippedCount <= 0) return;
|
|
mcpRuntimeLog.log(JSON.stringify({
|
|
event: "mcp.forwarding.skipped",
|
|
reason: "unsupported-runtime",
|
|
runtimeId: details.runtimeId ?? null,
|
|
provider: details.provider ?? null,
|
|
lane: details.lane ?? null,
|
|
skippedCount: details.skippedCount,
|
|
}));
|
|
}
|