Skip to main content
Glama

expense_add

Add new expense entries to track business spending with detailed categorization, vendor information, and financial data for accurate accounting and reporting.

Instructions

Add a new expense entry

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amountYes
categoryYes
costCenterNo
dateYes
descriptionNo
expenseIdYes
invoiceNumberNo
projectIdNo
recurringNo
recurringFrequencyNo
subcategoryNo
tagsNo
taxDeductibleNo
vendorIdYes

Implementation Reference

  • JS handler function for 'expense_add' tool that delegates to Python ExpenseTracker.add_expense via PythonBridge
    handler: async (args: any): Promise<ToolResult> => { try { const result = await pythonBridge.callPythonFunction({ module: 'expense_tracking', function: 'ExpenseTracker.add_expense', args: [], kwargs: { expense: args } }); return result; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } }
  • Input schema defining parameters for adding an expense
    inputSchema: { type: "object", properties: { expenseId: { type: "string" }, date: { type: "string", format: "date" }, vendorId: { type: "string" }, amount: { type: "number" }, category: { type: "string", enum: [ "Rent/Lease", "Utilities", "Salaries & Wages", "Employee Benefits", "Insurance", "Marketing & Advertising", "Office Supplies", "Maintenance & Repairs", "Professional Fees", "Travel & Entertainment", "Raw Materials", "Inventory Purchases", "Freight & Shipping", "Equipment", "Property", "Vehicles", "Software", "Interest Expense", "Bank Fees", "Taxes", "Depreciation", "Amortization", "Other" ] }, subcategory: { type: "string" }, description: { type: "string" }, invoiceNumber: { type: "string" }, costCenter: { type: "string" }, projectId: { type: "string" }, tags: { type: "array", items: { type: "string" } }, taxDeductible: { type: "boolean", default: true }, recurring: { type: "boolean", default: false }, recurringFrequency: { type: "string" } }, required: ["expenseId", "date", "vendorId", "amount", "category"] },
  • Tool definition object registered in the exported expenseTools array
    { name: "expense_add", description: "Add a new expense entry", inputSchema: { type: "object", properties: { expenseId: { type: "string" }, date: { type: "string", format: "date" }, vendorId: { type: "string" }, amount: { type: "number" }, category: { type: "string", enum: [ "Rent/Lease", "Utilities", "Salaries & Wages", "Employee Benefits", "Insurance", "Marketing & Advertising", "Office Supplies", "Maintenance & Repairs", "Professional Fees", "Travel & Entertainment", "Raw Materials", "Inventory Purchases", "Freight & Shipping", "Equipment", "Property", "Vehicles", "Software", "Interest Expense", "Bank Fees", "Taxes", "Depreciation", "Amortization", "Other" ] }, subcategory: { type: "string" }, description: { type: "string" }, invoiceNumber: { type: "string" }, costCenter: { type: "string" }, projectId: { type: "string" }, tags: { type: "array", items: { type: "string" } }, taxDeductible: { type: "boolean", default: true }, recurring: { type: "boolean", default: false }, recurringFrequency: { type: "string" } }, required: ["expenseId", "date", "vendorId", "amount", "category"] }, handler: async (args: any): Promise<ToolResult> => { try { const result = await pythonBridge.callPythonFunction({ module: 'expense_tracking', function: 'ExpenseTracker.add_expense', args: [], kwargs: { expense: args } }); return result; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } } },
  • src/index.ts:32-44 (registration)
    Global registration: expenseTools array spread into allTools used by MCP server's ListTools and CallTool handlers
    const allTools = [ ...excelTools, ...financialTools, ...rentalTools, ...expenseTools, ...reportingTools, ...cashFlowTools, ...taxTools, ...analyticsTools, ...chartTools, ...complianceTools, ...propertyTools, ];
  • Python backend implementation of ExpenseTracker.add_expense method called by the JS tool handler
    def add_expense(self, expense: Expense) -> str: """Add a new expense with validation""" # Validate vendor exists if expense.vendor_id not in self.vendors: raise ValueError(f"Vendor {expense.vendor_id} not found") # Check approval rules if self._requires_approval(expense): expense.approval_status = ApprovalStatus.PENDING else: expense.approval_status = ApprovalStatus.APPROVED self.expenses.append(expense) return expense.expense_id

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/jeremycharlesgillespie/excel-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server