mirror of
https://github.com/morluto/rea.git
synced 2026-10-28 18:35:53 +00:00
Forward Ghidra startup waiting observations through the existing progress reporter. Count emitted MCP status notifications and omit the unknown total to keep progress strictly increasing. Verified with focused tests, type/lint/docs checks, packaging and actual installed Windows timeout/recovery workflows. Native first-query speed and large-target memory remain open under #1065. Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import type { ServerContext } from "@modelcontextprotocol/server";
|
|
import type { ProgressReporter } from "../application/ProgressReporter.js";
|
|
import {
|
|
createProgressReporter,
|
|
silentProgressReporter,
|
|
} from "../application/ProgressReporter.js";
|
|
|
|
export interface McpProgressContext {
|
|
readonly mcpReq: Pick<ServerContext["mcpReq"], "_meta" | "notify">;
|
|
}
|
|
|
|
/** Adapt the request's negotiated MCP progress token to application progress. */
|
|
export const mcpProgressReporter = (
|
|
context: McpProgressContext,
|
|
): ProgressReporter => {
|
|
const token = context.mcpReq._meta?.progressToken;
|
|
if (token === undefined) return silentProgressReporter;
|
|
return createProgressReporter(
|
|
async (update) => {
|
|
try {
|
|
await context.mcpReq.notify({
|
|
method: "notifications/progress",
|
|
params: {
|
|
progressToken: token,
|
|
// Status phases can repeat their work count while waiting. The
|
|
// protocol requires every notification to advance; count emitted
|
|
// observations without inventing a total amount of analysis work.
|
|
progress: update.sequence,
|
|
message: `${update.phase}: ${update.message}`,
|
|
},
|
|
});
|
|
} catch (cause: unknown) {
|
|
// Progress is observational; transport failure cannot change tool truth.
|
|
void cause;
|
|
}
|
|
},
|
|
{ minimumIntervalMs: 100 },
|
|
);
|
|
};
|