Skip to main content
Glama

get_budgets

Retrieve and list budget information from the Brex financial platform, including active, archived, or draft budgets with pagination support.

Instructions

List budgets (read-only). Example: {"limit":10}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
cursorNo
parent_budget_idNo
spend_budget_statusNo

Implementation Reference

  • Main execution handler for the 'get_budgets' tool: validates input parameters, calls BrexClient.getBudgets(), formats and returns the paginated budgets as JSON.
    registerToolHandler("get_budgets", async (request: ToolCallRequest) => { try { const params = validateParams(request.params.arguments); const client = getBrexClient(); const apiParams: BudgetListParams = { limit: params.limit, cursor: params.cursor, parent_budget_id: params.parent_budget_id, spend_budget_status: params.spend_budget_status }; const resp = await client.getBudgets(apiParams); const items = Array.isArray(resp.items) ? resp.items : []; return { content: [{ type: "text", text: JSON.stringify({ budgets: items, meta: { count: items.length, next_cursor: resp.next_cursor || null } }, null, 2) }] }; } catch (error) { logError(`Error in get_budgets: ${error instanceof Error ? error.message : String(error)}`); throw error; } });
  • Input parameter type definition (GetBudgetsParams interface) and validation function used by the tool handler.
    interface GetBudgetsParams { limit?: number; cursor?: string; parent_budget_id?: string; spend_budget_status?: SpendBudgetStatus; } function validateParams(input: unknown): GetBudgetsParams { const raw = (input || {}) as Record<string, unknown>; const out: GetBudgetsParams = {}; if (raw.limit !== undefined) { const n = parseInt(String(raw.limit), 10); if (isNaN(n) || n <= 0 || n > 100) throw new Error("Invalid limit (1..100)"); out.limit = n; } if (raw.cursor !== undefined) out.cursor = String(raw.cursor); if (raw.parent_budget_id !== undefined) out.parent_budget_id = String(raw.parent_budget_id); if (raw.spend_budget_status !== undefined) out.spend_budget_status = String(raw.spend_budget_status) as SpendBudgetStatus; return out; }
  • Registration call that invokes the tool's register function during server initialization.
    registerGetBudgets(server);
  • Tool schema definition provided in the listTools response, including inputSchema for MCP client validation.
    name: "get_budgets", description: "List budgets (read-only). Example: {\"limit\":10}", inputSchema: { type: "object", properties: { limit: { type: "number" }, cursor: { type: "string" }, parent_budget_id: { type: "string" }, spend_budget_status: { type: "string", enum: ["ACTIVE","ARCHIVED","DRAFT"] } } } },
  • Brex API client method getBudgets() called by the tool handler to fetch budgets from the Brex /v2/budgets endpoint.
    async getBudgets(params?: BudgetListParams): Promise<BudgetsResponse> { try { logDebug('Fetching budgets from Brex API', { params }); return await this.get<BudgetsResponse>('/v2/budgets', params as unknown as Record<string, any>); } catch (error) { logError(`Error fetching budgets: ${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