Skip to main content
Glama

Billing

billing

Query billing and financial data in OfficeRnD to retrieve payments, fees, plans, and coin balances with filtering and pagination.

Instructions

Query billing/financial data in OfficeRnD.

action=list: List entities with optional filters and pagination (max 50 per page). action=get: Get a single entity by ID (payments, plans). action=coin_stats: Get coin/credit balance for a member or company in a given month.

Entity-specific filters when listing:

  • payments: status, member, company, documentType (creditNote|invoice|overpayment|paymentCharge), dateFrom, dateTo (ISO dates), sort (e.g. 'createdAt,desc')

  • fees: (pagination only)

  • plans: sort

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction to perform
entityNoEntity type (required for list/get, not used for coin_stats)
idNoEntity ID (required for action=get)
statusNoFilter by payment status
memberNoFilter by member ID (payments, coin_stats)
companyNoFilter by company ID (payments, coin_stats)
documentTypeNoFilter by document type (payments only)
dateFromNoPayments issued on/after this ISO date
dateToNoPayments issued before this ISO date
sortNoSort expression, e.g. 'createdAt,desc' (payments, plans)
monthNoMonth for coin_stats (e.g. '2026-03')
cursorNextNoCursor token for next page of results
limitNoResults per page (max 50, default 50)

