Skip to main content
Glama

delete_transactions

Remove specific or all financial transactions from both JSON ledger and ChromaDB storage. Requires confirmation for safety when deleting transaction data.

Instructions

Delete transactions from both the JSON ledger and ChromaDB. Args: indices: List of transaction indices (from list_transactions) to delete delete_all: Set to true to delete all transactions confirm: Must be true to actually perform deletion (safety guard) Returns: Status message describing the deletion result

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indicesNo
delete_allNo
confirmNo

Implementation Reference

  • The handler function for the 'delete_transactions' tool, which deletes transactions from the JSON ledger and ChromaDB based on indices or all if specified. Includes safety confirm parameter. The @mcp.tool() decorator registers it.
    @mcp.tool() def delete_transactions(indices: Optional[List[int]] = None, delete_all: bool = False, confirm: bool = False) -> str: """ Delete transactions from both the JSON ledger and ChromaDB. Args: indices: List of transaction indices (from list_transactions) to delete delete_all: Set to true to delete all transactions confirm: Must be true to actually perform deletion (safety guard) Returns: Status message describing the deletion result """ if not confirm: raise ValueError("Deletion aborted: set confirm=True to proceed.") transactions = _load_transactions() if delete_all: deleted_count = len(transactions) _save_transactions([]) try: # Recreate the collection to ensure it is empty global collection chroma_client.delete_collection("transactions") collection = chroma_client.get_or_create_collection("transactions") except chromadb.errors.InvalidCollectionException: pass return f"Deleted {deleted_count} transactions." if deleted_count else "No transactions to delete." if not indices: raise ValueError("Provide indices to delete or set delete_all=True.") indices_set = set(indices) remaining: List[Dict[str, Any]] = [] removed: List[Dict[str, Any]] = [] for idx, txn in enumerate(transactions): if idx in indices_set: removed.append(txn) else: remaining.append(txn) if not removed: return "No transactions matched the provided indices." _save_transactions(remaining) # Remove matching entries from ChromaDB using metadata filters for txn in removed: metadata_filter = {k: v for k, v in txn.items() if isinstance(k, str)} try: collection.delete(where=metadata_filter) except Exception: # If metadata-based delete fails, ignore but keep JSON consistent continue return f"Deleted {len(removed)} transactions."
  • The @mcp.tool() decorator registers the delete_transactions function as an MCP tool.
    @mcp.tool()

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