Skip to main content
Glama
crazyrabbitLTC

Brex MCP Server

get_card_expense

Retrieve detailed information for a specific Brex card expense by providing its unique ID, including merchant details and transaction data.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expense_idYesCard expense ID
expandNo

Implementation Reference

  • Core execution logic for the 'get_card_expense' tool: validates parameters, fetches card expense via BrexClient, returns formatted JSON response.
    registerToolHandler("get_card_expense", async (request: ToolCallRequest) => {
      try {
        const params = validateParams(request.params.arguments);
        const client = getBrexClient();
        const expense = await client.getCardExpense(params.expense_id, { expand: params.expand });
        return {
          content: [{
            type: "text",
            text: JSON.stringify(expense, null, 2)
          }]
        };
      } catch (error) {
        logError(`Error in get_card_expense: ${error instanceof Error ? error.message : String(error)}`);
        throw error;
      }
    });
  • Type definition (GetCardExpenseParams) and validation logic for tool input parameters.
    interface GetCardExpenseParams {
      expense_id: string;
      expand?: string[];
    }
    
    function validateParams(input: unknown): GetCardExpenseParams {
      const raw = (input || {}) as Record<string, unknown>;
      if (!raw.expense_id) throw new Error("Missing required parameter: expense_id");
      const out: GetCardExpenseParams = { 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;
    }
  • Official input schema for 'get_card_expense' tool as exposed in the MCP list_tools response.
    name: "get_card_expense",
    description: "Get a single card expense by ID. Returns the complete card expense object. Example: {\"expense_id\":\"expense_123\",\"expand\":[\"merchant\"]}",
    inputSchema: {
      type: "object",
      properties: {
        expense_id: { type: "string", description: "Card expense ID" },
        expand: { type: "array", items: { type: "string" } }
      },
      required: ["expense_id"]
    }
  • Top-level registration of the get_card_expense tool by calling the module's registration function during server setup.
    registerGetCardExpenseById(server);
  • Module-specific registration function that attaches the handler to the tool name 'get_card_expense'.
    export function registerGetCardExpenseById(_server: Server): void {
      registerToolHandler("get_card_expense", async (request: ToolCallRequest) => {
        try {
          const params = validateParams(request.params.arguments);
          const client = getBrexClient();
          const expense = await client.getCardExpense(params.expense_id, { expand: params.expand });
          return {
            content: [{
              type: "text",
              text: JSON.stringify(expense, null, 2)
            }]
          };
        } catch (error) {
          logError(`Error in get_card_expense: ${error instanceof Error ? error.message : String(error)}`);
          throw error;
        }
      });
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool returns a 'complete card expense object,' which hints at read-only behavior, but doesn't clarify if it's safe, requires authentication, has rate limits, or what happens on errors. For a tool with no annotations, this is insufficient detail.

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, followed by a concise example. Every sentence earns its place: the first defines the action, the second specifies the return, and the third provides a practical illustration. It's appropriately sized with zero waste.

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

Completeness2/5

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

Given no annotations, no output schema, and moderate schema coverage (50%), the description is incomplete. It lacks details on behavioral traits, error handling, and parameter usage beyond the example. For a tool with two parameters and no structured safety hints, this leaves significant gaps for an agent.

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 minimal value: it implies 'expense_id' is required and provides an example with 'expand' but doesn't explain what 'expand' does or its allowed values. Since schema coverage is moderate, the baseline is 3, and the description doesn't fully compensate for the gap.

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 card expense by ID.' It specifies the verb ('Get') and resource ('card expense'), and distinguishes it from siblings like 'get_all_card_expenses' by focusing on a single item. However, it doesn't explicitly differentiate from 'get_expense' (which might be similar), keeping it from a perfect score.

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_all_card_expenses' or 'get_expense', nor does it specify prerequisites or exclusions. This lack of context leaves the agent without usage direction.

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