guard_write_batch
Batch evaluate write permissions for up to 200 AnchorIDs. Returns per-item allowed or blocked decisions with conflict analysis to validate data safety before execution.
Instructions
Batch pre-write safety check for multiple AnchorIDs (max 200). Each item needs a client_ref for correlation. Returns per-item allowed/blocked decisions with reasons. Evaluation-only — never writes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| items | Yes | Array of guard/write requests |
Implementation Reference
- src/tools.ts:322-352 (registration)Tool registration for guard_write_batch - defines the tool name, description, and handler function
// ─── 9. guard_write_batch ───────────────────────────────────────── server.tool( "guard_write_batch", "Batch pre-write safety check for multiple AnchorIDs (max 200). " + "Each item needs a client_ref for correlation. Returns per-item " + "allowed/blocked decisions with reasons. Evaluation-only — never writes.", { items: z .array( z.object({ client_ref: z.string().describe("Your reference ID for correlation"), entity_id: z.string().describe("UUID of the AnchorID to evaluate"), min_confidence: z.number().min(0).max(1).optional(), require_no_conflicts: z.boolean().optional(), }), ) .max(200) .describe("Array of guard/write requests"), }, async (input) => { try { const data = await api.post( "/guard/write:batch", input as Record<string, unknown>, ); return jsonContent(data); } catch (e) { return errorContent(e); } }, ); - src/tools.ts:341-351 (handler)Handler function that executes the tool logic - makes POST request to /guard/write:batch endpoint
async (input) => { try { const data = await api.post( "/guard/write:batch", input as Record<string, unknown>, ); return jsonContent(data); } catch (e) { return errorContent(e); } }, - src/tools.ts:328-340 (schema)Zod schema definition for guard_write_batch input validation - defines the items array structure with up to 200 items
{ items: z .array( z.object({ client_ref: z.string().describe("Your reference ID for correlation"), entity_id: z.string().describe("UUID of the AnchorID to evaluate"), min_confidence: z.number().min(0).max(1).optional(), require_no_conflicts: z.boolean().optional(), }), ) .max(200) .describe("Array of guard/write requests"), }, - src/tools.ts:17-42 (helper)Helper utilities used by the handler - jsonContent formats API responses, errorContent formats errors with isError flag
/** Format the API response as MCP tool content. */ function jsonContent(data: unknown) { return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], }; } /** Format an error as MCP tool content (isError flag). */ function errorContent(err: unknown) { if (err instanceof ApiError) { const payload = { error: err.message, status_code: err.status_code, request_id: err.request_id, details: err.details, }; return { content: [{ type: "text" as const, text: JSON.stringify(payload, null, 2) }], isError: true, }; } return { content: [{ type: "text" as const, text: (err as Error).message ?? String(err) }], isError: true, }; }