fix(mcp): isolate optional observation adapter failures (#838)

This commit is contained in:
N0zoM1z0
2026-10-07 11:45:17 +08:00
committed by GitHub
parent 78f4848d70
commit be3cfbffdf
31 changed files with 741 additions and 102 deletions
+11 -12
View File
@@ -2,25 +2,16 @@ import type { StdioServerHandle } from "@modelcontextprotocol/server/stdio";
import type { BinarySession } from "../application/BinarySession.js";
import type { Logger } from "../logger.js";
import {
createServer,
type CreateServerOptions,
} from "../server/createServer.js";
import { createServer } from "../server/createServer.js";
import type { RuntimeDependencies } from "./types.js";
import type { OptionalProviderLoadResult } from "../application/OptionalObservationProviders.js";
import {
MCP_CONNECTION_LOST,
MCP_CONNECTION_START_FAILED,
} from "./messages.js";
/** Optional adapters whose absence must not prevent the core MCP server. */
export type OptionalProviders = Pick<
CreateServerOptions,
| "browserObservation"
| "browserScenarioCapture"
| "electronObservation"
| "electronActiveObservation"
| "javascriptRuntimeObservation"
>;
export type OptionalProviders = OptionalProviderLoadResult;
interface ServerContext {
readonly logger: Logger;
@@ -51,6 +42,14 @@ export const startMcpTransport = async (
"Optional MCP providers could not load; affected tools remain unavailable",
);
}
for (const failure of Object.values(
optionalProviders.optionalProviderLoadFailures ?? {},
)) {
serverLogger.warn(
{ providerId: failure.providerId, error: failure.reason },
"Optional MCP adapter could not load; its peers remain available",
);
}
let handle: StdioServerHandle;
try {
handle = dependencies.serve(