
Banktivity个人理财文件的MCP服务器——Swift/Core Data重写以实现CloudKit安全的读写访问
概览
一个Swift库、MCP服务器和用于Banktivity个人理财文件的CLI。提供对.bank8金库的完整读写访问——账户、交易、类别、标签、模板、导入规则、定时交易、对账单、证券和RDF导出。 - — 纯域库,支持核心数据仓库和RDF导出,无服务器依赖 - — MCP服务器在stdio上提供64个工具,用于像Claude这样的AI助手 - — 用于脚本编写和自动化的独立CLI 灵感来自banktivity-mcp(TypeScript/Node.js),这是在Swift中从头重写的版本。原版使用better-sqlite3直接读写Core Data的SQLite存储,绕过Core Data内部的变更追踪。这对读取有效,但直接SQL写入对CloudKit同步是看不见的——Banktivity不知道数据被更改,保险库可能会损坏或无法同步。
概述(AI 翻译)
一个用于 Banktivity 个人理财文件的 Swift 库、MCP 服务器和 CLI。提供对 .bank8 保险库的完整读写访问——账户、交易、类别、标签、模板、导入规则、预定交易、对账单、证券和 RDF 导出。
- BanktivityLib — 纯域库,带有核心数据仓库和RDF导出,无服务器依赖
- banktivity-mcp — MCP 服务器在 stdio 上提供 64 个工具,供 Claude 等 AI 助手使用
- banktivity-cli — 用于脚本编写和自动化的独立CLI
灵感来自 banktivity-mcp(TypeScript/Node.js),这是 Swift 的从头重写。原版使用 better-sqlite3 直接读写 Core Data 的 SQLite 存储,绕过 Core Data 内部的变更追踪。这对读取有效,但直接写入 SQL 对 CloudKit 同步是看不见的——Banktivity 不知道数据被更改,保险库可能损坏或无法同步。该版本使用 NSPersistentContainer,所有变异都通过 Core Data 的 API,确保正确的变更追踪和 CloudKit 兼容性。
**警告:本服务器可能会修改您的Banktivity数据。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
banktivity-swift-mcp
A Swift library, MCP server, and CLI for Banktivity personal finance files. Provides full read/write access to .bank8 vaults — accounts, transactions, categories, tags, templates, import rules, scheduled transactions, statements, securities, and RDF export.
- BanktivityLib — pure domain library with Core Data repositories and RDF export, no server dependencies
- banktivity-mcp — MCP server exposing 66 tools over stdio, for AI assistants like Claude
- banktivity-cli — standalone CLI for scripting and automation
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+
- A Banktivity
.bank8vault file
Read-only mode
Set BANKTIVITY_STORE_READ_ONLY to 1, true, or yes to open the Core Data store read-only. Even a pure read makes SQLite touch its write-ahead log and other housekeeping files, so use this when the goal is to inspect a vault without altering a byte of it. Writes then fail down at the store layer rather than at the write guard.
BANKTIVITY_STORE_READ_ONLY=1 \
banktivity-cli --vault ~/Documents/Banktivity/My\ Accounts.bank8 accounts list
One caveat: SQLite may still open core.sql-shm for writing on its own account. The default remains read/write and the write guard is unchanged, so treat this as a second layer rather than a substitute for backups.
Installation
Homebrew (recommended)
brew install sflinter/tap/banktivity-swift-mcp
This installs both banktivity-mcp and banktivity-cli as universal binaries (Apple Silicon + Intel).
Download binary
Download the universal binary from GitHub Releases, extract, and move to your PATH:
tar xzf banktivity-swift-mcp-v0.8.0-macos-universal.tar.gz
mv banktivity-mcp banktivity-cli ~/.local/bin/
Build from source
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"banktivity": {
"command": "/Users/you/.local/bin/banktivity-mcp",
"env": {
"BANKTIVITY_FILE_PATH": "/Users/you/Documents/Banktivity/My Accounts.bank8"
}
}
}
}