feat(mcp)!: harden contracts and evidence references

BREAKING CHANGE: comparison tools now require session-owned Evidence IDs or approved bundle paths, and structured Evidence results use compact references.
This commit is contained in:
morluto
2026-07-16 19:49:58 +08:00
parent ad398a17f5
commit ee1cd40405
47 changed files with 1387 additions and 672 deletions
+9 -8
View File
@@ -22,6 +22,8 @@ import {
REA_WORKFLOW_PROVIDER,
workflowAnalysisProfile,
} from "../application/InvestigationProviders.js";
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
import { safeParseToolInput } from "./toolInputValidation.js";
/** Optional session services used by enhanced tool registration. */
export interface EnhancedToolRegistration {
@@ -69,12 +71,7 @@ const registerEnhancedTool = (
const name = enhancedToolNameSchema.parse(contract.name);
server.registerTool(
name,
{
description: contract.description,
inputSchema: contract.inputSchema,
outputSchema: contract.outputSchema,
annotations: contract.annotations,
},
toolRegistrationOptions(contract),
async (input, context) => {
const progress = mcpProgressReporter(context);
await progress.report({
@@ -83,9 +80,13 @@ const registerEnhancedTool = (
total: 1,
message: "started",
});
const parsedInput = jsonObjectSchema.parse(
enhancedInputSchemas[name].parse(input),
const validatedInput = safeParseToolInput(
enhancedInputSchemas[name],
input,
name,
);
if (!validatedInput.ok) return toCallToolResult(validatedInput, contract);
const parsedInput = jsonObjectSchema.parse(validatedInput.value);
const parameters: Record<string, JsonValue> = { ...parsedInput };
const result = await logToolExecution(registration.logger, name, () =>
services.execute(name, input, context.mcpReq.signal),