Implementation Reference

  • The main handler function for the 'billing' MCP tool, which implements list, get, and coin_stats actions.
      async ({
        action,
        entity,
        id,
        status,
        member,
        company,
        documentType,
        dateFrom,
        dateTo,
        sort,
        month,
        cursorNext,
        limit,
      }) => {
        try {
          // coin_stats
          if (action === "coin_stats") {
            const params: Record<string, string> = {};
            if (member) params["memberId"] = member;
            if (company) params["companyId"] = company;
            if (month) params["month"] = month;
    
            const stats = await apiGet<CoinStats>("/coins/stats", params);
    
            const lines: string[] = [];
            if (stats.balance !== undefined) lines.push(`Balance: ${stats.balance}`);
            if (stats.earned !== undefined) lines.push(`Earned: ${stats.earned}`);
            if (stats.spent !== undefined) lines.push(`Spent: ${stats.spent}`);
            if (lines.length === 0) lines.push(JSON.stringify(stats, null, 2));
    
            return { content: [{ type: "text" as const, text: lines.join("\n") }] };
          }
    
          if (!entity) {
            return {
              content: [{ type: "text" as const, text: "entity is required for list/get actions." }],
              isError: true,
            };
          }
    
          const cfg = ENTITIES[entity];
    
          // get
          if (action === "get") {
            if (!cfg.getPath) {
              return {
                content: [{ type: "text" as const, text: `Entity "${entity}" does not support get by ID.` }],
                isError: true,
              };
            }
            if (!id) {
              return {
                content: [{ type: "text" as const, text: "id is required for action=get." }],
                isError: true,
              };
            }
            const item = await apiGet<Record<string, unknown>>(`${cfg.getPath}/${id}`);
            return { content: [{ type: "text" as const, text: cfg.formatter(item) }] };
          }
    
          // list
          const params: Record<string, string> = {};
          if (cursorNext) params["$cursorNext"] = cursorNext;
          if (limit) params["$limit"] = limit;
    
          switch (entity) {
            case "payments":
              if (status) params["status"] = status;
              if (member) params["member"] = member;
              if (company) params["company"] = company;
              if (documentType) params["documentType"] = documentType;
              if (dateFrom) params["date[$gte]"] = dateFrom;
              if (dateTo) params["date[$lt]"] = dateTo;
              if (sort) params["$sort"] = sort;
              break;
            case "plans":
              if (sort) params["$sort"] = sort;
              break;
          }
    
          const data = await apiGet<PaginatedResponse<Record<string, unknown>>>(cfg.listPath, params);
    
          if (data.results.length === 0) {
            return { content: [{ type: "text" as const, text: `No ${cfg.label} found.` }] };
          }
    
          const text = data.results.map(cfg.formatter).join("\n---\n");
          let result = `Found ${data.results.length} ${cfg.label} (range ${data.rangeStart}-${data.rangeEnd}):\n\n${text}`;
          if (data.cursorNext) {
            result += `\n\n[More results available — use cursorNext: "${data.cursorNext}"]`;
          }
    
          return { content: [{ type: "text" as const, text: result }] };
        } catch (error) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Error querying billing: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
            isError: true,
          };
        }
      }
    );
  • Zod schema definition for the input arguments of the 'billing' tool.
    inputSchema: {
      action: z
        .enum(["list", "get", "coin_stats"])
        .describe("Action to perform"),
      entity: z
        .enum(["payments", "fees", "plans"])
        .optional()
        .describe("Entity type (required for list/get, not used for coin_stats)"),
      id: z
        .string()
        .optional()
        .describe("Entity ID (required for action=get)"),
      status: z
        .string()
        .optional()
        .describe("Filter by payment status"),
      member: z
        .string()
        .optional()
        .describe("Filter by member ID (payments, coin_stats)"),
      company: z
        .string()
        .optional()
        .describe("Filter by company ID (payments, coin_stats)"),
      documentType: z
        .enum(["creditNote", "invoice", "overpayment", "paymentCharge"])
        .optional()
        .describe("Filter by document type (payments only)"),
      dateFrom: z
        .string()
        .optional()
        .describe("Payments issued on/after this ISO date"),
      dateTo: z
        .string()
        .optional()
        .describe("Payments issued before this ISO date"),
      sort: z
        .string()
        .optional()
        .describe("Sort expression, e.g. 'createdAt,desc' (payments, plans)"),
      month: z
        .string()
        .optional()
        .describe("Month for coin_stats (e.g. '2026-03')"),
      cursorNext: z
        .string()
        .optional()
        .describe("Cursor token for next page of results"),
      limit: z
        .string()
        .optional()
        .describe("Results per page (max 50, default 50)"),
    },
  • Registration function for the 'billing' tool using server.registerTool.
    export function registerBillingTool(server: McpServer): void {
      server.registerTool(
        "billing",
        {
          title: "Billing",
          description: `Query billing/financial data in OfficeRnD.
    
    action=list: List entities with optional filters and pagination (max 50 per page).
    action=get: Get a single entity by ID (payments, plans).
    action=coin_stats: Get coin/credit balance for a member or company in a given month.
    
    Entity-specific filters when listing:
    - payments: status, member, company, documentType (creditNote|invoice|overpayment|paymentCharge), dateFrom, dateTo (ISO dates), sort (e.g. 'createdAt,desc')
    - fees: (pagination only)
    - plans: sort`,
          inputSchema: {
            action: z
              .enum(["list", "get", "coin_stats"])
              .describe("Action to perform"),
            entity: z
              .enum(["payments", "fees", "plans"])
              .optional()
              .describe("Entity type (required for list/get, not used for coin_stats)"),
            id: z
              .string()
              .optional()
              .describe("Entity ID (required for action=get)"),
            status: z
              .string()
              .optional()
              .describe("Filter by payment status"),
            member: z
              .string()
              .optional()
              .describe("Filter by member ID (payments, coin_stats)"),
            company: z
              .string()
              .optional()
              .describe("Filter by company ID (payments, coin_stats)"),
            documentType: z
              .enum(["creditNote", "invoice", "overpayment", "paymentCharge"])
              .optional()
              .describe("Filter by document type (payments only)"),
            dateFrom: z
              .string()
              .optional()
              .describe("Payments issued on/after this ISO date"),
            dateTo: z
              .string()
              .optional()
              .describe("Payments issued before this ISO date"),
            sort: z
              .string()
              .optional()
              .describe("Sort expression, e.g. 'createdAt,desc' (payments, plans)"),
            month: z
              .string()
              .optional()
              .describe("Month for coin_stats (e.g. '2026-03')"),
            cursorNext: z
              .string()
              .optional()
              .describe("Cursor token for next page of results"),
            limit: z
              .string()
              .optional()
              .describe("Results per page (max 50, default 50)"),
          },
        },
        async ({
          action,
          entity,
          id,
          status,
          member,
          company,
          documentType,
          dateFrom,
          dateTo,
          sort,
          month,
          cursorNext,
          limit,
        }) => {
          try {
            // coin_stats
            if (action === "coin_stats") {
              const params: Record<string, string> = {};
              if (member) params["memberId"] = member;
              if (company) params["companyId"] = company;
              if (month) params["month"] = month;
    
              const stats = await apiGet<CoinStats>("/coins/stats", params);
    
              const lines: string[] = [];
              if (stats.balance !== undefined) lines.push(`Balance: ${stats.balance}`);
              if (stats.earned !== undefined) lines.push(`Earned: ${stats.earned}`);
              if (stats.spent !== undefined) lines.push(`Spent: ${stats.spent}`);
              if (lines.length === 0) lines.push(JSON.stringify(stats, null, 2));
    
              return { content: [{ type: "text" as const, text: lines.join("\n") }] };
            }
    
            if (!entity) {
              return {
                content: [{ type: "text" as const, text: "entity is required for list/get actions." }],
                isError: true,
              };
            }
    
            const cfg = ENTITIES[entity];
    
            // get
            if (action === "get") {
              if (!cfg.getPath) {
                return {
                  content: [{ type: "text" as const, text: `Entity "${entity}" does not support get by ID.` }],
                  isError: true,
                };
              }
              if (!id) {
                return {
                  content: [{ type: "text" as const, text: "id is required for action=get." }],
                  isError: true,
                };
              }
              const item = await apiGet<Record<string, unknown>>(`${cfg.getPath}/${id}`);
              return { content: [{ type: "text" as const, text: cfg.formatter(item) }] };
            }
    
            // list
            const params: Record<string, string> = {};
            if (cursorNext) params["$cursorNext"] = cursorNext;
            if (limit) params["$limit"] = limit;
    
            switch (entity) {
              case "payments":
                if (status) params["status"] = status;
                if (member) params["member"] = member;
                if (company) params["company"] = company;
                if (documentType) params["documentType"] = documentType;
                if (dateFrom) params["date[$gte]"] = dateFrom;
                if (dateTo) params["date[$lt]"] = dateTo;
                if (sort) params["$sort"] = sort;
                break;
              case "plans":
                if (sort) params["$sort"] = sort;
                break;
            }
    
            const data = await apiGet<PaginatedResponse<Record<string, unknown>>>(cfg.listPath, params);
    
            if (data.results.length === 0) {
              return { content: [{ type: "text" as const, text: `No ${cfg.label} found.` }] };
            }
    
            const text = data.results.map(cfg.formatter).join("\n---\n");
            let result = `Found ${data.results.length} ${cfg.label} (range ${data.rangeStart}-${data.rangeEnd}):\n\n${text}`;
            if (data.cursorNext) {
              result += `\n\n[More results available — use cursorNext: "${data.cursorNext}"]`;
            }
    
            return { content: [{ type: "text" as const, text: result }] };
          } catch (error) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `Error querying billing: ${error instanceof Error ? error.message : String(error)}`,
                },
              ],
              isError: true,
            };
          }
        }
      );
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden. It successfully discloses pagination limits (max 50 per page) and date formats (ISO dates), but fails to explicitly declare the read-only/safe nature of the operations implied by 'Query', or mention rate limits and authentication requirements.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear action-based sections and efficient bullet-style listings for entity filters. It is appropriately front-loaded with the primary purpose statement. Minor density in the filter list prevents a perfect score.

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 the tool's complexity (13 parameters across 3 actions and multiple entities), the description adequately maps parameters to their applicable actions and entities. While it lacks output schema details, the rules indicate this is not required; however, it could briefly clarify what 'coin_stats' returns.

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?

Although schema description coverage is 100%, the description adds value by organizing parameters into entity-specific filter groups (payments, fees, plans) that are presented as a flat list in the schema. This contextual grouping helps agents understand which parameters combine logically.

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 opens with the specific verb 'Query' and resource 'billing/financial data in OfficeRnD', clearly distinguishing it from siblings like 'space', 'community', and 'settings'. It further clarifies scope by detailing the three distinct actions (list, get, coin_stats) and their specific purposes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear guidance on when to use each internal action (list for filtered enumeration with pagination, get for single entity retrieval by ID, coin_stats for credit balances), effectively guiding selection between modes. However, it does not explicitly contrast with sibling tools or state when NOT to use this tool.

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/MrBoor/officernd-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server