Skip to content

Tool System

Wilson’s tools are LangChain DynamicStructuredTool instances with Zod schemas for input validation. The tool registry collects all tools and conditionally loads them based on available API keys and configuration.

ToolDescriptionAlways Available
csv_importImport transactions from CSV, OFX, or QIF filesYes
categorizeAI-powered transaction categorizationYes
transaction_searchSearch and filter transactions by any criteriaYes
spending_summaryGenerate spending breakdowns by category, merchant, or periodYes
anomaly_detectFind duplicates, unusual amounts, forgotten subscriptionsYes
export_transactionsExport filtered transactions to CSV or XLSXYes
web_searchSearch the web for merchant info or financial questionsRequires API key

The registry (src/tools/registry.ts) manages tool discovery and loading:

  1. Collects all built-in tools
  2. Conditionally includes tools based on environment variables (e.g., web search requires an API key)
  3. Loads MCP tools from configured servers
  4. Provides rich description strings injected into the system prompt

Each tool has two levels of description:

  • Zod schema description — Used by the LLM to understand parameters
  • Rich description string — Injected into the system prompt for better tool selection
import { DynamicStructuredTool } from '@langchain/core/tools';
import { z } from 'zod';
const myTool = new DynamicStructuredTool({
name: 'my_tool',
description: 'What this tool does',
schema: z.object({
query: z.string().describe('Search query'),
limit: z.number().optional().describe('Max results'),
}),
func: async ({ query, limit }) => {
// Tool implementation
return JSON.stringify(results);
},
});

The import system includes bank-specific CSV parsers:

ParserFileBank Format
Chaseparsers/chase.tsChase CSV with Details, Posting Date
Amexparsers/amex.tsAmerican Express CSV
Bank of Americaparsers/bofa.tsBofA checking and credit card formats
Genericparsers/generic.tsFallback for any CSV with date/amount columns
OFXparsers/ofx.tsOFX v1.x (SGML) and v2.x (XML)
QIFparsers/qif.tsQuicken Interchange Format

All parsers return a ParsedTransaction interface that normalizes the data before database insertion.

detect-bank.ts sniffs file format in this order:

  1. OFX — Checks for <OFX> or OFXHEADER markers
  2. QIF — Checks for !Type: header
  3. CSV — Sniffs column headers to identify bank format

Wilson supports multiple web search providers for merchant research:

ProviderAPI Key
ExaEXA_API_KEY
PerplexityPERPLEXITY_API_KEY
TavilyTAVILY_API_KEY
BraveBRAVE_API_KEY

Only one is needed. Wilson uses whichever key is available.