@receiz/mcp-server
Version:
MCP server for agents building and verifying Receiz proof-native applications through the canonical Receiz SDK rails.
69 lines • 5.76 kB
JavaScript
const object = (properties, required = []) => ({ type: "object", additionalProperties: false, properties, required });
const text = (description) => ({ type: "string", description });
export const RECEIZ_V122_MCP_TOOL_NAMES = Object.freeze([
"receiz_v122_subject_admit", "receiz_v122_subject_state", "receiz_v122_subject_export_edge_bundle", "receiz_v122_subject_import_edge_bundle", "receiz_v122_subject_access_binding", "receiz_v122_subject_access_key_publish",
"receiz_v122_world_plan_private", "receiz_v122_world_validate_transaction", "receiz_v122_world_execute_transaction", "receiz_v122_world_execution", "receiz_v122_world_execution_by_idempotency", "receiz_v122_world_additions",
"receiz_v122_mandate_issue", "receiz_v122_mandate_state", "receiz_v122_mandate_revoke",
"receiz_v122_multi_world_plan", "receiz_v122_multi_world_execute", "receiz_v122_value_plan_settlement", "receiz_v122_value_plan_reserve",
]);
export const RECEIZ_V122_MCP_TOOLS = RECEIZ_V122_MCP_TOOL_NAMES.map((name) => ({
name,
description: `Receiz v122 proof-native operation. MCP is not authority; exact proof objects and SDK verification remain stronger truth. ${name.includes("value") ? "Phi moves on an explicit Settlement or Reserve rail; USD is display-only." : ""}`,
inputSchema: name === "receiz_v122_subject_admit" ? object({ artifactBase64: text("Exact enclosing Receiz proof-object bytes."), filename: text("Proof-object filename."), mimeType: text("Proof-object MIME type."), ownerReceizId: text("Exact object-carried owner."), idempotencyKey: text("Stable semantic idempotency key."), expectedAbsent: { const: true } }, ["artifactBase64", "filename", "mimeType", "ownerReceizId", "idempotencyKey", "expectedAbsent"])
: name === "receiz_v122_world_plan_private" ? object({ input: { type: "object", description: "Edge-only planning input. privatePayload is encrypted locally and never sent as plaintext." } }, ["input"])
: object({ input: { type: "object", description: "Exact SDK input. Mutations require an explicit idempotency key or persisted exact plan." } }, ["input"]),
outputSchema: { type: "object", additionalProperties: true },
}));
const input = (args) => (args.input && typeof args.input === "object" ? args.input : args);
const inputObject = (args) => {
const value = input(args);
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
};
function rejectPrivatePlaintext(value) {
if (Array.isArray(value)) {
value.forEach(rejectPrivatePlaintext);
return;
}
if (value === null || typeof value !== "object")
return;
for (const [key, child] of Object.entries(value)) {
if (/^(privatePayload|privateGeometry|inviteList|privateMetadata|plaintext)$/i.test(key)) {
throw new TypeError("V122_MCP_PRIVATE_PLAINTEXT_REMOTE_FORBIDDEN");
}
rejectPrivatePlaintext(child);
}
}
function remoteInput(args) {
const value = input(args);
rejectPrivatePlaintext(value);
return value;
}
export async function callReceizV122McpOperation(client, name, args) {
switch (name) {
case "receiz_v122_subject_admit": return client.subjects.admit({ proofObject: new Blob([Buffer.from(String(args.artifactBase64), "base64")], { type: String(args.mimeType) }), ownerReceizId: args.ownerReceizId, idempotencyKey: args.idempotencyKey, expectedAbsent: true });
case "receiz_v122_subject_state": return client.subjects.state(String(inputObject(args).subjectId));
case "receiz_v122_subject_export_edge_bundle": return client.subjects.exportEdgeBundle(String(inputObject(args).subjectId), inputObject(args).verifier);
case "receiz_v122_subject_import_edge_bundle": return client.subjects.importEdgeBundle(inputObject(args).bundle, inputObject(args).verifier);
case "receiz_v122_subject_access_binding": return client.subjects.accessBinding(String(inputObject(args).subjectId));
case "receiz_v122_subject_access_key_publish": return client.subjects.publishAccessKey(remoteInput(args));
case "receiz_v122_world_plan_private": return client.world.planPrivateCommand(input(args));
case "receiz_v122_world_validate_transaction": {
const value = remoteInput(args);
const valueObject = value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
return client.world.validateTransaction(valueObject.transaction ?? value);
}
case "receiz_v122_world_execute_transaction": return client.world.executeTransactionV122(remoteInput(args));
case "receiz_v122_world_execution": return client.world.execution(remoteInput(args));
case "receiz_v122_world_execution_by_idempotency": return client.world.executionByIdempotencyKey(remoteInput(args));
case "receiz_v122_world_additions": return client.world.additionsV122(remoteInput(args));
case "receiz_v122_mandate_issue": return client.subjectMandates.issue(remoteInput(args));
case "receiz_v122_mandate_state": return client.subjectMandates.state(remoteInput(args));
case "receiz_v122_mandate_revoke": return client.subjectMandates.revoke(remoteInput(args));
case "receiz_v122_multi_world_plan": return client.world.planMultiWorldTransaction(input(args));
case "receiz_v122_multi_world_execute": return client.world.executeMultiWorldTransaction(remoteInput(args));
case "receiz_v122_value_plan_settlement": return client.value.planSettlement(input(args));
case "receiz_v122_value_plan_reserve": return client.value.planReserve(input(args));
default: throw new Error("V122_MCP_TOOL_UNKNOWN");
}
}
//# sourceMappingURL=v122Operations.js.map