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
| Name | Required | Description | Default |
|---|---|---|---|
| expense_id | Yes | Card expense ID | |
| expand | No |
Implementation Reference
- src/tools/getCardExpenseById.ts:28-43 (handler)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; }
- src/tools/index.ts:170-179 (schema)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"] }
- src/tools/index.ts:59-59 (registration)Top-level registration of the get_card_expense tool by calling the module's registration function during server setup.registerGetCardExpenseById(server);
- src/tools/getCardExpenseById.ts:27-44 (registration)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; } }); }