Skip to main content
Glama
klodr

mercury-invoicing-mcp

mercury_get_invoice

Read-only

Retrieve full details of a specific invoice by its ID, including line items, status, and payment URL.

Instructions

Retrieve a specific invoice by ID, including line items, status, and the payment URL.

USE WHEN: fetching the full detail of one invoice (line items, current status, balance due, payment URL) whose ID is already known.

DO NOT USE: to enumerate invoices (use mercury_list_invoices). For attachments use mercury_list_invoice_attachments.

RETURNS: { id, status, amount, customerId, lineItems, paymentUrl, dueDate, ... }.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
invoiceIdYesThe invoice ID (UUID)

Implementation Reference

  • The actual handler function for mercury_get_invoice. Makes a GET request to /ar/invoices/{invoiceId} via the MercuryClient, passing the UUID invoice ID from the validated args, then returns the result via textResult.
    async ({ invoiceId }) => {
      const data = await client.get(`/ar/invoices/${invoiceId}`);
      return textResult(data);
    },
  • Input schema for mercury_get_invoice: a single 'invoiceId' parameter validated as a UUID via Zod's z.uuid().
    {
      invoiceId: z.uuid().describe("The invoice ID (UUID)"),
    },
  • Registration of mercury_get_invoice via defineTool(). This calls server.registerTool under the hood, passing the tool name, description, input schema, handler, and annotations (readOnlyHint: true). The tool is registered inside registerInvoiceTools() which gets called from registerAllTools() in src/tools/index.ts.
    defineTool(
      server,
      "mercury_get_invoice",
      [
        "Retrieve a specific invoice by ID, including line items, status, and the payment URL.",
        "",
        "USE WHEN: fetching the full detail of one invoice (line items, current status, balance due, payment URL) whose ID is already known.",
        "",
        "DO NOT USE: to enumerate invoices (use `mercury_list_invoices`). For attachments use `mercury_list_invoice_attachments`.",
        "",
        "RETURNS: `{ id, status, amount, customerId, lineItems, paymentUrl, dueDate, ... }`.",
      ].join("\n"),
      {
        invoiceId: z.uuid().describe("The invoice ID (UUID)"),
      },
      async ({ invoiceId }) => {
        const data = await client.get(`/ar/invoices/${invoiceId}`);
        return textResult(data);
      },
      { title: "Get Invoice", readOnlyHint: true, openWorldHint: true },
    );
  • Top-level registration entry point: registerInvoiceTools(server, client) is called from registerAllTools(), which wires up all invoice tools including mercury_get_invoice.
      registerInvoiceTools(server, client);
      registerCustomerTools(server, client);
    
      // Webhooks
      registerWebhookTools(server, client);
    }
  • The defineTool helper used to register mercury_get_invoice. It wraps the handler with middleware (rate limiting, dry-run, audit) via wrapToolHandler, creates a strict Zod schema, and calls server.registerTool with the tool name, description, schema, and wrapped handler.
    export function defineTool<S extends ZodRawShape>(
      server: McpServer,
      name: string,
      description: string,
      inputSchema: S,
      handler: (args: z.infer<z.ZodObject<S>>) => Promise<ToolResult>,
      annotations: ToolAnnotations,
    ): void {
      const wrapped = wrapToolHandler(name, handler);
      const strictSchema = z.object(inputSchema).strict();
      // MCP behavioral annotations (readOnlyHint / destructiveHint /
      // idempotentHint / openWorldHint) — declared machine-readable so
      // hosts and rubrics (TDQS / Glama Behavior dimension) can detect
      // tool semantics without scraping the prose description. Required
      // (not optional) so every new tool ships with explicit semantics —
      // forgetting the annotation now fails typecheck instead of
      // silently shipping a tool with no hint set.
      // The MCP SDK overloads `registerTool` with shape narrowing the runtime
      // strict-schema and the wrapped callback can't satisfy through generics.
      // Both casts are runtime-safe — the signatures only diverge at the type
      // level. Asserted by the existing tool-registration tests.
      (server.registerTool as unknown as (...a: unknown[]) => unknown)(
        name,
        { description, inputSchema: strictSchema, annotations },
        wrapped,
      );
    }
Behavior5/5

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

Annotations already indicate readOnlyHint=true and the description adds specific return fields (line items, status, payment URL). No contradictions; the description enriches the behavioral context beyond annotations.

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?

The description is concise with three clear sections: main purpose, usage guidance, and return format. Every sentence adds value; no redundancy.

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?

Despite no output schema, the description lists key return fields, covering what the agent needs. Tool is simple with one parameter; description fully addresses usage and expectations.

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% with description for invoiceId. The tool description does not add further parameter semantics beyond what the schema provides, so baseline 3 is appropriate.

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 'Retrieve a specific invoice by ID, including line items, status, and the payment URL.' It specifies the verb (retrieve), resource (invoice by ID), and included data, distinguishing from siblings like mercury_list_invoices.

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

Usage Guidelines5/5

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

The description includes explicit 'USE WHEN' and 'DO NOT USE' sections, directing to use for fetching one invoice with known ID and avoiding for enumeration or attachments, referencing alternative tools.

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/klodr/mercury-invoicing-mcp'

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