Skip to main content
Glama
klodr

mercury-invoicing-mcp

mercury_get_customer

Read-only

Fetch a customer's complete information using their unique ID. Use when you already know the customer ID.

Instructions

Retrieve a specific Accounts Receivable customer by ID.

USE WHEN: fetching the full detail of one customer whose ID is already known. Faster than relisting + filtering when you have the ID.

DO NOT USE: to enumerate customers (use mercury_list_customers). For payment recipients use mercury_list_recipients (different surface).

RETURNS: { id, name, email, address, ... }.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
customerIdYesCustomer ID

Implementation Reference

  • Handler function that retrieves a specific Accounts Receivable customer by ID. Calls Mercury API GET /ar/customers/{customerId} and returns the result.
    defineTool(
      server,
      "mercury_get_customer",
      [
        "Retrieve a specific Accounts Receivable customer by ID.",
        "",
        "USE WHEN: fetching the full detail of one customer whose ID is already known. Faster than relisting + filtering when you have the ID.",
        "",
        "DO NOT USE: to enumerate customers (use `mercury_list_customers`). For payment recipients use `mercury_list_recipients` (different surface).",
        "",
        "RETURNS: `{ id, name, email, address, ... }`.",
      ].join("\n"),
      {
        customerId: z.uuid().describe("Customer ID"),
      },
      async ({ customerId }) => {
        const data = await client.get(`/ar/customers/${customerId}`);
        return textResult(data);
      },
      { title: "Get Customer", readOnlyHint: true, openWorldHint: true },
    );
  • Input schema for mercury_get_customer: requires a single 'customerId' parameter (UUID) describing the customer to retrieve.
    {
      customerId: z.uuid().describe("Customer ID"),
    },
  • Registration call that wires mercury_get_customer (along with other customer tools) onto the MCP server via registerCustomerTools.
    registerCustomerTools(server, client);
  • Registration function that registers all customer tools (including mercury_get_customer) on the MCP server using defineTool.
    export function registerCustomerTools(server: McpServer, client: MercuryClient): void {
      defineTool(
        server,
        "mercury_list_customers",
        [
          "List Accounts Receivable customers, with cursor-based pagination.",
          "",
          "USE WHEN: enumerating AR customers before creating an invoice (need a `customerId` for `mercury_create_invoice`), or for a customer-level audit. Use `startAfter` / `endBefore` for paging beyond the limit.",
          "",
          "DO NOT USE: for payment recipients (`mercury_list_recipients` is the bank-payment counterparty list, distinct from AR customers). For one customer whose ID is known, prefer `mercury_get_customer`.",
          "",
          "RETURNS: `{ customers: [{ id, name, email, address, ... }] }`.",
        ].join("\n"),
        {
          limit: z.number().int().min(1).max(1000).optional().describe("Max results (1-1000)"),
          order: z.enum(["asc", "desc"]).optional(),
          startAfter: z.uuid().optional().describe("Pagination cursor (forward)"),
          endBefore: z.uuid().optional().describe("Pagination cursor (reverse)"),
        },
        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/customers", query);
          return textResult(data);
        },
        { title: "List Customers", readOnlyHint: true, openWorldHint: true },
      );
    
      defineTool(
        server,
        "mercury_get_customer",
        [
          "Retrieve a specific Accounts Receivable customer by ID.",
          "",
          "USE WHEN: fetching the full detail of one customer whose ID is already known. Faster than relisting + filtering when you have the ID.",
          "",
          "DO NOT USE: to enumerate customers (use `mercury_list_customers`). For payment recipients use `mercury_list_recipients` (different surface).",
          "",
          "RETURNS: `{ id, name, email, address, ... }`.",
        ].join("\n"),
        {
          customerId: z.uuid().describe("Customer ID"),
        },
        async ({ customerId }) => {
          const data = await client.get(`/ar/customers/${customerId}`);
          return textResult(data);
        },
        { title: "Get Customer", readOnlyHint: true, openWorldHint: true },
      );
    
      defineTool(
        server,
        "mercury_create_customer",
        [
          "Create a new Accounts Receivable customer (a billable entity you will later invoice).",
          "",
          "USE WHEN: onboarding a new customer before issuing them an invoice. The returned `id` is what `mercury_create_invoice` expects as `customerId`.",
          "",
          "DO NOT USE: for payment recipients (use `mercury_add_recipient` — different surface, used for outbound bank transfers, not invoicing).",
          "",
          "SIDE EFFECTS: writes a new customer to your Mercury workspace. Persistent. NOT idempotent at the API level — calling twice with the same payload creates two customers; check `mercury_list_customers` for existing entries before creating to avoid duplicates.",
          "",
          "RETURNS: `{ id, name, email, address, ... }` — keep `id` for the invoicing tools.",
        ].join("\n"),
        {
          name: z.string().describe("Customer name"),
          email: z.email().describe("Customer email"),
          address: addressSchema.optional(),
        },
        async (args) => {
          const data = await client.post("/ar/customers", args);
          return textResult(data);
        },
        { title: "Create Customer", destructiveHint: false, openWorldHint: true },
      );
    
      defineTool(
        server,
        "mercury_update_customer",
        [
          "Update an existing Accounts Receivable customer. Pass only the fields you want to change.",
          "",
          "USE WHEN: amending a customer's contact details (name, email, billing address) after creation. Existing invoices are not retroactively modified.",
          "",
          "DO NOT USE: to delete a customer (use `mercury_delete_customer`). To change the customer of an existing invoice, cancel + recreate the invoice.",
          "",
          "SIDE EFFECTS: writes the new customer record to Mercury. Persistent. Only the fields you pass are changed — omitted fields keep their current value.",
          "",
          "RETURNS: `{ id, name, email, address, ... }` — the updated customer.",
        ].join("\n"),
        {
          customerId: z.uuid().describe("Customer ID"),
          name: z.string().optional(),
          email: z.email().optional(),
          address: addressSchema.optional(),
        },
        async ({ customerId, ...body }) => {
          const data = await client.patch(`/ar/customers/${customerId}`, body);
          return textResult(data);
        },
        { title: "Update Customer", destructiveHint: false, openWorldHint: true },
      );
    
      defineTool(
        server,
        "mercury_delete_customer",
        [
          "Permanently delete an Accounts Receivable customer. **DESTRUCTIVE.**",
          "",
          "USE WHEN: removing a customer that was created by mistake, or that the user explicitly wants to purge. ALWAYS confirm with the user before calling — there is no undo.",
          "",
          "DO NOT USE: when the customer has invoices in `paid` / `outstanding` status — Mercury rejects deletion in those cases and returns a 409. Cancel outstanding invoices first via `mercury_cancel_invoice`.",
          "",
          "SIDE EFFECTS: **permanent deletion** on Mercury's side. The customer disappears from the AR list. Past invoices' `customerId` may dangle (Mercury does not cascade-delete invoices). NOT recoverable from API. ALWAYS confirm with the user.",
          "",
          "RETURNS: confirmation payload from Mercury (`{ deleted: true, ... }` or similar).",
        ].join("\n"),
        {
          customerId: z.uuid().describe("Customer ID"),
        },
        async ({ customerId }) => {
          const data = await client.delete(`/ar/customers/${customerId}`);
          return textResult(data);
        },
        { title: "Delete Customer", destructiveHint: true, openWorldHint: true },
      );
    }
Behavior4/5

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

Annotations already indicate readOnlyHint and openWorldHint; the description adds that it returns full customer detail and gives the return shape. No contradictions.

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?

Highly concise with three clear sections: intro, usage guidance, return shape. No unnecessary words; front-loaded with key info.

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

Completeness4/5

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

Given low complexity, the description adequately covers purpose, usage, and return format. Ellipsis indicates more fields, which is acceptable without output schema.

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

Parameters4/5

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

Schema covers parameter fully with description; description adds context that the ID is already known and that the tool is for lookup, reinforcing the parameter's role.

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?

Clearly states the action (Retrieve) and resource (a specific Accounts Receivable customer by ID). Differentiates from sibling tools like mercury_list_customers and mercury_list_recipients.

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 specifies when to use (when ID is known, faster than listing) and when not to use (enumerating customers or fetching payment recipients). Provides 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