MCP server for Banktivity personal finance files — Swift/Core Data rewrite for CloudKit-safe read/write access
banktivity-swift-mcp
A Model Context Protocol (MCP) server for Banktivity personal finance files. It gives AI assistants like Claude full read/write access to your .bank8 vault — accounts, transactions, categories, tags, templates, import rules, and scheduled transactions.
Inspired by banktivity-mcp (TypeScript/Node.js), this is a ground-up rewrite in Swift. The original uses better-sqlite3 to read and write Core Data's SQLite store directly, bypassing Core Data's internal change tracking. This works for reads, but direct SQL writes are invisible to CloudKit sync — Banktivity doesn't know the data changed, and the vault can become corrupted or fail to sync. This Swift version uses NSPersistentContainer so all mutations go through Core Data's API, ensuring proper change tracking and CloudKit compatibility.
WARNING: This server can modify your Banktivity data. Write tools (create, update, delete) make real changes to your
.bank8vault. While the server uses Core Data for proper change tracking and includes a write guard that blocks mutations when Banktivity is open, AI assistants can and will make mistakes. Back up your vault regularly and consider working on a copy until you're confident in your workflow. The authors are not responsible for any data loss or corruption.
Requirements
- macOS 14+
- Swift 6.0+ (Xcode 16+ or Command Line Tools)
- A Banktivity
.bank8vault file
Installation
git clone https://github.com/sflinter/banktivity-swift-mcp.git
cd banktivity-swift-mcp
swift build -c release
cp .build/release/banktivity-mcp ~/.local/bin/
codesign -fs - ~/.local/bin/banktivity-mcp
Configuration
Claude Code
Add to your MCP settings (~/.claude/settings.json or project .mcp.json):
{
"mcpServers": {
"banktivity": {
"command": "/Users/you/.local/bin/banktivity-mcp",
"env": {
"BANKTIVITY_FILE_PATH": "/Users/you/Documents/Banktivity/My Accounts.bank8"
}
}
}
}
Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"banktivity": {
"command": "/Users/you/.local/bin/banktivity-mcp",
"env": {
"BANKTIVITY_FILE_PATH": "/Users/you/Documents/Banktivity/My Accounts.bank8"
}
}
}
}
Available Tools
Accounts
list_accounts— List all accounts with balancesget_account_balance— Get balance for a specific accountget_net_worth— Calculate total net worthget_spending_by_category— Spending breakdown by category for a date rangeget_income_by_category— Income breakdown by category for a date rangeget_summary— Overall financial summary
Transactions
get_transactions— List transactions with filtering and paginationsearch_transactions— Full-text search across payees, memos, etc.get_transaction— Get a single transaction by IDcreate_transaction— Create a new transactionupdate_transaction— Update an existing transactiondelete_transaction— Delete a transaction
Line Items
get_line_item— Get a specific line itemadd_line_item— Add a line item to a transaction (for splits)update_line_item— Update a line itemdelete_line_item— Delete a line item
Categories
list_categories— List all income/expense categoriesget_category— Get a specific categoryget_category_tree— Get the full category hierarchycreate_category— Create a new category
Categorization
get_uncategorized_transactions— Find transactions without categoriessuggest_category_for_merchant— Suggest a category based on merchant historyrecategorize_transaction— Change a transaction's categorybulk_recategorize_by_payee— Recategorize all transactions for a payeereview_categorizations— Review recent categorization changesget_payee_category_summary— Summary of categories used per payee
Tags
get_tags— List all tagscreate_tag— Create a new tagtag_transaction— Tag a transactionget_transactions_by_tag— Find transactions with a specific tagbulk_tag_transactions— Tag multiple transactions at once
Templates
list_transaction_templates— List saved transaction templatesget_transaction_template— Get a specific templatecreate_transaction_template— Create a new templateupdate_transaction_template— Update a templatedelete_transaction_template— Delete a template
Import Rules
list_import_rules— List all import rulesget_import_rule— Get a specific import rulematch_import_rules— Find rules matching a payee stringcreate_import_rule— Create a new import ruleupdate_import_rule— Update an import ruledelete_import_rule— Delete an import rule
Scheduled Transactions
list_scheduled_transactions— List all scheduled transactionsget_scheduled_transaction— Get a specific scheduled transactioncreate_scheduled_transaction— Create a new scheduled transactionupdate_scheduled_transaction— Update a scheduled transactiondelete_scheduled_transaction— Delete a scheduled transaction
Diagnostic
dump_schema— Inspect the Core Data model schema (entity names, attributes, relationships)
Safety Features
- Write guard: Before any mutation, the server checks if Banktivity.app has the vault open (via
lsof). If it does, writes are blocked to prevent corruption. - No persistent history tracking: Banktivity uses its own sync mechanism. Core Data's built-in history tracking would add unrecognized metadata that corrupts the vault.
- Background contexts: All writes use background
NSManagedObjectContextinstances withperformAndWaitfor data integrity.
How It Works
Banktivity's .bank8 bundle is a directory containing compiled Core Data models (.momd files) and a SQLite database (StoreContent/core.sql). This server:
- Loads and merges all
.momdmodel bundles from the vault - Opens the SQLite store via
NSPersistentContainer(no history tracking) - Exposes 47 MCP tools over stdio transport
- Uses KVC (
value(forKey:)) to access entities since we load Banktivity's own compiled models at runtime