Skip to main content
Glama

query_financial_history

Search through stored financial transactions using natural language queries to find relevant spending records and calculate totals.

Instructions

Search through all stored financial data using semantic search. Args: query: Search query string to find relevant transactions Returns: Formatted summary of matching transactions with totals

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes

Implementation Reference

  • The main handler function for the 'query_financial_history' tool. It performs semantic search on the ChromaDB collection of transactions using the provided query, retrieves up to 10 results, processes them with pandas to compute totals, and returns a formatted string summary of matching transactions.
    @mcp.tool() def query_financial_history(query: str) -> str: """ Search through all stored financial data using semantic search. Args: query: Search query string to find relevant transactions Returns: Formatted summary of matching transactions with totals """ # Search ChromaDB results = collection.query( query_texts=[query], n_results=10 ) # Format results found_transactions = [] if results['metadatas'][0]: for metadata in results['metadatas'][0]: found_transactions.append(metadata) # Create summary if found_transactions: df = pd.DataFrame(found_transactions) total_amount = df['amount'].sum() if 'amount' in df.columns else 0 count = len(found_transactions) response = f"Found {count} relevant transactions.\n" response += f"Total amount: ${total_amount:.2f}\n\n" response += "Recent transactions:\n" for txn in found_transactions[:5]: response += f"- {txn.get('date')}: ${txn.get('amount'):.2f} - {txn.get('description')}\n" else: response = "No matching transactions found." return response
  • Initialization of the global ChromaDB persistent client and 'transactions' collection, which is directly used by the query_financial_history handler for storing embeddings and performing vector similarity searches.
    chroma_client = chromadb.PersistentClient(path=str(DB_PATH)) collection = chroma_client.get_or_create_collection("transactions")
  • The @mcp.tool() decorator registers the query_financial_history function as an MCP tool, making it available via the FastMCP server.
    @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