Skip to main content
Glama

get_pnl

Read-only

Compute Profit & Loss (P&L / net income / margin) by combining the Income tab with expense tabs. Examples: 'am I profitable this year', 'P&L for Q1', 'net income last quarter', 'what's my margin', 'P&L this year vs last' (YoY). Supports period comparison — YoY, MoM, QoQ, same-month-prev-year. Margin renders as multiplier in loss territory ('expenses 5.4× revenue') so the user gets a readable signal instead of '-436.9% margin'. Returns: { message, data: { revenue, expenses, netIncome, margin, comparison?, sampleMeta? } }.

Input Schema

NameRequiredDescriptionDefault
queryNoNatural language P&L question (e.g., 'P&L for Q1 2025', 'am I profitable')
dateRangeNoTime period filter; use exactly one variant matching the user's phrasing.
clientEmailNoAccepted client's account email (accountants only).

Output Schema

NameRequiredDescriptionDefault
dataNoInline branch: computed analytics, or null when no spreadsheet / no data.
typeNoAsync branch only: "analytics_pending" — poll pollEndpoint or call poll_analytics with jobId.
jobIdNoAsync branch only.
messageNoHuman-readable narrative (both branches).
successNoAsync branch only.
responseNoChat alias of message.
pollEndpointNoAsync branch only.
pollIntervalNoAsync branch only: milliseconds.
estimatedTimeNoAsync branch only: seconds.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changed
    • changedInput schema / properties / clientEmail / description
      Previous value: -"Client account email. Accountants may use this only for an accepted ExpenseBot client."New value: +"Accepted client's account email (accountants only)."
    • changedInput schema / properties / dateRange / description
      Previous value: -"Time period filter. Use exactly one variant — pick the shape that matches the user's phrasing."New value: +"Time period filter; use exactly one variant matching the user's phrasing."
    • changedInput schema / properties / dateRange / oneOf
      Previous value: -[
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "month": {
      -        "description": "Month name or 1-12 (e.g., 'March' or '3')",
      -        "type": "string"
      -      },
      -      "type": {
      -        "const": "month",
      -        "type": "string"
      -      },
      -      "year": {
      -        "description": "4-digit year (e.g., 2026)",
      -        "type": "integer"
      -      }
      -    },
      -    "required": [
      -      "type",
      -      "month",
      -      "year"
      -    ],
      -    "title": "Specific month",
      -    "type": "object"
      -  },
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "quarter": {
      -        "maximum": 4,
      -        "minimum": 1,
      -        "type": "integer"
      -      },
      -      "type": {
      -        "const": "quarter",
      -        "type": "string"
      -      },
      -      "year": {
      -        "type": "integer"
      -      }
      -    },
      -    "required": [
      -      "type",
      -      "quarter",
      -      "year"
      -    ],
      -    "title": "Quarter of a year",
      -    "type": "object"
      -  },
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "type": {
      -        "const": "year",
      -        "type": "string"
      -      },
      -      "year": {
      -        "type": "integer"
      -      }
      -    },
      -    "required": [
      -      "type",
      -      "year"
      -    ],
      -    "title": "Full year",
      -    "type": "object"
      -  },
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "end": {
      -        "description": "ISO date YYYY-MM-DD (inclusive)",
      -        "format": "date",
      -        "type": "string"
      -      },
      -      "start": {
      -        "description": "ISO date YYYY-MM-DD (inclusive)",
      -        "format": "date",
      -        "type": "string"
      -      },
      -      "type": {
      -        "const": "specific",
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "type",
      -      "start",
      -      "end"
      -    ],
      -    "title": "Specific date range",
      -    "type": "object"
      -  },
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "type": {
      -        "const": "relative",
      -        "type": "string"
      -      },
      -      "value": {
      -        "description": "Relative range phrase, e.g., 'last month', 'YTD', 'this quarter', 'last 7 days'",
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "type",
      -      "value"
      -    ],
      -    "title": "Relative natural-language range",
      -    "type": "object"
      -  }
      -]New value: +[
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "month": {
      +        "description": "Month name or 1-12 (e.g., 'March' or '3')",
      +        "type": "string"
      +      },
      +      "type": {
      +        "const": "month",
      +        "type": "string"
      +      },
      +      "year": {
      +        "description": "4-digit year (e.g., 2026)",
      +        "type": "integer"
      +      }
      +    },
      +    "required": [
      +      "type",
      +      "month",
      +      "year"
      +    ],
      +    "title": "Specific month",
      +    "type": "object"
      +  },
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "quarter": {
      +        "maximum": 4,
      +        "minimum": 1,
      +        "type": "integer"
      +      },
      +      "type": {
      +        "const": "quarter",
      +        "type": "string"
      +      },
      +      "year": {
      +        "type": "integer"
      +      }
      +    },
      +    "required": [
      +      "type",
      +      "quarter",
      +      "year"
      +    ],
      +    "title": "Quarter of a year",
      +    "type": "object"
      +  },
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "type": {
      +        "const": "year",
      +        "type": "string"
      +      },
      +      "year": {
      +        "type": "integer"
      +      }
      +    },
      +    "required": [
      +      "type",
      +      "year"
      +    ],
      +    "title": "Full year",
      +    "type": "object"
      +  },
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "end": {
      +        "description": "ISO date YYYY-MM-DD (inclusive)",
      +        "format": "date",
      +        "type": "string"
      +      },
      +      "start": {
      +        "description": "ISO date YYYY-MM-DD (inclusive)",
      +        "format": "date",
      +        "type": "string"
      +      },
      +      "type": {
      +        "const": "specific",
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "type",
      +      "start",
      +      "end"
      +    ],
      +    "title": "Specific date range",
      +    "type": "object"
      +  },
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "type": {
      +        "const": "relative",
      +        "type": "string"
      +      },
      +      "value": {
      +        "description": "Relative phrase, e.g. 'last month', 'YTD', 'last 7 days'",
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "type",
      +      "value"
      +    ],
      +    "title": "Relative natural-language range",
      +    "type": "object"
      +  }
      +]
    • changedOutput schema / description
      Previous value: -"Two branches. Async: type='analytics_pending' with jobId — poll poll_analytics until complete. Inline: message + data with the computed analytics (data may be null when there is no spreadsheet or no data yet). success is present only on the async branch."New value: +"Async: type='analytics_pending' with jobId (poll poll_analytics). Inline: message + data (data may be null). success only on the async branch."
  2. Changed1 schema field changed
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "additionalProperties": true,
      +  "description": "Two branches. Async: type='analytics_pending' with jobId — poll poll_analytics until complete. Inline: message + data with the computed analytics (data may be null when there is no spreadsheet or no data yet). success is present only on the async branch.",
      +  "properties": {
      +    "data": {
      +      "additionalProperties": true,
      +      "description": "Inline branch: computed analytics, or null when no spreadsheet / no data.",
      +      "type": [
      +        "object",
      +        "null"
      +      ]
      +    },
      +    "estimatedTime": {
      +      "description": "Async branch only: seconds.",
      +      "type": "number"
      +    },
      +    "jobId": {
      +      "description": "Async branch only.",
      +      "type": "string"
      +    },
      +    "message": {
      +      "description": "Human-readable narrative (both branches).",
      +      "type": "string"
      +    },
      +    "pollEndpoint": {
      +      "description": "Async branch only.",
      +      "type": "string"
      +    },
      +    "pollInterval": {
      +      "description": "Async branch only: milliseconds.",
      +      "type": "number"
      +    },
      +    "response": {
      +      "description": "Chat alias of message.",
      +      "type": "string"
      +    },
      +    "success": {
      +      "description": "Async branch only.",
      +      "type": "boolean"
      +    },
      +    "type": {
      +      "description": "Async branch only: \"analytics_pending\" — poll pollEndpoint or call poll_analytics with jobId.",
      +      "type": "string"
      +    }
      +  },
      +  "required": [],
      +  "type": "object"
      +}
  3. Changed1 schema field changed
    • changedOutput schema / (root)
      Previous value: -{
      -  "additionalProperties": true,
      -  "description": "Standard ExpenseBot tool result envelope. `message` is the human-readable summary the AI cites; `data` is the structured payload (totals, breakdowns, ids, etc.). On failure, `success` is false and `error` carries a code/message/hint triple.",
      -  "properties": {
      -    "data": {
      -      "additionalProperties": true,
      -      "description": "Structured payload. Shape varies per tool — common keys: total, breakdown, comparison, sampleMeta, ids, expenseId, reportId, signupUrl, results.",
      -      "type": "object"
      -    },
      -    "error": {
      -      "additionalProperties": true,
      -      "description": "Present only when success === false.",
      -      "properties": {
      -        "code": {
      -          "type": "string"
      -        },
      -        "hint": {
      -          "type": "string"
      -        },
      -        "message": {
      -          "type": "string"
      -        }
      -      },
      -      "type": "object"
      -    },
      -    "message": {
      -      "description": "Human-readable result text. Always present on success; prefer rendering this verbatim before any further reasoning.",
      -      "type": "string"
      -    },
      -    "sampleMeta": {
      -      "additionalProperties": true,
      -      "description": "Set when the underlying dataset was truncated. isTruncated=true means the agent saw a sample of `sampleCount` of `totalCount` rows; aggregate totals are still accurate.",
      -      "properties": {
      -        "isTruncated": {
      -          "type": "boolean"
      -        },
      -        "sampleCount": {
      -          "type": "integer"
      -        },
      -        "totalCount": {
      -          "type": "integer"
      -        }
      -      },
      -      "type": "object"
      -    },
      -    "success": {
      -      "description": "False on tool errors; check before reading `data`.",
      -      "type": "boolean"
      -    }
      -  },
      -  "type": "object"
      -}New value: +null
  4. First observed

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare readOnly=true and destructive=false, so safety is covered. The description adds genuine behavioral detail beyond that: period-comparison modes supported (YoY/MoM/QoQ/same-month-prev-year) and the non-obvious loss-margin rendering as a multiplier rather than a negative percentage, which is exactly the kind of surprise an agent should be warned about.

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 purpose, trigger examples, comparison modes, and return shape appear in that order with no filler; the margin-multiplier note is a single justified sentence preventing misread output. It is dense but every clause carries signal.

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?

For a read-only reporting tool with full schema coverage and an output schema, the description supplies what's needed: what it combines, what periods/comparisons are legal, and what the payload contains. Minor gap: no guidance on default period when no dateRange is supplied (0 required params).

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 coverage is 100%, so the baseline is 3; the description earns above baseline by explaining that comparison types are driven from the natural-language query and by mapping example phrasings to dateRange styles. It does not add much on clientEmail, but the schema already documents it as accountant-only.

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?

States a specific verb and resource ('Compute Profit & Loss ... by combining the Income tab with expense tabs') and enumerates the metrics produced (net income, margin). The examples cement scope so an agent can distinguish it from income-only siblings like get_income_summary or get_per_tag_pnl.

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?

Provides concrete trigger phrasings ('am I profitable this year', 'P&L for Q1', 'what's my margin', YoY comparison), which is clear usage context. It stops short of naming alternatives or stating when NOT to use it (e.g., use get_per_tag_pnl for per-tag breakdowns, get_income_summary for revenue-only).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.