Skip to main content
Glama
Frontier-Compute

Frontier-Compute/zcash-mcp

zcash_watch_payment

Poll a ZAP1 invoice until payment is confirmed or timeout expires. Returns paid status, transaction ID, block height, and confirmed amount.

Instructions

Poll a ZAP1 invoice until it is paid or the timeout expires. Returns paid status, txid, block height, and confirmed amount.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
invoice_idYesInvoice ID returned by zcash_create_invoice
timeout_secondsNoMaximum seconds to wait for payment (default 300)

Implementation Reference

  • The async handler that polls the ZAP1 /invoice/{invoice_id} endpoint until paid or timeout. Returns paid status, txid, height, and amount on success; returns timeout result or error otherwise.
      async ({ invoice_id, timeout_seconds }) => {
        const deadline = Date.now() + timeout_seconds * 1000;
    
        try {
          while (Date.now() < deadline) {
            const res = await fetch(`${ZAP1_API}/invoice/${invoice_id}`, {
              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();
    
            if (data.status === "paid") {
              return {
                content: [
                  {
                    type: "text" as const,
                    text: JSON.stringify(
                      {
                        paid: true,
                        txid: data.txid ?? null,
                        height: data.height ?? null,
                        amount: data.amount ?? null,
                      },
                      null,
                      2
                    ),
                  },
                ],
              };
            }
    
            const remaining = Math.ceil((deadline - Date.now()) / 1000);
            if (remaining <= 0) break;
    
            await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS));
          }
    
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify(
                  { paid: false, txid: null, height: null, amount: null, reason: "timeout" },
                  null,
                  2
                ),
              },
            ],
          };
        } catch (err) {
          const msg = err instanceof Error ? err.message : String(err);
          return {
            content: [{ type: "text" as const, text: `Error: ${msg}` }],
            isError: true,
          };
        }
      }
    );
  • Input schema for zcash_watch_payment: invoice_id (string) and timeout_seconds (positive int, default 300).
    {
      invoice_id: z.string().describe("Invoice ID returned by zcash_create_invoice"),
      timeout_seconds: z.number().int().positive().default(300).describe("Maximum seconds to wait for payment (default 300)"),
    },
  • Registration of the tool via server.tool() with name 'zcash_watch_payment' and its description.
    export function registerWatchTool(server: McpServer) {
      server.tool(
        "zcash_watch_payment",
        "Poll a ZAP1 invoice until it is paid or the timeout expires. Returns paid status, txid, block height, and confirmed amount.",
        {
          invoice_id: z.string().describe("Invoice ID returned by zcash_create_invoice"),
          timeout_seconds: z.number().int().positive().default(300).describe("Maximum seconds to wait for payment (default 300)"),
        },
        async ({ invoice_id, timeout_seconds }) => {
          const deadline = Date.now() + timeout_seconds * 1000;
    
          try {
            while (Date.now() < deadline) {
              const res = await fetch(`${ZAP1_API}/invoice/${invoice_id}`, {
                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();
    
              if (data.status === "paid") {
                return {
                  content: [
                    {
                      type: "text" as const,
                      text: JSON.stringify(
                        {
                          paid: true,
                          txid: data.txid ?? null,
                          height: data.height ?? null,
                          amount: data.amount ?? null,
                        },
                        null,
                        2
                      ),
                    },
                  ],
                };
              }
    
              const remaining = Math.ceil((deadline - Date.now()) / 1000);
              if (remaining <= 0) break;
    
              await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS));
            }
    
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify(
                    { paid: false, txid: null, height: null, amount: null, reason: "timeout" },
                    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:43-43 (registration)
    Invocation of registerWatchTool(server) to register the tool on the MCP server.
    registerWatchTool(server);
  • Constants: ZAP1_API base URL, POLL_INTERVAL_MS (5s), and API_TIMEOUT_MS (10s).
    const ZAP1_API = process.env.ZAP1_API_URL ?? "https://pay.frontiercompute.io";
    const POLL_INTERVAL_MS = 5_000;
    const API_TIMEOUT_MS = 10_000;
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must carry the full burden. It describes the polling loop and return values, but does not disclose potential side effects, error behavior (e.g., if invoice already paid), rate limits, or idempotency. Adequate but minimal.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, no redundant information. The action and return are front-loaded. Every word serves a purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity, the description fully explains what it does, its inputs (referencing sibling tool for invoice creation), and its outputs. No output schema exists, so the listed return fields are sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds context about the polling purpose (waiting for payment) and clarifies the role of 'timeout_seconds', but does not significantly extend beyond the schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (polling a ZAP1 invoice), the condition (until paid or timeout), and the return values (paid status, txid, block height, confirmed amount). It distinguishes itself from siblings like 'zcash_create_invoice' and 'zcash_prove_payment' by specifying the polling/waiting behavior.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context—after creating an invoice with 'zcash_create_invoice'—but does not explicitly state when to use this tool versus alternatives (e.g., for immediate status without waiting). No exclusions or alternative tools are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Frontier-Compute/zcash-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server