refactor(server): admit complete evidence workflows and share handlers
Validation: integrated changes passed formatting, typecheck, lint, resolved module-boundary verification and git diff --check. Tests and real-provider workflows were not run.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import type {
|
||||
ServerContext,
|
||||
CallToolResult,
|
||||
} from "@modelcontextprotocol/server";
|
||||
|
||||
import type { EvidenceMcpServer } from "./EvidenceMcpServer.js";
|
||||
import type { WithAdmittedAnalysis } from "./analysisAdmission.js";
|
||||
|
||||
/** Run one complete tool workflow inside session admission when supplied. */
|
||||
export const runAdmittedToolOperation = async (
|
||||
server: EvidenceMcpServer,
|
||||
admission: WithAdmittedAnalysis | undefined,
|
||||
operationName: string,
|
||||
signal: ServerContext["mcpReq"]["signal"],
|
||||
operation: () => Promise<CallToolResult>,
|
||||
): Promise<CallToolResult> => {
|
||||
if (admission === undefined) return operation();
|
||||
const admitted = await admission(operationName, signal, operation);
|
||||
return admitted.ok
|
||||
? admitted.value
|
||||
: server.delivery.toErrorToolResult(admitted.error);
|
||||
};
|
||||
Reference in New Issue
Block a user