Skip to main content
Glama
crazyrabbitLTC

Brex MCP Server

get_budget_programs

Retrieve budget program details from Brex to view active or inactive spending limits and financial allocations.

Instructions

List budget programs (read-only). Returns complete budget program objects. Example: {"limit":10,"budget_program_status":"ACTIVE"}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
cursorNo
budget_program_statusNo

Implementation Reference

  • Main handler function for the 'get_budget_programs' tool: validates input parameters, calls the Brex API via client, processes response, and returns formatted JSON.
    registerToolHandler("get_budget_programs", async (request: ToolCallRequest) => {
      try {
        const params = validateParams(request.params.arguments);
        const client = getBrexClient();
        
        const apiParams: BudgetProgramListParams = {
          limit: params.limit,
          cursor: params.cursor,
          budget_program_status: params.budget_program_status
        };
        
        const resp = await client.getBudgetPrograms(apiParams);
        const items = Array.isArray(resp.items) ? resp.items : [];
        
        return { 
          content: [{ 
            type: "text", 
            text: JSON.stringify({ 
              budget_programs: items, 
              meta: { 
                count: items.length, 
                next_cursor: resp.next_cursor || null 
              } 
            }, null, 2) 
          }] 
        };
      } catch (error) {
        logError(`Error in get_budget_programs: ${error instanceof Error ? error.message : String(error)}`);
        throw error;
      }
    });
  • TypeScript interface defining input parameters for the get_budget_programs tool.
    interface GetBudgetProgramsParams {
      limit?: number;
      cursor?: string;
      budget_program_status?: BudgetProgramStatus;
    }
  • Registration function that sets up the 'get_budget_programs' tool handler using registerToolHandler.
    export function registerGetBudgetPrograms(_server: Server): void {
      registerToolHandler("get_budget_programs", async (request: ToolCallRequest) => {
        try {
          const params = validateParams(request.params.arguments);
          const client = getBrexClient();
          
          const apiParams: BudgetProgramListParams = {
            limit: params.limit,
            cursor: params.cursor,
            budget_program_status: params.budget_program_status
          };
          
          const resp = await client.getBudgetPrograms(apiParams);
          const items = Array.isArray(resp.items) ? resp.items : [];
          
          return { 
            content: [{ 
              type: "text", 
              text: JSON.stringify({ 
                budget_programs: items, 
                meta: { 
                  count: items.length, 
                  next_cursor: resp.next_cursor || null 
                } 
              }, null, 2) 
            }] 
          };
        } catch (error) {
          logError(`Error in get_budget_programs: ${error instanceof Error ? error.message : String(error)}`);
          throw error;
        }
      });
    }
  • Invocation of the registerGetBudgetPrograms function within the overall registerTools function.
    registerGetBudgetPrograms(server);
  • JSON input schema definition for the 'get_budget_programs' tool in the listTools response.
    name: "get_budget_programs",
    description: "List budget programs (read-only). Returns complete budget program objects. Example: {\"limit\":10,\"budget_program_status\":\"ACTIVE\"}",
    inputSchema: {
      type: "object",
      properties: {
        limit: { type: "number" },
        cursor: { type: "string" },
        budget_program_status: { type: "string", enum: ["ACTIVE","INACTIVE"] }
      }
    }
  • Helper function to validate and parse input parameters for the tool.
    function validateParams(input: unknown): GetBudgetProgramsParams {
      const raw = (input || {}) as Record<string, unknown>;
      const out: GetBudgetProgramsParams = {};
      
      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.budget_program_status !== undefined) {
        out.budget_program_status = String(raw.budget_program_status) as BudgetProgramStatus;
      }
      
      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