CLAUDE.mdtypescript
copilot-money-mcp CLAUDE.md
MCP (Model Context Protocol) server that enables AI-powered queries of Copilot Money personal finance data by reading locally cached Firestore data (LevelDB + Protocol Buffers).
Copilot Money MCP Server
MCP (Model Context Protocol) server that enables AI-powered queries of Copilot Money personal finance data by reading locally cached Firestore data (LevelDB + Protocol Buffers).
Quick Reference
bun install # Install dependencies
bun test # Run tests (772 tests)
bun run build # Build for production
bun run pack:mcpb # Create .mcpb bundle for Claude Desktop
bun run check # Run typecheck + lint + format:check + test
bun run fix # Run lint:fix + format
Architecture
Data Flow
- Copilot Money stores data in local LevelDB/Firestore cache
src/core/decoder.tsreads.ldbfiles and parses Protocol Bufferssrc/core/database.tsprovides filtered access to transactions/accountssrc/tools/tools.tsexposes MCP tools via Model Context Protocolsrc/server.tshandles MCP protocol communication
Project Structure
src/
├── core/
│ ├── database.ts # CopilotDatabase - main data access layer
│ └── decoder.ts # LevelDB binary decoder for Firestore protobufs
├── models/
│ ├── transaction.ts # Transaction Zod schema
│ ├── account.ts # Account Zod schema
│ ├── budget.ts # Budget Zod schema
│ ├── goal.ts # Goal Zod schema
│ ├── category.ts # Category mappings (Plaid taxonomy)
│ └── ... # Other entity schemas
├── tools/
│ └── tools.ts # All MCP tool implementations (~3000 lines)
├── utils/
│ ├── date.ts # Date period parsing (this_month, last_30_days, etc.)
│ └── categories.ts # Category name resolution
├── server.ts # MCP server (CopilotMoneyServer class)
└── cli.ts # CLI entry point with --db-path option
Key Files
src/tools/tools.ts- All 8 MCP tools are implemented here as async methods in theCopilotMoneyToolsclass.src/core/database.ts-CopilotDatabaseclass with methods likegetTransactions(),getAccounts(),getIncome(), etc.src/core/decoder.ts- Binary decoder that reads LevelDB files and parses Firestore Protocol Buffers.manifest.json- MCP bundle metadata for .mcpb packaging.
Conventions
Code Style
- TypeScript strict mode
- Zod for runtime validation of all data models
- ESLint + Prettier enforced via pre-commit hooks
- All tools marked with
readOnlyHint: true(never modifies user data)
Testing
- Bun test runner
- Tests in
tests/mirrorsrc/structure - Synthetic test fixtures in
tests/fixtures/synthetic-db/ - Run specific tests:
bun test tests/tools/tools.test.ts
Tool Implementation Pattern
Each MCP tool follows this pattern:
- Define input schema with Zod in
createToolSchemas() - Implement async method in
CopilotMoneyToolsclass (e.g.,getTransactions()) - Register in the tool handlers switch statement in
src/server.ts - Add to
manifest.jsontools array
Important Notes
- Privacy First: 100% local processing, zero network requests
- Read-Only: Never modifies Copilot Money database
- Database Location:
~/Library/Containers/com.copilot.production/Data/Library/Application Support/firestore/__FIRAPP_DEFAULT/copilot-production-22904/main
Common Tasks
Adding a New Tool
- Add Zod schema in
createToolSchemas()insrc/tools/tools.ts - Implement async method in
CopilotMoneyToolsclass (e.g.,getNewTool()) - Add case to tool handler switch statement in
src/server.ts - Add tool to
manifest.json - Run
bun run sync-manifestto verify manifest matches code - Add tests in
tests/tools/tools.test.ts
Debugging
bun run dev:debug # Run with inspector
Building for Distribution
bun run pack:mcpb # Creates .mcpb bundle for Claude Desktop