zcash_identity_register
Register an agent identity on the ZAP1 protocol by submitting an AGENT_REGISTER attestation with a unique agent ID and public key hash. Returns the leaf hash and verification URLs for the registration event.
Instructions
Register an agent identity on ZAP1 via an AGENT_REGISTER attestation. Returns the leaf hash and verification URLs for the registration event.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent_id | Yes | Unique agent identifier to register | |
| pubkey_hash | Yes | SHA-256 of the agent's public key (64-char hex) |
Implementation Reference
- src/tools/identity.ts:15-50 (handler)Async handler function that makes a POST request to ZAP1 API /attest with event_type AGENT_REGISTER, wallet_hash=agent_id, input_hash=pubkey_hash, and returns the JSON response or an error.
async ({ agent_id, pubkey_hash }) => { try { const res = await fetch(`${ZAP1_API}/attest`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ event_type: "AGENT_REGISTER", wallet_hash: agent_id, input_hash: pubkey_hash, }), signal: AbortSignal.timeout(API_TIMEOUT_MS), }); if (!res.ok) { const text = await res.text(); throw new Error(`${res.status}: ${text}`); } const data = await res.json(); return { content: [ { type: "text" as const, text: JSON.stringify(data, null, 2), }, ], }; } catch (err) { const msg = err instanceof Error ? err.message : String(err); return { content: [{ type: "text" as const, text: `Error: ${msg}` }], isError: true, }; } } ); - src/tools/identity.ts:11-14 (schema)Zod schema defining inputs: agent_id (string, max 128 chars) and pubkey_hash (64-char hex string, SHA-256 of the agent's public key).
{ agent_id: z.string().max(128).describe("Unique agent identifier to register"), pubkey_hash: z.string().regex(/^[0-9a-fA-F]{64}$/, "pubkey_hash must be 64-char hex").describe("SHA-256 of the agent's public key (64-char hex)"), }, - src/tools/identity.ts:7-51 (registration)The registerIdentityTool function registers the 'zcash_identity_register' tool on the MCP server via server.tool().
export function registerIdentityTool(server: McpServer) { server.tool( "zcash_identity_register", "Register an agent identity on ZAP1 via an AGENT_REGISTER attestation. Returns the leaf hash and verification URLs for the registration event.", { agent_id: z.string().max(128).describe("Unique agent identifier to register"), pubkey_hash: z.string().regex(/^[0-9a-fA-F]{64}$/, "pubkey_hash must be 64-char hex").describe("SHA-256 of the agent's public key (64-char hex)"), }, async ({ agent_id, pubkey_hash }) => { try { const res = await fetch(`${ZAP1_API}/attest`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ event_type: "AGENT_REGISTER", wallet_hash: agent_id, input_hash: pubkey_hash, }), signal: AbortSignal.timeout(API_TIMEOUT_MS), }); if (!res.ok) { const text = await res.text(); throw new Error(`${res.status}: ${text}`); } const data = await res.json(); return { content: [ { type: "text" as const, text: JSON.stringify(data, null, 2), }, ], }; } catch (err) { const msg = err instanceof Error ? err.message : String(err); return { content: [{ type: "text" as const, text: `Error: ${msg}` }], isError: true, }; } } ); } - src/index.ts:45-45 (registration)Top-level invocation of registerIdentityTool(server) to register the tool at server startup.
registerIdentityTool(server); - src/tools/identity.ts:4-5 (helper)Configuration constants: ZAP1_API base URL and API_TIMEOUT_MS used by the handler.
const ZAP1_API = process.env.ZAP1_API_URL ?? "https://pay.frontiercompute.io"; const API_TIMEOUT_MS = 15_000;