get_budget
Retrieve complete budget details from the Brex financial platform by specifying a budget ID to access financial planning information.
Instructions
Get a budget by ID (read-only). Returns the complete budget object. Example: {"budget_id":"budget_123"}
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| budget_id | Yes | The ID of the budget to retrieve |
Implementation Reference
- src/tools/getBudgetById.ts:27-43 (handler)The core handler function for the 'get_budget' tool. It validates the input parameters, retrieves the Brex client, fetches the budget by ID, stringifies it to JSON, and returns it as text content. Includes error handling with logging.registerToolHandler("get_budget", async (request: ToolCallRequest) => { try { const params = validateParams(request.params.arguments); const client = getBrexClient(); const budget = await client.getBudget(params.budget_id); return { content: [{ type: "text", text: JSON.stringify({ budget }, null, 2) }] }; } catch (error) { logError(`Error in get_budget: ${error instanceof Error ? error.message : String(error)}`); throw error; } });
- src/tools/getBudgetById.ts:14-24 (schema)TypeScript interface defining the input parameters for get_budget and the validation function that ensures 'budget_id' is present and converts it to string.interface GetBudgetParams { budget_id: string; } function validateParams(input: unknown): GetBudgetParams { const raw = (input || {}) as Record<string, unknown>; if (!raw.budget_id) throw new Error("Missing required parameter: budget_id"); return { budget_id: String(raw.budget_id) }; }
- src/tools/getBudgetById.ts:26-44 (registration)The registration function exported from the tool file that sets up the 'get_budget' handler using registerToolHandler. This function is called from index.ts.export function registerGetBudgetById(_server: Server): void { registerToolHandler("get_budget", async (request: ToolCallRequest) => { try { const params = validateParams(request.params.arguments); const client = getBrexClient(); const budget = await client.getBudget(params.budget_id); return { content: [{ type: "text", text: JSON.stringify({ budget }, null, 2) }] }; } catch (error) { logError(`Error in get_budget: ${error instanceof Error ? error.message : String(error)}`); throw error; } }); }
- src/tools/index.ts:64-64 (registration)Top-level registration call in tools/index.ts that invokes registerGetBudgetById(server) to register the tool during server setup.registerGetBudgetById(server);
- src/tools/index.ts:98-108 (schema)The JSON schema for the 'get_budget' tool provided in the listTools response, defining the expected input structure for MCP clients.{ name: "get_budget", description: "Get a budget by ID (read-only). Returns the complete budget object. Example: {\"budget_id\":\"budget_123\"}", inputSchema: { type: "object", properties: { budget_id: { type: "string", description: "The ID of the budget to retrieve" } }, required: ["budget_id"] } },