Skip to main content
Glama

store_transactions

Store financial transactions from documents by parsing date, amount, description, and category into a structured format for analysis and reporting.

Instructions

Parse and store transaction data from uploaded financial documents. If you receive unstructured financial data (statements, receipts, CSV files, etc.), extract transactions into the format: [{"date": "YYYY-MM-DD", "amount": number, "description": "string", "category": "string"}] Args: transactions: List of transaction dictionaries, each containing: - date: Transaction date (string, format: YYYY-MM-DD) - amount: Transaction amount (number, can be negative for expenses) - description: Transaction description (string) - category: Transaction category (string, optional, e.g. "Food", "Transport", "Bills") Returns: Success message with count of stored transactions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
transactionsYes

Implementation Reference

  • The store_transactions tool handler, registered via @mcp.tool(). Parses and stores transaction data in ChromaDB for semantic search and in a JSON backup file. Includes detailed docstring describing input schema.
    @mcp.tool() def store_transactions(transactions: List[Dict[str, Any]]) -> str: """ Parse and store transaction data from uploaded financial documents. If you receive unstructured financial data (statements, receipts, CSV files, etc.), extract transactions into the format: [{"date": "YYYY-MM-DD", "amount": number, "description": "string", "category": "string"}] Args: transactions: List of transaction dictionaries, each containing: - date: Transaction date (string, format: YYYY-MM-DD) - amount: Transaction amount (number, can be negative for expenses) - description: Transaction description (string) - category: Transaction category (string, optional, e.g. "Food", "Transport", "Bills") Returns: Success message with count of stored transactions """ # Store in ChromaDB ids = [] documents = [] metadatas = [] for i, txn in enumerate(transactions): txn_id = f"txn_{datetime.now().timestamp()}_{i}" doc = f"Date: {txn.get('date')} Amount: {txn.get('amount')} Description: {txn.get('description')} Category: {txn.get('category', 'unknown')}" ids.append(txn_id) documents.append(doc) metadatas.append(txn) collection.add( ids=ids, documents=documents, metadatas=metadatas ) # Also save to JSON file existing = _load_transactions() existing.extend(transactions) _save_transactions(existing) return f"Stored {len(transactions)} transactions successfully"
  • Helper function to load existing transactions from the JSON backup file, used by store_transactions.
    def _load_transactions() -> List[Dict[str, Any]]: if JSON_FILE.exists(): with JSON_FILE.open("r") as f: try: return json.load(f) except json.JSONDecodeError: return [] return []
  • Helper function to save transactions to the JSON backup file, used by store_transactions.
    def _save_transactions(transactions: List[Dict[str, Any]]) -> None: JSON_FILE.parent.mkdir(parents=True, exist_ok=True) with JSON_FILE.open("w") as f: json.dump(transactions, f, indent=2)

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/xinrong-meng/my-finance-mcp'

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