* refactor(config): parse capability settings into exact states * refactor(runtime): encode replay and process outcomes exactly * refactor: make analysis states unrepresentable * refactor(mcp): register canonical schemas with SDK * fix: preserve capability and catalog invariants * fix(build): remove stale compiled modules * fix(replay): update real verifier policy dependency * fix(package): verify the complete MCP catalog * fix(test): supply complete replay reload policy * refactor(contracts): centralize output schema lookup * refactor(mcp): delegate protocol boundaries to SDK * fix(browser): approve real source capture * fix(mcp): preserve catalog guidance
60 lines
2.4 KiB
TypeScript
60 lines
2.4 KiB
TypeScript
import type { McpServer } from "@modelcontextprotocol/server";
|
|
|
|
import { resolveCompareApplicationVersionsRequestValidated } from "../../application/ApplicationWorkflowEvidenceResolver.js";
|
|
import { compareApplicationVersionsEvidenceValidated } from "../../application/JavaScriptApplicationWorkflowService.js";
|
|
import { applicationToolContract } from "../../contracts/applicationToolContracts.js";
|
|
import { applicationVersionComparisonResultSchema } from "../../domain/javascriptApplicationVersionComparisonSchemas.js";
|
|
import { logToolExecution } from "../toolLogging.js";
|
|
import { toolRegistrationOptions } from "../toolRegistrationOptions.js";
|
|
import { toCallToolResult } from "../toolResult.js";
|
|
import { recordResult, recordSources } from "./helpers.js";
|
|
import type { ApplicationToolRegistration } from "./types.js";
|
|
|
|
const compareContract = applicationToolContract("compare_application_versions");
|
|
|
|
/** Register the provider-neutral JavaScript version comparison tool. */
|
|
export const registerCompareApplicationVersionsTool = (
|
|
server: McpServer,
|
|
options: ApplicationToolRegistration,
|
|
): void => {
|
|
server.registerTool(
|
|
compareContract.name,
|
|
toolRegistrationOptions(compareContract),
|
|
async (input) => {
|
|
const resolved = resolveCompareApplicationVersionsRequestValidated(
|
|
input,
|
|
options.evidenceLookup,
|
|
);
|
|
if (!resolved.ok) return toCallToolResult(resolved, compareContract);
|
|
const parsed = resolved.value;
|
|
const result = await logToolExecution(
|
|
options.logger,
|
|
compareContract.name,
|
|
() =>
|
|
Promise.resolve(compareApplicationVersionsEvidenceValidated(parsed)),
|
|
);
|
|
if (!result.ok) return toCallToolResult(result, compareContract);
|
|
const sources = [
|
|
parsed.left,
|
|
parsed.right,
|
|
...parsed.left_native_observations,
|
|
...parsed.right_native_observations,
|
|
];
|
|
const recorded = recordSources(options.recordEvidence, sources);
|
|
if (!recorded.ok) return toCallToolResult(recorded, compareContract);
|
|
const comparison = applicationVersionComparisonResultSchema.parse(
|
|
result.value.normalized_result,
|
|
);
|
|
const unknown = comparison.summary.unknown > 0;
|
|
return recordResult(
|
|
options,
|
|
compareContract,
|
|
result.value,
|
|
parsed.unknown_registry_approved === true && unknown
|
|
? "application-version-comparison"
|
|
: undefined,
|
|
);
|
|
},
|
|
);
|
|
};
|