Files
reverse-engineering-anything/src/server/toolLogging.ts
T
morlutoandCursor Agent 93295c3df3 fix(mcp): report selection after failed target opens (#8726)
* fix(mcp): report selection after failed target opens

* fix(mcp): retain resource root selection in open failures

* test(session): assert selection during cleanup failures

* test(mcp): delay failed open response across target switch

* test(session): distinguish no selection from pending cleanup

* test(session): assert selections during cleanup and cancellation

* test(mcp): join the failed-open gate before restoring its spy

The snapshot-switch gate waited only on its acknowledgement, so a request
that settled early hung until the runner timeout, and a later assertion
failure restored the spy while that request was still in flight. Race the
acknowledgement and join the launched open in finally before mockRestore.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-11-05 03:34:03 +08:00

24 lines
662 B
TypeScript

import type { Result } from "../domain/result.js";
import type { Logger } from "pino";
/** Log one MCP tool's duration and status without recording caller input. */
export const logToolExecution = async <
Outcome extends Result<unknown, unknown>,
>(
logger: Logger,
tool: string,
execute: () => Promise<Outcome>,
): Promise<Outcome> => {
const startedAt = performance.now();
const result = await execute();
logger[result.ok ? "info" : "warn"](
{
tool,
durationMs: Math.round((performance.now() - startedAt) * 100) / 100,
status: result.ok ? "ok" : "error",
},
"MCP tool execution completed",
);
return result;
};