Skip to main content
Glama
klodr

mercury-invoicing-mcp

mercury_list_cards

Read-only

List all physical and virtual cards (debit, virtual, IO Credit) for a Mercury account. Returns card ID, last4, type, status, holder, and expiry to support spend audits and freeze reviews.

Instructions

List physical and virtual cards attached to a Mercury account.

USE WHEN: enumerating cards (debit, virtual debit, IO Credit) issued against an account — for spend audits, freezing review, or cardholder lookups.

DO NOT USE: to list IO Credit transactions (use mercury_list_credit_transactions). Card creation, freezing, and PIN ops are not exposed by this MCP — the Mercury API does not currently support them.

RETURNS: { cards: [{ id, last4, type, status, holderName, expiry, ... }] }.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYesThe Mercury account ID

Implementation Reference

  • The handler/registration for the mercury_list_cards tool. Defines the tool with a Zod schema accepting an accountId (UUID), makes a GET request to /account/{accountId}/cards via the MercuryClient, and returns the JSON result.
    export function registerCardTools(server: McpServer, client: MercuryClient): void {
      defineTool(
        server,
        "mercury_list_cards",
        [
          "List physical and virtual cards attached to a Mercury account.",
          "",
          "USE WHEN: enumerating cards (debit, virtual debit, IO Credit) issued against an account — for spend audits, freezing review, or cardholder lookups.",
          "",
          "DO NOT USE: to list IO Credit transactions (use `mercury_list_credit_transactions`). Card creation, freezing, and PIN ops are not exposed by this MCP — the Mercury API does not currently support them.",
          "",
          "RETURNS: `{ cards: [{ id, last4, type, status, holderName, expiry, ... }] }`.",
        ].join("\n"),
        {
          accountId: z.uuid().describe("The Mercury account ID"),
        },
        async ({ accountId }) => {
          const data = await client.get(`/account/${accountId}/cards`);
          return textResult(data);
        },
        { title: "List Cards", readOnlyHint: true, openWorldHint: true },
      );
    }
  • src/tools/cards.ts:1-4 (registration)
    Imports for the cards tool file. The registerCardTools function is called from src/tools/index.ts (line 23) to register mercury_list_cards on the MCP server.
    import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
    import { defineTool, textResult } from "./_shared.js";
    import { z } from "zod";
    import { MercuryClient } from "../client.js";
  • The defineTool helper function used by mercury_list_cards to register itself on the McpServer with schema, handler, and annotations. Wraps the handler with rate-limit/audit middleware.
    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,
      );
    }
  • The textResult helper used by the handler to format the API response as a ToolResult with sanitized JSON.
    export function textResult(data: unknown): ToolResult {
      // Walk the payload once, reuse the sanitized value for both the
      // LLM-display JSON string and the `structuredContent` object.
      // Calling sanitizeJsonForLlm(data) + sanitizeJsonValues(data)
      // separately would run the walker twice on the same input.
      const sanitized = sanitizeJsonValues(data);
      return {
        content: [{ type: "text", text: JSON.stringify(sanitized, null, 2) }],
        structuredContent: (sanitized ?? {}) as Record<string, unknown>,
      };
    }
  • The MercuryClient.get method called by the handler (client.get('/account/{accountId}/cards')).
    // Convenience helpers
    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?

Annotations already indicate readOnlyHint=true, confirming no side effects. The description adds value by specifying the return format (cards array with fields like id, last4, type) and noting current API limitations (no card creation/freezing), which goes 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 (4 sentences), well-structured with clear sections (USE WHEN, DO NOT USE, RETURNS), and contains no redundant information.

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 low complexity (single parameter, no output schema), the description covers the purpose, usage guidelines, return format, and limitations completely. No additional information is needed for an agent to correctly select and invoke the tool.

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 for the single parameter accountId, which is clearly documented. The description does not add further semantic meaning beyond the schema, but the schema itself is sufficient.

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 explicitly states it lists physical and virtual cards attached to a Mercury account, with a specific verb and resource. It distinguishes from sibling tools like mercury_list_credit_transactions by exclusion, ensuring no ambiguity.

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?

Clear 'USE WHEN' and 'DO NOT USE' sections provide explicit context for when to use this tool (e.g., spend audits, freezing review) and when not to (e.g., listing credit transactions, which points to an alternative sibling). Also notes API limitations for card creation and freezing.

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