zcash_reputation_score
Look up an agent's ZAP1 reputation score combining bond data and policy compliance. Returns attestation count, violations, bonds, and compliant status.
Instructions
Fetch an agent's reputation from ZAP1. Combines bond data and policy compliance into a single object: attestation count, violations, bonds, and compliant flag.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent_id | Yes | Agent identifier to look up |
Implementation Reference
- src/tools/reputation.ts:7-62 (handler)The registerReputationTool function that registers the 'zcash_reputation_score' tool with the MCP server. The handler fetches bond data and policy compliance from ZAP1 API for a given agent_id, then returns a JSON object with attestation_count, violations, bonds, and compliant fields.
export function registerReputationTool(server: McpServer) { server.tool( "zcash_reputation_score", "Fetch an agent's reputation from ZAP1. Combines bond data and policy compliance into a single object: attestation count, violations, bonds, and compliant flag.", { agent_id: z.string().max(128).describe("Agent identifier to look up"), }, async ({ agent_id }) => { try { const [bondRes, policyRes] = await Promise.all([ fetch(`${ZAP1_API}/agent/${encodeURIComponent(agent_id)}/bond`, { signal: AbortSignal.timeout(API_TIMEOUT_MS), }), fetch(`${ZAP1_API}/agent/${encodeURIComponent(agent_id)}/policy/verify`, { signal: AbortSignal.timeout(API_TIMEOUT_MS), }), ]); if (!bondRes.ok) { const text = await bondRes.text(); throw new Error(`bond ${bondRes.status}: ${text}`); } if (!policyRes.ok) { const text = await policyRes.text(); throw new Error(`policy ${policyRes.status}: ${text}`); } const bond = await bondRes.json(); const policy = await policyRes.json(); const reputation = { agent_id, attestation_count: bond.attestation_count ?? null, violations: bond.violations ?? null, bonds: bond.bonds ?? null, compliant: policy.compliant ?? null, }; return { content: [ { type: "text" as const, text: JSON.stringify(reputation, 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/reputation.ts:1-5 (helper)Imports and constants: imports McpServer from MCP SDK and Zod for schema validation, defines ZAP1_API base URL and API_TIMEOUT_MS constant.
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { z } from "zod/v4"; const ZAP1_API = process.env.ZAP1_API_URL ?? "https://pay.frontiercompute.io"; const API_TIMEOUT_MS = 15_000; - src/tools/reputation.ts:8-13 (schema)Tool registration name 'zcash_reputation_score', description, and input schema: requires agent_id (string, max 128 chars).
server.tool( "zcash_reputation_score", "Fetch an agent's reputation from ZAP1. Combines bond data and policy compliance into a single object: attestation count, violations, bonds, and compliant flag.", { agent_id: z.string().max(128).describe("Agent identifier to look up"), }, - src/index.ts:21-21 (registration)Import of registerReputationTool from the reputation module.
import { registerReputationTool } from "./tools/reputation.js"; - src/index.ts:46-46 (registration)Registration call: registerReputationTool(server) which triggers server.tool(...) to register the 'zcash_reputation_score' tool.
registerReputationTool(server);