monarchmoney-node
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@monarchmoney-node show my recent transactions"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Monarch Money (Node.js)
Node.js/TypeScript library for accessing Monarch Money data.
Disclaimer: This project is unofficial and not affiliated with Monarch Money.
Installation
npm install @hakimelek/monarchmoneyRequires Node.js 18+ (uses native fetch and AbortSignal.timeout).
Related MCP server: Monarch Money MCP Server
Quick Start
import {
MonarchMoney,
EmailOtpRequiredException,
RequireMFAException,
} from "@hakimelek/monarchmoney";
const mm = new MonarchMoney();
try {
await mm.login("your@email.com", "password");
} catch (e) {
if (e instanceof EmailOtpRequiredException) {
// Monarch sent a verification code to your email
const code = await promptUser("Enter the code from your email:");
await mm.submitEmailOtp("your@email.com", "password", code);
} else if (e instanceof RequireMFAException) {
// TOTP-based MFA is enabled on the account
await mm.multiFactorAuthenticate("your@email.com", "password", "123456");
}
}
// Fetch data — fully typed responses
const { accounts } = await mm.getAccounts();
console.log(accounts[0].displayName, accounts[0].currentBalance);Authentication
Monarch's API requires email verification (OTP) for new devices/sessions, even when MFA is disabled. The library handles this with distinct exception types so your app can respond appropriately.
Login with email OTP handling
try {
await mm.login(email, password);
} catch (e) {
if (e instanceof EmailOtpRequiredException) {
// A code was sent to the user's email — prompt them for it
const code = await yourApp.promptForEmailCode();
await mm.submitEmailOtp(email, password, code);
}
}With MFA secret key (automatic TOTP)
await mm.login("email", "password", {
mfaSecretKey: "YOUR_BASE32_SECRET",
});The MFA secret is the "Two-factor text code" from Settings > Security > Enable MFA in Monarch Money.
Session persistence & token reuse
After a successful login (including email OTP), you can save the token to avoid re-authenticating on every run:
// Save token after login
mm.saveSession(); // writes to .mm/mm_session.json (mode 0o600)
// Next time, login() loads the saved session automatically
await mm.login(email, password); // uses saved token, no network call
// Or pass the token directly (skip login entirely)
const mm = new MonarchMoney({ token: "your-saved-token" });mm.saveSession(); // save to disk
mm.loadSession(); // load from disk
mm.deleteSession(); // remove the file
mm.setToken("..."); // set token programmaticallyInteractive CLI
await mm.interactiveLogin(); // prompts for email, password, email OTP or MFA codeAPI
All methods return typed responses. Hover over any method in your editor for full JSDoc and type information.
Read Methods
Method | Returns | Description |
|
| All linked accounts |
|
| Available account types/subtypes |
|
| Daily balances (default: last 31 days) |
|
| Snapshots by type ( |
|
| Aggregate net value over time |
|
| Securities in a brokerage account |
|
| Daily balance history |
|
| Linked institutions |
|
| Budgets with actuals (default: last month → next month) |
|
| Plan status (trial, premium, etc.) |
|
| Aggregate summary |
|
| Transactions with full filtering |
|
| All matching transactions (auto-paginates) |
|
| Async generator yielding pages |
|
| All categories |
|
| Category groups |
| typed response | Single transaction detail |
| typed response | Splits for a transaction |
|
| All tags |
|
| Cashflow by category, group, merchant |
|
| Income, expense, savings, savings rate |
|
| Upcoming recurring transactions |
|
| Check refresh status |
Write Methods
Method | Returns | Description |
|
| Create manual account |
|
| Update account settings/balance |
|
| Delete account |
|
| Start refresh (non-blocking) |
|
| Refresh and poll until done |
|
| Create transaction |
|
| Update transaction |
|
| Delete transaction |
|
| Manage splits |
|
| Create category |
|
| Delete category |
|
| Bulk delete |
|
| Create tag |
|
| Set tags on transaction |
|
| Set/clear budget |
|
| Upload balance history CSV |
Error Handling
import {
MonarchMoneyError, // base class for all errors
EmailOtpRequiredException, // email verification code needed — call submitEmailOtp()
RequireMFAException, // TOTP MFA required — call multiFactorAuthenticate()
LoginFailedException, // bad credentials or auth error (includes .statusCode)
RequestFailedException, // API/GraphQL failure (includes .statusCode, .graphQLErrors)
} from "@hakimelek/monarchmoney";
try {
await mm.login(email, password);
} catch (e) {
if (e instanceof EmailOtpRequiredException) {
// e.code === "EMAIL_OTP_REQUIRED"
// Prompt user for the code sent to their email
const code = await getCodeFromUser();
await mm.submitEmailOtp(email, password, code);
} else if (e instanceof RequireMFAException) {
// e.code === "MFA_REQUIRED"
// Prompt for TOTP code or use mfaSecretKey
} else if (e instanceof LoginFailedException) {
// e.code === "LOGIN_FAILED", e.statusCode
console.error("Login failed:", e.message);
}
}
try {
await mm.getAccounts();
} catch (e) {
if (e instanceof RequestFailedException) {
console.error(e.statusCode); // HTTP status, if applicable
console.error(e.graphQLErrors); // GraphQL errors array, if applicable
console.error(e.code); // "HTTP_ERROR" | "REQUEST_FAILED"
}
}Configuration
const mm = new MonarchMoney({
sessionFile: ".mm/mm_session.json", // session file path
timeout: 10, // API timeout in seconds
token: "pre-existing-token", // skip login
retry: {
maxRetries: 3, // retry on 429/5xx (default: 3, set 0 to disable)
baseDelayMs: 500, // base delay with exponential backoff + jitter
},
rateLimit: {
requestsPerSecond: 10, // token-bucket throttle (default: 0 = unlimited)
},
});
mm.setTimeout(30); // change timeout laterRetry automatically handles transient failures (429 Too Many Requests, 500, 502, 503, 504) with exponential backoff and jitter. The Retry-After header is respected on 429 responses.
Auto-Pagination
getTransactions() returns a single page. For large datasets, use the auto-pagination helpers:
// Async generator — yields one page at a time (memory-efficient)
for await (const page of mm.getTransactionPages({ startDate: "2025-01-01", endDate: "2025-12-31" })) {
for (const tx of page) {
console.log(tx.merchant?.name, tx.amount);
}
}
// Or collect everything into a flat array
const all = await mm.getAllTransactions({
startDate: "2025-01-01",
endDate: "2025-12-31",
pageSize: 100, // transactions per page (default: 100)
});
console.log(`${all.length} total transactions`);Both methods accept the same filter options as getTransactions() (date range, category, account, tags, etc.).
Refresh Progress
Track account refresh progress with the onProgress callback:
await mm.requestAccountsRefreshAndWait({
timeout: 300,
delay: 10,
onProgress: ({ completed, total, elapsedMs }) => {
console.log(`${completed}/${total} accounts refreshed (${(elapsedMs / 1000).toFixed(0)}s)`);
},
});MCP Server (AI Agent Integration)
This package includes a built-in Model Context Protocol server with 30 tools, making your Monarch Money data accessible to AI assistants like Claude Desktop, Cursor, and any MCP-compatible client.
Setup
Get your Monarch Money auth token by logging in with the library (see Authentication) and saving
mm.token.Add to your MCP client config (e.g. Claude Desktop
claude_desktop_config.json):
{
"mcpServers": {
"monarch-money": {
"command": "npx",
"args": ["@hakimelek/monarchmoney"],
"env": {
"MONARCH_TOKEN": "your-token-here"
}
}
}
}Or run it directly:
MONARCH_TOKEN=your-token npx @hakimelek/monarchmoneyAvailable Tools
Read (18 tools): get_accounts, get_account_holdings, get_account_history, get_account_type_options, get_recent_account_balances, get_aggregate_snapshots, get_institutions, get_budgets, get_subscription_details, get_transactions, get_transactions_summary, get_transaction_details, get_transaction_categories, get_transaction_category_groups, get_transaction_tags, get_cashflow, get_cashflow_summary, get_recurring_transactions
Write (12 tools): create_transaction, update_transaction, delete_transaction, create_manual_account, update_account, delete_account, refresh_accounts, is_refresh_complete, set_budget_amount, create_transaction_tag, set_transaction_tags, create_transaction_category
Every tool has typed parameters with descriptions, so AI agents know exactly what arguments to pass.
Project Structure
src/
index.ts — public exports
client.ts — MonarchMoney class with all API methods
mcp.ts — MCP server (30 tools for AI agents)
errors.ts — error classes (MonarchMoneyError hierarchy)
endpoints.ts — API URL constants
queries.ts — all GraphQL query/mutation strings
types.ts — TypeScript interfaces for all API responsesTesting
npm test # run tests once
npm run test:watch # run tests in watch mode
npm run test:coverage # run with coverage reportTests use Vitest and do not require real API credentials (fetch is mocked where needed).
Test the API connection (against the live api.monarch.com):
npm run build
# Login with email + password (will prompt for email OTP code if required)
MONARCH_EMAIL=your@email.com MONARCH_PASSWORD=yourpassword npm run test:connection
# Use a saved token (skips login)
MONARCH_TOKEN=your-token npm run test:connection -- --tokenSet these in a .env file for convenience (see .env.example).
FAQ
How do I use this if I login to Monarch via Google?
Set a password on your Monarch account at Settings > Security, then use that password with this library.
Why does Monarch ask for an email code every time I login?
Monarch requires email verification for new/unrecognized devices. After login, save the session token with mm.saveSession() or store mm.token — subsequent runs will reuse it without re-authenticating.
How This Library Compares
There are several unofficial Monarch Money integrations. Here's how @hakimelek/monarchmoney stacks up.
Landscape
@hakimelek/monarchmoney | monarch-money-api (pbassham) | monarchmoney (keithah) | monarchmoney (hammem) | |
Platform | Node.js / TypeScript | Node.js / JavaScript | Node.js / TypeScript | Python |
npm weekly downloads | — | ~440 | ~130 | N/A (pip: ~103K/mo) |
Runtime deps | 1 (speakeasy) | 5 | 7 | 3 |
TypeScript types | Full (every response) | None | Yes | N/A |
Email OTP flow | Yes | No | No | No |
MFA / TOTP | Yes | Yes | Yes | Yes |
Session persistence | Yes (0o600 perms) | Yes | Yes (AES-256) | Yes |
Interactive CLI login | Yes | Yes | Yes | Yes |
HTTP client | Native | node-fetch | node-fetch + graphql-request | aiohttp |
Error hierarchy | 4 typed exceptions | Generic throws | Generic throws | 1 exception |
Read methods | 20 | 15 | ~20 | ~16 |
Write methods | 14 | 9 | ~12 | ~10 |
Rate limiting | Yes | No | Yes | No |
Retry with backoff | Yes | No | Yes | No |
Auto-pagination | Yes | No | No | No |
Dual CJS + ESM | Yes | No | Yes | No |
Refresh progress events | Yes | No | No | No |
Built-in MCP server | Yes (30 tools) | No | No | No |
Where this library wins
Minimal footprint. One runtime dependency vs 5-7 in the JS/TS alternatives. Native fetch means zero HTTP polyfills on Node 18+.
Email OTP support. Monarch now requires email verification for unrecognized devices, even when MFA is off. This is the only Node.js library that handles the full EmailOtpRequiredException → submitEmailOtp() flow. Without it, automated scripts break on first login from a new environment.
Typed everything. Every API response has a dedicated TypeScript interface — 50+ exported types covering accounts, transactions, holdings, cashflow, budgets, recurring items, and mutations. The monarch-money-api package has no types at all.
Structured error handling. Four distinct exception classes (LoginFailedException, RequireMFAException, EmailOtpRequiredException, RequestFailedException) with error codes and status codes. Competitors throw generic errors or strings.
Broader write coverage. Includes updateTransaction(), setBudgetAmount(), uploadAccountBalanceHistory(), getCashflow(), getCashflowSummary(), and getRecurringTransactions() — all missing from monarch-money-api.
Clean, flat API. One class, direct methods, no sub-objects or verbosity levels to learn. Import MonarchMoney, call methods, get typed results.
Contributing
Contributions welcome. Please ensure TypeScript compiles cleanly (npm run build) and tests pass (npm test).
License
MIT
Available Tools
30 toolscreate_manual_accountB
Create a new manual account (not linked to a bank).
Inputs: account_name (required), account_type (required), account_sub_type (required), is_in_net_worth (required), +1 more.
create_transactionC
Create a new transaction in a specific account.
Inputs: date (required), account_id (required), amount (required), merchant_name (required), +3 more.
create_transaction_categoryB
Create a new transaction category within a category group.
Inputs: group_id (required), name (required), icon.
create_transaction_tagB
Create a new tag for categorizing transactions.
Inputs: name (required), color (required).
delete_accountA
Delete an account by ID. This is irreversible.
Inputs: account_id (required).
delete_transactionB
Delete a transaction by ID.
Inputs: transaction_id (required).
get_account_historyA
Get daily balance history for a specific account.
Inputs: account_id (required).
get_account_holdingsB
Get investment holdings (securities, stocks, ETFs) for a specific brokerage or investment account.
Inputs: account_id (required).
get_accountsA
Get all linked bank, credit, investment, and manual accounts with current balances.
Inputs: no named parameters.
get_account_type_optionsA
Get all available account types and subtypes (useful when creating manual accounts).
Inputs: no named parameters.
get_aggregate_snapshotsA
Get daily aggregate net worth across all accounts over time.
Inputs: start_date, end_date, account_type.
get_budgetsB
Get budgets with actual spending amounts. Defaults to previous month through next month.
Inputs: start_date, end_date.
get_cashflowA
Get cashflow data grouped by category, category group, and merchant. Defaults to current month.
Inputs: start_date, end_date.
get_cashflow_summaryB
Get cashflow summary: total income, expenses, savings, and savings rate. Defaults to current month.
Inputs: start_date, end_date.
get_institutionsA
Get linked financial institutions and their connection status.
Inputs: no named parameters.
get_recent_account_balancesB
Get daily account balances for a date range. Defaults to last 31 days.
Inputs: start_date.
get_recurring_transactionsB
Get upcoming recurring transactions (subscriptions, bills). Defaults to current month.
Inputs: start_date, end_date.
get_subscription_detailsA
Get Monarch Money subscription status (trial, premium, plan info).
Inputs: no named parameters.
get_transaction_categoriesA
Get all transaction categories configured in the account.
Inputs: no named parameters.
get_transaction_category_groupsA
Get all category groups (e.g. Income, Food & Drink, Housing).
Inputs: no named parameters.
get_transaction_detailsA
Get full details for a single transaction.
Inputs: transaction_id (required).
get_transactionsA
Search and filter transactions with pagination. Returns up to limit transactions at a time.
Inputs: limit, offset, start_date, end_date, +4 more.
get_transactions_summaryA
Get aggregate transaction summary: totals, averages, counts, income, expenses.
Inputs: no named parameters.
get_transaction_tagsA
Get all tags configured in the account.
Inputs: no named parameters.
is_refresh_completeB
Check whether a previously started account refresh has completed.
Inputs: account_ids.
refresh_accountsB
Trigger a refresh of account balances and transactions from linked institutions. Non-blocking.
Inputs: account_ids (required).
set_budget_amountB
Set or clear a budget amount for a category or category group.
Inputs: amount (required), category_id, category_group_id, start_date, +1 more.
set_transaction_tagsA
Set (replace) all tags on a transaction.
Inputs: transaction_id (required), tag_ids (required).
update_accountB
Update an account's settings (name, balance, visibility, etc.).
Inputs: account_id (required), account_name, account_balance, include_in_net_worth, +1 more.
update_transactionA
Update fields on an existing transaction. Only provided fields are changed.
Inputs: transaction_id (required), category_id, merchant_name, amount, +4 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 30 tools
Every tool targets a distinct resource and action. Even similar tools like get_transactions, get_transaction_details, and get_transactions_summary have clear differentiation in descriptions.
All tool names follow a consistent verb_noun pattern in snake_case, with standard CRUD verbs and a few specific verbs like refresh and is_refresh_complete.
30 tools is slightly above the typical 3-15 range, but the domain of personal finance management is broad and each tool serves a distinct purpose, justifying the count.
Core account and transaction operations are well-covered, but missing single account retrieval and update/delete operations for categories and tags create notable gaps.
Maintenance
Related MCP Connectors
Personal finance for AI agents — onboard, import statements, categorize & budget over MCP.
Read-only finance MCP server. Connects your banks, cards, payment apps, books and payroll into one ledger for your AI. Can't move money. Open source (AGPL-3.0), free during beta.
Log, query, and edit expenses, budgets, and accounts in Manilo from any MCP-compatible AI assistant.
Query your real net worth, spending, transactions, budgets and portfolio from any MCP client.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAn MCP server that provides access to personal financial data from Monarch Money, allowing users to retrieve account information, transactions, budgets, goals, and net worth through natural language queries.16-
- FlicenseNot gradedqualityDmaintenanceAn MCP server that integrates with Monarch Money to provide financial data access and operations, including account management, transaction filtering, budget analysis, and goal tracking through natural language.-
- AlicenseAqualityBmaintenanceAn MCP server for Monarch Money that gives AI assistants access to your financial accounts, transactions, budgets, and more.42933 PyPI29MIT
- AlicenseCqualityCmaintenanceUnofficial MCP server for Monarch Money that exposes tools for managing accounts, transactions, budgets, and other financial data through natural language.1251MIT