Skip to main content
Glama
crazyrabbitLTC

Brex MCP Server

get_expense

Retrieve detailed expense information from Brex by providing a specific expense ID, returning the complete expense object with optional merchant details.

Instructions

Get a single expense by ID. Returns the complete expense object. Example: {"expense_id":"expense_123","expand":["merchant"]}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expense_idYesExpense ID
expandNo

Implementation Reference

  • Core execution logic for the get_expense tool: parameter validation, Brex API call to retrieve single expense by ID with optional expand fields, returns JSON-formatted response.
    registerToolHandler("get_expense", async (request: ToolCallRequest) => {
      try {
        const params = validateParams(request.params.arguments);
        const client = getBrexClient();
        const expense = await client.getExpense(params.expense_id, { expand: params.expand });
        return {
          content: [{
            type: "text",
            text: JSON.stringify(expense, null, 2)
          }]
        };
      } catch (error) {
        logError(`Error in get_expense: ${error instanceof Error ? error.message : String(error)}`);
        throw error;
      }
    });
  • TypeScript interface and validation function defining the input schema for get_expense: requires expense_id (string), optional expand (string array).
    interface GetExpenseParams {
      expense_id: string;
      expand?: string[];
    }
    
    function validateParams(input: unknown): GetExpenseParams {
      const raw = (input || {}) as Record<string, unknown>;
      if (!raw.expense_id) throw new Error("Missing required parameter: expense_id");
      const out: GetExpenseParams = { expense_id: String(raw.expense_id) };
      if (raw.expand !== undefined) out.expand = Array.isArray(raw.expand) ? raw.expand.map(String) : [String(raw.expand)];
      return out;
    }
  • Registers the get_expense tool handler by calling registerToolHandler with the name and async handler function.
    export function registerGetExpenseById(_server: Server): void {
      registerToolHandler("get_expense", async (request: ToolCallRequest) => {
        try {
          const params = validateParams(request.params.arguments);
          const client = getBrexClient();
          const expense = await client.getExpense(params.expense_id, { expand: params.expand });
          return {
            content: [{
              type: "text",
              text: JSON.stringify(expense, null, 2)
            }]
          };
        } catch (error) {
          logError(`Error in get_expense: ${error instanceof Error ? error.message : String(error)}`);
          throw error;
        }
      });
    }
  • JSON Schema definition for the get_expense tool input, used in the MCP list_tools response to describe parameters to the LLM.
    name: "get_expense",
    description: "Get a single expense by ID. Returns the complete expense object. Example: {\"expense_id\":\"expense_123\",\"expand\":[\"merchant\"]}",
    inputSchema: {
      type: "object",
      properties: {
        expense_id: { type: "string", description: "Expense ID" },
        expand: { type: "array", items: { type: "string" } }
      },
      required: ["expense_id"]
    }
  • Invokes the registerGetExpenseById function to add the get_expense tool during server tool registration in registerTools.
    registerGetExpenseById(server);
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves and returns an expense object, implying a read-only operation, but doesn't cover permissions, error handling, rate limits, or data format details. The example adds some context but lacks comprehensive behavioral traits.

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 front-loaded with the core purpose in the first sentence, followed by a concise example that illustrates usage. Every sentence earns its place, with no wasted words, making it efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (2 parameters, no output schema, no annotations), the description is minimally adequate. It covers the basic operation and provides an example, but lacks details on return values, error cases, or integration with sibling tools. It's complete enough for a simple retrieval tool but has clear gaps in guidance and behavioral context.

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?

Schema description coverage is 50% (only 'expense_id' has a description). The description adds value by mentioning the 'expand' parameter in the example, suggesting it can include related data like 'merchant', which isn't documented in the schema. However, it doesn't fully compensate for the lack of schema coverage, as it doesn't explain 'expand' options or constraints beyond the example.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get a single expense by ID. Returns the complete expense object.' It specifies the verb ('Get'), resource ('expense'), and scope ('single'), distinguishing it from sibling tools like 'get_all_expenses' or 'get_expenses' which retrieve multiple expenses. However, it doesn't explicitly differentiate from 'get_card_expense', which might also retrieve a single expense but for cards.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose this over 'get_expenses' for multiple expenses, 'get_card_expense' for card-specific expenses, or 'update_expense' for modifications. The example hints at usage but doesn't clarify context or exclusions.

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/crazyrabbitLTC/mcp-brex-server'

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