fix(mcp): integrate managed contracts after rebase

This commit is contained in:
morluto
2026-07-16 19:52:35 +08:00
parent 6e6827cd76
commit 9c4a93d9b1
11 changed files with 350 additions and 173 deletions
+2 -12
View File
@@ -135,17 +135,12 @@ export const MANAGED_TOOL_CONTRACTS = [
},
{
name: "inspect_managed_members",
...toolContractMetadata("inspect_managed_members"),
description:
"Inspect bounded PE/CLI metadata members, signatures, method body IL hashes, exception regions, call edges, and field-access anchors without loading or executing target code. Metadata tokens are reported as build-local coordinates bound to the artifact SHA-256 and MVID.",
kind: "managed-provider",
inputSchema: managedMemberInputSchema,
outputSchema: memberOutputSchema,
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
examples: [
{
title: "Example inspect managed members request",
@@ -155,17 +150,12 @@ export const MANAGED_TOOL_CONTRACTS = [
},
{
name: "inspect_managed_native_boundaries",
...toolContractMetadata("inspect_managed_native_boundaries"),
description:
"Inspect PE/CLI ModuleRef, ImplMap/PInvoke declarations, CLI native-header indicators, and non-IL method implementation flags without loading or executing target code. Results are managed declarations and degraded native-boundary observations, not verified native exports or addresses.",
kind: "managed-provider",
inputSchema: managedNativeBoundaryInputSchema,
outputSchema: nativeBoundaryOutputSchema,
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
examples: [
{
title: "Example inspect managed/native boundary request",
+50 -16
View File
@@ -8,6 +8,36 @@ import {
MANAGED_RECONSTRUCTION_IMPORT_EXAMPLE,
MANAGED_RUNTIME_CORRELATION_EXAMPLE,
} from "./managedWorkflowExamples.js";
import { toolContractMetadata } from "./toolEffects.js";
const managedEvidenceIdSchema = z
.string()
.regex(/^ev_[a-f0-9]{64}$/u)
.describe("Session-owned inspect_managed_members Evidence ID");
/** MCP references for comparing two session-owned managed observations. */
export const compareManagedMembersReferenceInputSchema = z
.strictObject({
left_evidence_id: managedEvidenceIdSchema,
right_evidence_id: managedEvidenceIdSchema,
limits: compareManagedMembersInputSchema.shape.limits,
unknown_registry_approved:
compareManagedMembersInputSchema.shape.unknown_registry_approved,
})
.superRefine((input, context) => {
if (input.left_evidence_id === input.right_evidence_id)
context.addIssue({
code: "custom",
path: ["right_evidence_id"],
message: "Managed member Evidence must be distinct",
});
});
/** MCP reference for planning from one session-owned managed observation. */
export const managedRuntimeCorrelationReferenceInputSchema =
managedRuntimeCorrelationInputSchema
.omit({ static_members: true })
.extend({ static_members_evidence_id: managedEvidenceIdSchema });
const comparisonOutputSchema =
managedWorkflowOutputSchemas.compare_managed_members;
@@ -32,21 +62,21 @@ if (reconstructionOutputSchema === undefined)
export const MANAGED_WORKFLOW_TOOL_CONTRACTS = [
{
name: "compare_managed_members",
...toolContractMetadata("compare_managed_members"),
description:
"Compare two authenticated inspect_managed_members Evidence records using unique-only CIL/signature and structural method-shape tiers. Names are reported as observations but are not used as a matching basis; metadata tokens are remapped as build-local coordinates bound to each artifact SHA-256 and MVID.",
kind: "application",
inputSchema: compareManagedMembersInputSchema,
inputSchema: compareManagedMembersReferenceInputSchema,
outputSchema: comparisonOutputSchema,
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
examples: [
{
title: "Compare two managed member observations",
input: MANAGED_MEMBER_COMPARISON_EXAMPLE,
input: {
left_evidence_id: MANAGED_MEMBER_COMPARISON_EXAMPLE.left.evidence_id,
right_evidence_id:
MANAGED_MEMBER_COMPARISON_EXAMPLE.right.evidence_id,
limits: MANAGED_MEMBER_COMPARISON_EXAMPLE.limits,
},
},
],
},
@@ -72,22 +102,26 @@ export const MANAGED_WORKFLOW_TOOL_CONTRACTS = [
},
{
name: "plan_managed_runtime_correlation",
...toolContractMetadata("plan_managed_runtime_correlation"),
description:
"Prepare a separately authorized managed runtime-correlation admission plan from authenticated inspect_managed_members Evidence. The operation is default-disabled, requires the managed_runtime permission ceiling and grant, locks the exact artifact SHA-256, MVID, method signature, and normalized IL shape, distinguishes attach/load/debugger/reflection/instrumentation effects, and records that no target code was executed.",
kind: "application",
inputSchema: managedRuntimeCorrelationInputSchema,
inputSchema: managedRuntimeCorrelationReferenceInputSchema,
outputSchema: runtimeOutputSchema,
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
examples: [
{
title: "Plan an exact-build managed runtime correlation",
input: MANAGED_RUNTIME_CORRELATION_EXAMPLE,
input: {
static_members_evidence_id:
MANAGED_RUNTIME_CORRELATION_EXAMPLE.static_members.evidence_id,
method: MANAGED_RUNTIME_CORRELATION_EXAMPLE.method,
requested_effect:
MANAGED_RUNTIME_CORRELATION_EXAMPLE.requested_effect,
host: MANAGED_RUNTIME_CORRELATION_EXAMPLE.host,
bounds: MANAGED_RUNTIME_CORRELATION_EXAMPLE.bounds,
},
},
],
},
] as const satisfies readonly ToolContract[];
import { z } from "zod";
+4
View File
@@ -95,6 +95,10 @@ export const TOOL_EFFECTS: Readonly<Record<string, ToolEffects>> = {
inventory_artifact: evidence,
extract_artifact: effects({ mutatesSession: true, writesFilesystem: true }),
inspect_managed_artifact: evidence,
inspect_managed_members: evidence,
inspect_managed_native_boundaries: evidence,
compare_managed_members: sessionEvidence,
plan_managed_runtime_correlation: sessionEvidence,
list_browser_targets: browserEvidence,
inspect_web_page: browserEvidence,
analyze_web_bundle: browserEvidence,