Skip to main content
Glama

get_expense

Retrieve detailed expense information from Brex financial platform by providing a specific expense ID to access complete expense data and related 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
expandNo
expense_idYesExpense ID

Implementation Reference

  • The core handler function for the 'get_expense' tool. Validates input parameters, fetches the specific expense using BrexClient.getExpense, formats it as JSON, and returns it as text content.
    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 input schema for the 'get_expense' tool, defining required 'expense_id' and optional 'expand' array, used in the listTools response.
    inputSchema: { type: "object", properties: { expense_id: { type: "string", description: "Expense ID" }, expand: { type: "array", items: { type: "string" } } }, required: ["expense_id"] }
  • Registration call for the 'get_expense' tool handler during server setup in registerTools function.
    registerGetExpenseById(server);
  • The registration function exported from getExpenseById.ts, which registers the tool handler with name 'get_expense' using registerToolHandler.
    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; } }); }
  • TypeScript interface and validation function for input parameters of 'get_expense' tool.
    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; }

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