Skip to main content
Glama
klodr

mercury-invoicing-mcp

mercury_list_invoices

List invoices in your Mercury workspace with cursor-based pagination. Use for AR audits, finding invoice IDs, or building dunning reports.

Instructions

List invoices in your Mercury workspace, with cursor-based pagination.

USE WHEN: enumerating invoices for an AR audit, finding the ID of an invoice to update/cancel, or building a dunning report. Use startAfter / endBefore to page beyond the limit.

DO NOT USE: for one invoice whose ID is known (prefer mercury_get_invoice). Mercury does not currently support filtering by status or customer at the API level — filter client-side after listing.

RETURNS: { invoices: [{ id, status, amount, customerId, dueDate, ... }] }.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMax results to return (1-1000). Default: 1000
orderNoSort order. Default: asc
startAfterNoPagination: return invoices after this ID
endBeforeNoPagination: return invoices before this ID

Implementation Reference

  • The actual handler function for mercury_list_invoices. It builds query parameters (limit, order, startAfter, endBefore), calls client.get('/ar/invoices', query), and returns the sanitized JSON result via textResult().
    async (args) => {
      const query: Record<string, string | number | undefined> = {
        limit: args.limit,
        order: args.order,
        start_after: args.startAfter,
        end_before: args.endBefore,
      };
      const data = await client.get("/ar/invoices", query);
      return textResult(data);
    },
  • Zod input schema for mercury_list_invoices: optional 'limit' (int 1-1000), 'order' (asc/desc), 'startAfter' (UUID), and 'endBefore' (UUID).
      limit: z
        .number()
        .int()
        .min(1)
        .max(1000)
        .optional()
        .describe("Max results to return (1-1000). Default: 1000"),
      order: z.enum(["asc", "desc"]).optional().describe("Sort order. Default: asc"),
      startAfter: z
        .string()
        .uuid()
        .optional()
        .describe("Pagination: return invoices after this ID"),
      endBefore: z
        .string()
        .uuid()
        .optional()
        .describe("Pagination: return invoices before this ID"),
    },
  • Registration: the tool 'mercury_list_invoices' is registered via defineTool() inside the registerInvoiceTools() function, which is called from registerAllTools() in src/tools/index.ts (line 33).
    export function registerInvoiceTools(server: McpServer, client: MercuryClient): void {
      defineTool(
        server,
        "mercury_list_invoices",
        [
          "List invoices in your Mercury workspace, with cursor-based pagination.",
          "",
          "USE WHEN: enumerating invoices for an AR audit, finding the ID of an invoice to update/cancel, or building a dunning report. Use `startAfter` / `endBefore` to page beyond the limit.",
          "",
          "DO NOT USE: for one invoice whose ID is known (prefer `mercury_get_invoice`). Mercury does not currently support filtering by status or customer at the API level — filter client-side after listing.",
          "",
          "RETURNS: `{ invoices: [{ id, status, amount, customerId, dueDate, ... }] }`.",
        ].join("\n"),
        {
          limit: z
            .number()
            .int()
            .min(1)
            .max(1000)
            .optional()
            .describe("Max results to return (1-1000). Default: 1000"),
          order: z.enum(["asc", "desc"]).optional().describe("Sort order. Default: asc"),
          startAfter: z
            .string()
            .uuid()
            .optional()
            .describe("Pagination: return invoices after this ID"),
          endBefore: z
            .string()
            .uuid()
            .optional()
            .describe("Pagination: return invoices before this ID"),
        },
        async (args) => {
          const query: Record<string, string | number | undefined> = {
            limit: args.limit,
            order: args.order,
            start_after: args.startAfter,
            end_before: args.endBefore,
          };
          const data = await client.get("/ar/invoices", query);
          return textResult(data);
        },
      );
  • The defineTool() helper wraps the handler with middleware (rate-limit, audit, dry-run) via wrapToolHandler(), then registers it on the MCP server via server.registerTool().
    export function defineTool<S extends ZodRawShape>(
      server: McpServer,
      name: string,
      description: string,
      inputSchema: S,
      handler: (args: z.infer<z.ZodObject<S>>) => Promise<ToolResult>,
    ): void {
      const wrapped = wrapToolHandler(name, handler);
      const strictSchema = z.object(inputSchema).strict();
      server.registerTool(name, { description, inputSchema: strictSchema }, wrapped);
  • The MercuryClient.get() method — used by the handler to make the GET /ar/invoices request to the Mercury API with query parameters for pagination.
    get<T = unknown>(path: string, query?: Record<string, string | number | undefined>) {
      return this.request<T>("GET", path, { query });
    }
Behavior4/5

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

No annotations provided, so description carries full burden. It discloses pagination behavior, lack of server-side filtering, and the return structure. While it doesn't explicitly state read-only, the listing operation implies it.

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?

Concise and well-structured with clear sections (USE WHEN, DO NOT USE, RETURNS). No unnecessary words, efficient communication.

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 complexity (4 params, no output schema), the description covers when to use, alternatives, limitations, return shape, and pagination details. Complete for a list operation.

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 parameters are already documented. The description adds usage context for startAfter/endBefore and default limit, but doesn't significantly expand beyond the schema.

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 'List invoices in your Mercury workspace' with a specific verb and resource, and mentions cursor-based pagination. It distinguishes itself from sibling tools like mercury_get_invoice (single invoice) and mercury_update_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 when-to-use scenarios (AR audit, finding IDs, dunning report) and when-not-to-use (prefer mercury_get_invoice for known ID). Also notes client-side filtering as a limitation.

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