Skip to main content
Glama
klodr

mercury-invoicing-mcp

mercury_list_invoice_attachments

Read-only

Retrieve all attachments linked to an invoice, including PDFs and supporting documents, for audit or sharing. Fetches filename and short-lived download URL.

Instructions

List attachments associated with an invoice (PDF copies, supporting documents).

USE WHEN: discovering which files were attached to an invoice — for archival, audit, or to share with a customer. The download URL is short-lived; refetch shortly before download.

DO NOT USE: to upload an attachment — this MCP currently exposes only the read side. Mercury's API does support attachment upload (POST /ar/invoices/{id}/attachments); a write tool can be added if needed.

RETURNS: { attachments: [{ id, filename, downloadUrl, ... }] }.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
invoiceIdYesInvoice ID

Implementation Reference

  • The handler function that executes the tool logic: calls client.get on /ar/invoices/{invoiceId}/attachments and returns the result via textResult.
    async ({ invoiceId }) => {
      const data = await client.get(`/ar/invoices/${invoiceId}/attachments`);
      return textResult(data);
  • Input schema requiring invoiceId (UUID) as the only parameter.
    {
      invoiceId: z.uuid().describe("Invoice ID"),
    },
  • Registration of the tool via defineTool, which calls server.registerTool internally. The tool is registered with the name 'mercury_list_invoice_attachments'.
    defineTool(
      server,
      "mercury_list_invoice_attachments",
      [
        "List attachments associated with an invoice (PDF copies, supporting documents).",
        "",
        "USE WHEN: discovering which files were attached to an invoice — for archival, audit, or to share with a customer. The download URL is short-lived; refetch shortly before download.",
        "",
        "DO NOT USE: to upload an attachment — this MCP currently exposes only the read side. Mercury's API does support attachment upload (`POST /ar/invoices/{id}/attachments`); a write tool can be added if needed.",
        "",
        "RETURNS: `{ attachments: [{ id, filename, downloadUrl, ... }] }`.",
      ].join("\n"),
      {
        invoiceId: z.uuid().describe("Invoice ID"),
      },
      async ({ invoiceId }) => {
        const data = await client.get(`/ar/invoices/${invoiceId}/attachments`);
        return textResult(data);
      },
      { title: "List Invoice Attachments", readOnlyHint: true, openWorldHint: true },
    );
  • registerInvoiceTools is called in registerAllTools, which registers all invoice-related tools including mercury_list_invoice_attachments on the MCP server.
      registerInvoiceTools(server, client);
      registerCustomerTools(server, client);
    
      // Webhooks
      registerWebhookTools(server, client);
    }
  • The defineTool helper wraps the handler with middleware and registers the tool on the MCP server. It is used by the mercury_list_invoice_attachments registration.
    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. The description adds critical behavioral details: download URLs are short-lived requiring refetch before download, and it returns a specific structure. No contradiction with 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 (three sections: what, use when, do not use, returns) with no redundant sentences. Every sentence adds value.

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 a single parameter, no output schema, and annotations providing safety hints, the description is complete. It includes return format and critical usage notes, leaving no ambiguity for agent invocation.

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?

The input schema has 100% coverage with a description for invoiceId. The description adds no extra semantic value beyond what the schema provides, but the parameter is simple and well-documented; 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 it lists attachments associated with an invoice, specifying types (PDF copies, supporting documents). The use case section further clarifies purpose, and it is distinct from sibling tools like mercury_get_invoice or mercury_create_invoice.

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?

Explicitly provides USE WHEN and DO NOT USE guidance, including alternatives (upload is not supported) and a note on short-lived download URLs. This helps the agent decide when to invoke and when not.

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