refactor(mcp): make analysis states unrepresentable (#468)
* 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
This commit is contained in:
@@ -2,16 +2,12 @@ import type { McpServer } from "@modelcontextprotocol/server";
|
||||
|
||||
import { runControlledReplayValidated } from "../../application/JavaScriptReplayService.js";
|
||||
import { applicationToolContract } from "../../contracts/applicationToolContracts.js";
|
||||
import {
|
||||
controlledReplayInputSchema,
|
||||
controlledReplayOutputSchema,
|
||||
} from "../../domain/javascriptReplay.js";
|
||||
import { parseEvidence } from "../../domain/evidence.js";
|
||||
import { logToolExecution } from "../toolLogging.js";
|
||||
import { toCallToolResult } from "../toolResult.js";
|
||||
import { toolRegistrationOptions } from "../toolRegistrationOptions.js";
|
||||
import { safeParseToolInput } from "../toolInputValidation.js";
|
||||
import { controlledReplayOutputSchema } from "../../domain/javascriptReplay.js";
|
||||
import { mcpProgressReporter } from "../mcpProgress.js";
|
||||
import { logToolExecution } from "../toolLogging.js";
|
||||
import { toolRegistrationOptions } from "../toolRegistrationOptions.js";
|
||||
import { toCallToolResult } from "../toolResult.js";
|
||||
import { recordSources } from "./helpers.js";
|
||||
import type { ApplicationToolRegistration } from "./types.js";
|
||||
|
||||
@@ -26,25 +22,18 @@ export const registerControlledReplayTool = (
|
||||
replayContract.name,
|
||||
toolRegistrationOptions(replayContract),
|
||||
async (input, context) => {
|
||||
const parsedInput = safeParseToolInput(
|
||||
controlledReplayInputSchema,
|
||||
input,
|
||||
replayContract.name,
|
||||
);
|
||||
if (!parsedInput.ok) return toCallToolResult(parsedInput, replayContract);
|
||||
const parsed = parsedInput.value;
|
||||
const result = await logToolExecution(
|
||||
options.logger,
|
||||
replayContract.name,
|
||||
() =>
|
||||
runControlledReplayValidated(options.replay, parsed, {
|
||||
runControlledReplayValidated(options.replay, input, {
|
||||
signal: context.mcpReq.signal,
|
||||
progress: mcpProgressReporter(context),
|
||||
}),
|
||||
);
|
||||
if (!result.ok) return toCallToolResult(result, replayContract);
|
||||
const output = controlledReplayOutputSchema.parse(result.value);
|
||||
if (output.evidence !== null) {
|
||||
if (output.phase === "execute") {
|
||||
const sourcesRecorded = recordSources(
|
||||
options.recordEvidence,
|
||||
output.source_evidence.map((item) => parseEvidence(item)),
|
||||
@@ -59,7 +48,7 @@ export const registerControlledReplayTool = (
|
||||
}
|
||||
return toCallToolResult(result, replayContract, {
|
||||
evidenceResourcesAvailable:
|
||||
output.evidence !== null && options.recordEvidence !== undefined,
|
||||
output.phase === "execute" && options.recordEvidence !== undefined,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user