Skip to main content
Glama
klodr

mercury-invoicing-mcp

mercury_get_organization

Read-only

Retrieve legal identity details of your Mercury organization, including legal name, EIN, and registered address, for invoice generation and tax document preparation.

Instructions

Retrieve information about your Mercury organization (legal name, EIN, registered address, etc.).

USE WHEN: fetching the workspace's legal identity for invoice generation, tax documents, or to confirm which organization the API token is bound to.

DO NOT USE: for per-account info (use mercury_get_account). The Mercury API exposes only one organization per token, so there is no list variant.

RETURNS: { id, legalName, ein, address, ... }.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registers and implements the 'mercury_get_organization' tool. The handler (lines 19-21) calls client.get('/organization') and returns a sanitized JSON result containing organization info (id, legalName, ein, address, etc.).
    export function registerOrganizationTools(server: McpServer, client: MercuryClient): void {
      defineTool(
        server,
        "mercury_get_organization",
        [
          "Retrieve information about your Mercury organization (legal name, EIN, registered address, etc.).",
          "",
          "USE WHEN: fetching the workspace's legal identity for invoice generation, tax documents, or to confirm which organization the API token is bound to.",
          "",
          "DO NOT USE: for per-account info (use `mercury_get_account`). The Mercury API exposes only one organization per token, so there is no list variant.",
          "",
          "RETURNS: `{ id, legalName, ein, address, ... }`.",
        ].join("\n"),
        {},
        async () => {
          const data = await client.get("/organization");
          return textResult(data);
        },
        { title: "Get Organization", readOnlyHint: true, openWorldHint: true },
      );
    }
  • The input schema is an empty object '{}' (line 18) — no parameters are required for this tool.
    export function registerOrganizationTools(server: McpServer, client: MercuryClient): void {
      defineTool(
        server,
        "mercury_get_organization",
        [
          "Retrieve information about your Mercury organization (legal name, EIN, registered address, etc.).",
          "",
          "USE WHEN: fetching the workspace's legal identity for invoice generation, tax documents, or to confirm which organization the API token is bound to.",
          "",
          "DO NOT USE: for per-account info (use `mercury_get_account`). The Mercury API exposes only one organization per token, so there is no list variant.",
          "",
          "RETURNS: `{ id, legalName, ein, address, ... }`.",
        ].join("\n"),
        {},
        async () => {
          const data = await client.get("/organization");
          return textResult(data);
        },
        { title: "Get Organization", readOnlyHint: true, openWorldHint: true },
      );
    }
  • The tool is registered via defineTool() with name 'mercury_get_organization' on the MCP server. The registration function registerOrganizationTools() is called from src/tools/index.ts line 30.
    export function registerOrganizationTools(server: McpServer, client: MercuryClient): void {
      defineTool(
        server,
        "mercury_get_organization",
        [
          "Retrieve information about your Mercury organization (legal name, EIN, registered address, etc.).",
          "",
          "USE WHEN: fetching the workspace's legal identity for invoice generation, tax documents, or to confirm which organization the API token is bound to.",
          "",
          "DO NOT USE: for per-account info (use `mercury_get_account`). The Mercury API exposes only one organization per token, so there is no list variant.",
          "",
          "RETURNS: `{ id, legalName, ein, address, ... }`.",
        ].join("\n"),
        {},
        async () => {
          const data = await client.get("/organization");
          return textResult(data);
        },
        { title: "Get Organization", readOnlyHint: true, openWorldHint: true },
      );
    }
  • textResult() helper used by the handler — sanitizes JSON values and wraps them in a ToolResult with both text content and structuredContent.
    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>,
      };
    }
  • defineTool() helper that wraps the handler with rate-limiting/audit middleware (via wrapToolHandler) and registers the tool on the MCP server with strict input schema and annotations.
    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 declare readOnlyHint=true and openWorldHint=true. Description adds behavioral context: returns specific fields, and that the API exposes only one organization per token. 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?

Extremely concise with only three short sections. Uses clear headings and bullet-point-like formatting (RETURNS). Every sentence is necessary and informative.

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 has no input parameters and no output schema, the description provides a complete overview: what it does, when to use, and the return shape. No gaps for a simple read tool.

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?

No parameters in the schema (0 params, 100% coverage). Baseline is 4. Description does not add parameter details because none exist; it correctly states no params needed.

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 the action ('Retrieve information') and the resource ('Mercury organization'), listing specific fields (legal name, EIN, registered address). It distinguishes from sibling tool mercury_get_account, which is for per-account info.

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 sections, guiding the agent to use this tool for workspace legal identity and to avoid for per-account info. Mentions no list variant due to API 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