Skip to main content
Glama

search_expenses

Read-only

Search and filter the user's expenses. Returns matching expense rows from their spreadsheet. Filter by category, merchant, date range, amount, or tags. Results are paginated: when hasMore is true, call again with nextCursor and the same filters. Do not split a date range into repeated overlapping searches.

Use the optional query parameter for deterministic natural-language recall over merchant, city/location, Notes (including receipt items, delivery source, payer, and Business purpose), Tag, and category. Each matching result includes matchedFields and a short matchReason so you can explain why it was selected. When several rows plausibly match, a disambiguation list is returned; each option carries the exact expenseId. Structured filters (categories, merchants, dateRange, tags, minAmount, maxAmount) combine with the query using AND semantics. Each result includes expenseId, the exact durable Receipt ID required by update_expense.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tagsNoFilter by tags
limitNoResults per page (default 20, maximum 50)
queryNoOptional natural-language recall over the user's existing expense fields (merchant, city/location, Notes including receipt items, delivery source, payer, and Business purpose, Tag, category). Deterministic case-insensitive matching — no embeddings or model classifiers. Combine with structured filters using AND semantics. Examples: 'Tribeca restaurant', 'Bodewell project hardware store', 'client dinner note'.
cursorNoOpaque nextCursor returned by the previous search_expenses page. Reuse the same filters; never construct or edit this value.
dateRangeNoTime period filter. Use exactly one variant — pick the shape that matches the user's phrasing.
maxAmountNoMaximum expense amount
merchantsNoFilter by merchant names (e.g., ['Uber', 'Starbucks'])
minAmountNoMinimum expense amount
categoriesNoFilter by expense categories (e.g., ['Travel', 'Meals'])
hasReceiptNoWhen true, return only expenses with a receipt link. When false, return only expenses without one.
clientEmailNoClient account email. Accountants may use this only for an accepted ExpenseBot client.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
countYesRows matched by the filters.
totalYesSum of the matched set in home currency.
hasMoreNo
messageNo
expensesYesMatching expense rows, newest first, paginated.
pageInfoNo
nextCursorNoOpaque signed continuation; reuse with identical filters.
queryAppliedNo
totalMatchedNoPresent for free-text searches.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed15 schema fields changed
    • removedOutput schema / description
      Removed value: -"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."
    • addedOutput schema / properties / count
      Added value: +{
      +  "description": "Rows matched by the filters.",
      +  "type": "integer"
      +}
    • removedOutput schema / properties / data
      Removed value: -{
      -  "additionalProperties": true,
      -  "description": "Structured payload. Shape varies per tool — common keys: total, breakdown, comparison, sampleMeta, ids, expenseId, reportId, signupUrl, results.",
      -  "type": "object"
      -}
    • removedOutput schema / properties / error
      Removed value: -{
      -  "additionalProperties": true,
      -  "description": "Present only when success === false.",
      -  "properties": {
      -    "code": {
      -      "type": "string"
      -    },
      -    "hint": {
      -      "type": "string"
      -    },
      -    "message": {
      -      "type": "string"
      -    }
      -  },
      -  "type": "object"
      -}
    • addedOutput schema / properties / expenses
      Added value: +{
      +  "description": "Matching expense rows, newest first, paginated.",
      +  "items": {
      +    "additionalProperties": true,
      +    "properties": {
      +      "amount": {
      +        "description": "Functional/home-currency amount.",
      +        "type": "number"
      +      },
      +      "category": {
      +        "type": "string"
      +      },
      +      "currency": {
      +        "description": "Home currency code when available.",
      +        "type": "string"
      +      },
      +      "date": {
      +        "type": "string"
      +      },
      +      "dateIso": {
      +        "description": "Canonical YYYY-MM-DD when available.",
      +        "type": "string"
      +      },
      +      "expenseId": {
      +        "description": "Durable Receipt ID (Column Q). The only identity accepted by update_expense.",
      +        "type": "string"
      +      },
      +      "location": {
      +        "type": "string"
      +      },
      +      "matchReason": {
      +        "type": "string"
      +      },
      +      "matchedFields": {
      +        "items": {
      +          "type": "string"
      +        },
      +        "type": "array"
      +      },
      +      "merchant": {
      +        "type": "string"
      +      },
      +      "originalAmount": {
      +        "type": "number"
      +      },
      +      "originalCurrency": {
      +        "type": "string"
      +      },
      +      "tag": {
      +        "description": "Column K group (client/project/trip).",
      +        "type": "string"
      +      },
      +      "updateEligible": {
      +        "type": "boolean"
      +      }
      +    },
      +    "required": [
      +      "expenseId",
      +      "date",
      +      "amount",
      +      "tag",
      +      "updateEligible"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / hasMore
      Added value: +{
      +  "type": "boolean"
      +}
    • removedOutput schema / properties / message / description
      Removed value: -"Human-readable result text. Always present on success; prefer rendering this verbatim before any further reasoning."
    • addedOutput schema / properties / nextCursor
      Added value: +{
      +  "description": "Opaque signed continuation; reuse with identical filters.",
      +  "type": [
      +    "string",
      +    "null"
      +  ]
      +}
    • addedOutput schema / properties / pageInfo
      Added value: +{
      +  "additionalProperties": true,
      +  "type": "object"
      +}
    • addedOutput schema / properties / queryApplied
      Added value: +{
      +  "type": "string"
      +}
    • removedOutput schema / properties / sampleMeta
      Removed value: -{
      -  "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"
      -}
    • removedOutput schema / properties / success
      Removed value: -{
      -  "description": "False on tool errors; check before reading `data`.",
      -  "type": "boolean"
      -}
    • addedOutput schema / properties / total
      Added value: +{
      +  "description": "Sum of the matched set in home currency.",
      +  "type": "number"
      +}
    • addedOutput schema / properties / totalMatched
      Added value: +{
      +  "description": "Present for free-text searches.",
      +  "type": "integer"
      +}
    • addedOutput schema / required
      Added value: +[
      +  "expenses",
      +  "count",
      +  "total"
      +]
  2. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Well beyond the annotations' read-only/open-world profile: it discloses pagination contract (hasMore/nextCursor), non-determinism is explicitly ruled out, disambiguation-list behavior, matchedFields/matchReason on each row, AND semantics between query and filters, and that expenseId is the exact durable ID required by update_expense.

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?

Front-loads purpose and result semantics, then moves to pagination and query behavior. Two dense paragraphs with essentially no filler, though the return-field recap (matchedFields, expenseId) is more verbose than strictly needed given an output schema exists.

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?

For an 11-parameter, zero-required search tool with an output schema, the description covers everything an agent needs to invoke it correctly: filter combination rules, pagination loop, query matching scope, and disambiguation handling. Nothing material is missing.

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, but the description adds real value: it defines what the free-text query matcher covers (merchant, city/location, Notes, Tag, category), asserts deterministic case-insensitive matching, and specifies that query combines with structured filters via AND. The cursor semantics are also reinforced beyond the schema.

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+resource ('Search and filter the user's expenses') and immediately scopes the result set to the user's spreadsheet rows. An agent can distinguish this from get_expense_by_id, search, and search_knowledge without opening any schema.

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?

Gives concrete operational guidance: paginate via nextCursor with the same filters when hasMore is true, don't split a date range into overlapping searches, use query for natural-language recall, and combine it with structured filters via AND. It stops short of naming sibling alternatives (e.g., get_expense_by_id for a known ID, search_knowledge for docs), so no explicit when-not routing.

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.