Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
fix(mcp): keep analyze_function progress strictly increasing (#3460)
Peter3cfdc585b42c
diff --git a/src/server/registerEnhancedTools.ts b/src/server/registerEnhancedTools.tsindex 6efdcccdb..6176d47c3 100644--- a/src/server/registerEnhancedTools.ts+++ b/src/server/registerEnhancedTools.ts@@ -11,6 +11,7 @@ import type {import type { AnalysisOperationPort } from "../application/AnalysisProvider.js";import type { BinarySessionPort } from "../application/binary/BinarySessionPort.js";+import type { ProgressReporter } from "../application/ProgressReporter.js";import { EnhancedTools } from "../application/EnhancedTools.js";import type { ValidatedEnhancedCall } from "../application/EnhancedToolTypes.js";import {@@ -233,6 +234,7 @@ const executeEnhancedTool = async (return executeFunctionTool(admittedAnalysis, registration, contract, {context,parameters,+ progress,});const analysis: AnalysisOperationPort = {execute: (operation, operationParameters, executionOptions) =>@@ -316,10 +318,12 @@ const executeFunctionTool = async (request: {readonly context: ServerContext;readonly parameters: Readonly<Record<string, JsonValue>>;+ readonly progress: ProgressReporter;},): Promise<CallToolResult> => {- const { context, parameters } = request;- const progress = mcpProgressReporter(context);+ // Reuse the request reporter that already sent "started"; a second reporter+ // would restart the notification sequence at 1.+ const { context, parameters, progress } = request;const result = await logToolExecution(registration.logger,"analyze_function",diff --git a/tests/boundary/mcp/progressMcp.test.ts b/tests/boundary/mcp/progressMcp.test.tsindex 6c95b291a..9b471d75a 100644--- a/tests/boundary/mcp/progressMcp.test.ts+++ b/tests/boundary/mcp/progressMcp.test.ts@@ -2,9 +2,13 @@ import { Client, InMemoryTransport } from "@modelcontextprotocol/client";import { setTimeout as delay } from "node:timers/promises";import { describe, expect, it } from "vitest";-import type { AnalysisOperationPort } from "../../../src/application/AnalysisProvider.js";+import {+ createAnalysisExecution,+ type AnalysisOperationPort,+} from "../../../src/application/AnalysisProvider.js";+import { FUNCTION_COMPARISON_EXAMPLE } from "../../../src/contracts/functionComparisonExample.js";import { AnalysisCancelledError } from "../../../src/domain/analysisErrorCore.js";-import { err } from "../../../src/domain/result.js";+import { err, ok } from "../../../src/domain/result.js";import { createServer } from "../../../src/server/createServer.js";import { observed } from "../../fixtures/analysisExecution.js";@@ -61,6 +65,43 @@ describe("ordinary MCP progress and cancellation", () => {}});+ it("keeps analyze_function progress strictly increasing from start to completion", async () => {+ const analysis: AnalysisOperationPort = {+ execute: (operation) =>+ Promise.resolve(+ ok(+ createAnalysisExecution(+ operation === "analyze_function"+ ? FUNCTION_COMPARISON_EXAMPLE.left.normalized_result+ : "0x1000",+ { id: "fixture", name: "Fixture", version: "1" },+ ),+ ),+ ),+ };+ const server = createServer({ kind: "fixed", analysis });+ const client = new Client({ name: "function-progress-test", version: "1" });+ const [clientTransport, serverTransport] =+ InMemoryTransport.createLinkedPair();+ const progress: number[] = [];+ try {+ await server.connect(serverTransport);+ await client.connect(clientTransport);+ const result = await client.callTool(+ { name: "analyze_function", arguments: { procedure: "main" } },+ { onprogress: (update) => progress.push(update.progress) },+ );++ expect(result.isError).not.toBe(true);+ expect(progress.length).toBeGreaterThanOrEqual(2);+ progress.forEach((value, index) => {+ expect(value).toBeGreaterThan(progress[index - 1] ?? 0);+ });+ } finally {+ await Promise.allSettled([client.close(), server.close()]);+ }+ });+it("propagates client cancellation to the active provider request", async () => {let providerObservedCancellation = false;let markProviderStarted: (() => void) | undefined;