Skip to main content
Glama
crazyrabbitLTC

Brex MCP Server

upload_receipt

Upload receipt images to match with business expenses in the Brex financial platform. Submit base64-encoded image data with file name and content type for expense tracking.

Instructions

Upload a receipt image to match with expenses

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
receipt_dataYesBase64-encoded image data
receipt_nameYesName of the receipt file (e.g., 'receipt.jpg')
content_typeYesMIME type of the receipt (e.g., 'image/jpeg')

Implementation Reference

  • Core execution handler for the upload_receipt tool: validates input, decodes base64 receipt, uploads via helper, returns JSON response with receipt ID.
    registerToolHandler("upload_receipt", async (request: ToolCallRequest) => {
      try {
        // Validate parameters
        const params = validateParams(request.params.arguments);
        logDebug(`Uploading receipt named: ${params.receipt_name}`);
        
        // Get Brex client
        const brexClient = getBrexClient();
        
        try {
          // Upload receipt to Brex using our helper function
          const uploadResult = await uploadReceipt(brexClient, {
            file: Buffer.from(params.receipt_data, 'base64'),
            filename: params.receipt_name,
            contentType: params.content_type
          });
          
          if (!uploadResult || !uploadResult.id) {
            throw new Error("Invalid response from receipt upload");
          }
          
          logDebug(`Successfully uploaded receipt with ID: ${uploadResult.id}`);
          
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                status: "success",
                receipt_id: uploadResult.id,
                message: `Receipt uploaded successfully with ID: ${uploadResult.id}`
              }, null, 2)
            }]
          };
        } catch (apiError) {
          logError(`Error uploading receipt: ${apiError instanceof Error ? apiError.message : String(apiError)}`);
          throw new Error(`Failed to upload receipt: ${apiError instanceof Error ? apiError.message : String(apiError)}`);
        }
      } catch (error) {
        logError(`Error in upload_receipt tool: ${error instanceof Error ? error.message : String(error)}`);
        throw error;
      }
    });
  • Official MCP input schema for upload_receipt tool, defining required base64 data, filename, and content type.
    name: "upload_receipt",
    description: "Upload a receipt image to match with expenses",
    inputSchema: {
      type: "object",
      properties: {
        receipt_data: {
          type: "string",
          description: "Base64-encoded image data"
        },
        receipt_name: {
          type: "string",
          description: "Name of the receipt file (e.g., 'receipt.jpg')"
        },
        content_type: {
          type: "string",
          description: "MIME type of the receipt (e.g., 'image/jpeg')"
        }
      },
      required: ["receipt_data", "receipt_name", "content_type"]
    }
  • Top-level registration call for the upload_receipt tool during server setup.
    registerUploadReceipt(server);
  • Helper function implementing the receipt upload logic to Brex (simulated for demo).
    async function uploadReceipt(client: BrexClient, options: UploadReceiptOptions): Promise<UploadReceiptResult> {
      // This is a fake implementation since the actual method doesn't exist
      // In a real implementation, you would use the proper Brex API endpoint
      logDebug(`Simulating receipt upload for ${options.filename} (${options.contentType})`);
      
      try {
        // Here we would use the proper Brex API method
        // For example, it might be something like client.api.post('/receipts/upload', formData)
        
        // Simulate API delay
        await new Promise(resolve => setTimeout(resolve, 500));
        
        // Return a fake successful result
        return {
          id: `receipt-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`,
          url: `https://api.brex.com/receipts/download/${Date.now()}`
        };
      } catch (error) {
        logError(`Failed to upload receipt: ${error instanceof Error ? error.message : String(error)}`);
        throw new Error(`Receipt upload failed: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Parameter validation helper ensuring required receipt_data and receipt_name are present.
    function validateParams(input: any): UploadReceiptParams {
      if (!input) {
        throw new Error("Missing parameters");
      }
      
      if (!input.receipt_data) {
        throw new Error("Missing required parameter: receipt_data");
      }
      
      if (!input.receipt_name) {
        throw new Error("Missing required parameter: receipt_name");
      }
      
      const params: UploadReceiptParams = {
        receipt_data: input.receipt_data,
        receipt_name: input.receipt_name,
        content_type: input.content_type || 'application/pdf'
      };
      
      return params;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It states the upload purpose but doesn't disclose permissions needed, rate limits, whether this creates a new expense record, how matching works, or what happens on failure. For a mutation tool with zero annotation coverage, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized for a straightforward upload operation and front-loads the core action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after upload (e.g., returns a match ID, creates an expense), error conditions, or system behavior. The agent lacks critical context to use this tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, providing complete parameter documentation (base64 data, filename, MIME type). The description adds no parameter-specific information beyond what's in the schema, so it meets the baseline for high schema coverage without compensating value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Upload') and resource ('a receipt image'), with the purpose 'to match with expenses' providing specific context. It distinguishes from most sibling tools (which are primarily 'get' operations), though it doesn't explicitly differentiate from 'match_receipt' which appears related.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'match_receipt' or 'update_expense'. It doesn't mention prerequisites, sequencing, or exclusion criteria, leaving the agent to infer usage context from the purpose alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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