guard_write
Evaluate whether to allow proposed writes by verifying AnchorID existence, confidence thresholds, unresolved conflicts, and canonical link presence.
Instructions
Evaluation-only pre-write safety check. Verifies the AnchorID exists, confidence meets threshold, no unresolved conflicts, and at least one canonical link is present. Returns allowed/blocked with reasons. This tool does NOT perform any write — the caller decides whether to proceed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entity_id | Yes | UUID of the AnchorID to evaluate | |
| min_confidence | No | Minimum confidence threshold (default: 0.70) | |
| require_no_conflicts | No | Block if unresolved conflicts exist (default: true) |
Implementation Reference
- src/tools.ts:293-320 (registration)The guard_write tool is registered here with server.tool(). It includes the tool name, description, Zod schema for input validation, and the async handler function.
server.tool( "guard_write", "Evaluation-only pre-write safety check. Verifies the AnchorID exists, " + "confidence meets threshold, no unresolved conflicts, and at least one " + "canonical link is present. Returns allowed/blocked with reasons. " + "This tool does NOT perform any write — the caller decides whether to proceed.", { entity_id: z.string().describe("UUID of the AnchorID to evaluate"), min_confidence: z .number() .min(0) .max(1) .optional() .describe("Minimum confidence threshold (default: 0.70)"), require_no_conflicts: z .boolean() .optional() .describe("Block if unresolved conflicts exist (default: true)"), }, async (input) => { try { const data = await api.post("/guard/write", input as Record<string, unknown>); return jsonContent(data); } catch (e) { return errorContent(e); } }, ); - src/tools.ts:312-319 (handler)The handler function that executes the guard_write tool logic. It makes a POST request to /guard/write endpoint via the ApiClient and returns the response formatted as JSON content.
async (input) => { try { const data = await api.post("/guard/write", input as Record<string, unknown>); return jsonContent(data); } catch (e) { return errorContent(e); } }, - src/tools.ts:299-311 (schema)Zod schema definition for guard_write input validation. Defines entity_id (required string), min_confidence (optional number 0-1), and require_no_conflicts (optional boolean).
{ entity_id: z.string().describe("UUID of the AnchorID to evaluate"), min_confidence: z .number() .min(0) .max(1) .optional() .describe("Minimum confidence threshold (default: 0.70)"), require_no_conflicts: z .boolean() .optional() .describe("Block if unresolved conflicts exist (default: true)"), }, - src/tools.ts:18-42 (helper)Helper functions jsonContent and errorContent used by guard_write (and other tools) to format API responses and errors 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, }; }