Skip to main content
Glama

match_receipt

Generate a pre-signed URL to upload a receipt for automatic matching with existing expenses in the Brex financial platform.

Instructions

Create a pre-signed URL for uploading a receipt that will be automatically matched with existing expenses

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
notify_emailNoEmail address to notify after matching (optional)
receipt_nameYesName of the receipt file (e.g., 'receipt.jpg')
receipt_typeNoType of the receipt (optional)

Implementation Reference

  • Main execution handler for the 'match_receipt' tool. Validates parameters, uses Brex client to create a receipt match request, obtains pre-signed upload URL, and returns structured response with upload instructions.
    registerToolHandler("match_receipt", async (request: ToolCallRequest) => { try { // Validate parameters const params = validateParams(request.params.arguments); logDebug(`Creating receipt match for: ${params.receipt_name}`); // Get Brex client const brexClient = getBrexClient(); try { // Create receipt match request to get pre-signed URL const matchResult = await createReceiptMatch(brexClient, { receipt_name: params.receipt_name, receipt_type: params.receipt_type, notify_email: params.notify_email }); logDebug(`Successfully created receipt match with ID: ${matchResult.id}`); return { content: [{ type: "text", text: JSON.stringify({ status: "success", receipt_id: matchResult.id, upload_url: matchResult.uri, message: "Receipt match created successfully. Use the provided URL to upload the receipt file.", instructions: "1. Use this pre-signed URL with a PUT request to upload your receipt.\n2. The URL expires in 30 minutes.\n3. Once uploaded, Brex will automatically try to match the receipt with existing expenses." }, null, 2) }] }; } catch (apiError) { logError(`Error creating receipt match: ${apiError instanceof Error ? apiError.message : String(apiError)}`); throw new Error(`Failed to create receipt match: ${apiError instanceof Error ? apiError.message : String(apiError)}`); } } catch (error) { logError(`Error in match_receipt tool: ${error instanceof Error ? error.message : String(error)}`); throw error; } });
  • TypeScript interface defining the expected input parameters for the match_receipt tool.
    interface MatchReceiptParams { receipt_name: string; receipt_type?: string; notify_email?: string; }
  • Helper function that invokes the Brex API endpoint '/v1/expenses/card/receipt_match' to generate a pre-signed URL for receipt upload and automatic matching.
    async function createReceiptMatch(client: BrexClient, request: ReceiptMatchRequest): Promise<ReceiptMatchResponse> { try { logDebug(`Creating receipt match request for ${request.receipt_name}`); // Make API call to Brex to get pre-signed URL const response = await client.post('/v1/expenses/card/receipt_match', request); // Validate the response if (!response || !response.id || !response.uri) { throw new Error("Invalid response from receipt match request"); } return { id: response.id, uri: response.uri }; } catch (error) { logError(`Failed to create receipt match: ${error instanceof Error ? error.message : String(error)}`); throw new Error(`Receipt match request failed: ${error instanceof Error ? error.message : String(error)}`); } }
  • Validates and normalizes the raw input parameters into the MatchReceiptParams interface.
    function validateParams(input: any): MatchReceiptParams { if (!input) { throw new Error("Missing parameters"); } if (!input.receipt_name) { throw new Error("Missing required parameter: receipt_name"); } const params: MatchReceiptParams = { receipt_name: input.receipt_name, receipt_type: input.receipt_type, notify_email: input.notify_email }; return params; }
  • Registers the match_receipt tool handler with the tool handler registry.
    export function registerMatchReceipt(_server: Server): void { registerToolHandler("match_receipt", async (request: ToolCallRequest) => { try { // Validate parameters const params = validateParams(request.params.arguments); logDebug(`Creating receipt match for: ${params.receipt_name}`); // Get Brex client const brexClient = getBrexClient(); try { // Create receipt match request to get pre-signed URL const matchResult = await createReceiptMatch(brexClient, { receipt_name: params.receipt_name, receipt_type: params.receipt_type, notify_email: params.notify_email }); logDebug(`Successfully created receipt match with ID: ${matchResult.id}`); return { content: [{ type: "text", text: JSON.stringify({ status: "success", receipt_id: matchResult.id, upload_url: matchResult.uri, message: "Receipt match created successfully. Use the provided URL to upload the receipt file.", instructions: "1. Use this pre-signed URL with a PUT request to upload your receipt.\n2. The URL expires in 30 minutes.\n3. Once uploaded, Brex will automatically try to match the receipt with existing expenses." }, null, 2) }] }; } catch (apiError) { logError(`Error creating receipt match: ${apiError instanceof Error ? apiError.message : String(apiError)}`); throw new Error(`Failed to create receipt match: ${apiError instanceof Error ? apiError.message : String(apiError)}`); } } catch (error) { logError(`Error in match_receipt tool: ${error instanceof Error ? error.message : String(error)}`); throw error; } }); }
  • Official MCP input schema for the match_receipt tool as exposed in the listTools response.
    { name: "match_receipt", description: "Create a pre-signed URL for uploading a receipt that will be automatically matched with existing expenses", inputSchema: { type: "object", properties: { receipt_name: { type: "string", description: "Name of the receipt file (e.g., 'receipt.jpg')" }, receipt_type: { type: "string", description: "Type of the receipt (optional)" }, notify_email: { type: "string", description: "Email address to notify after matching (optional)" } }, required: ["receipt_name"] } },
  • Invocation of registerMatchReceipt during overall tools registration in registerTools function.
    registerMatchReceipt(server);
  • Import of the registerMatchReceipt function.
    import { registerMatchReceipt } from "./matchReceipt.js";

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