Skip to main content
Glama

get_card_expense

Retrieve detailed information for a specific Brex card expense using 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
expandNo
expense_idYesCard expense ID

Implementation Reference

  • The core handler function registered for 'get_card_expense' tool. Validates parameters, fetches the card expense via BrexClient, formats as JSON, and handles errors.
    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 and validation function for input parameters to the get_card_expense tool (expense_id required, expand optional).
    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; }
  • MCP protocol input schema definition for the get_card_expense tool, exposed in listTools 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"] }
  • Registration call that invokes the tool's register function during server setup.
    registerGetCardExpenseById(server);
  • Exported registration function that sets up the tool handler using registerToolHandler.
    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; } }); }

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