Sponsored by Deepsite.site

Monarch Money TypeScript SDK

Created By
martinamps7 months ago
small mcp server for accessing monarch money
Content

Monarch Money TypeScript SDK

A TypeScript library for accessing Monarch Money data.

Installation

bun add monarchmoney

or

npm install monarchmoney

Usage

Quick Start with Browser Token

The easiest way to get started is by using a token directly from your browser session:

import MonarchMoney from 'monarchmoney';

// You can get this token from your browser's localStorage or Cookies after logging in
// to Monarch Money on the web
const token = process.env.MONARCH_TOKEN;

// Create a client with the token
const mm = new MonarchMoney(token);

// Now you can use the API without logging in
const accounts = await mm.getAccounts();

Standard Authentication

If you don't have a token, you can log in with your credentials:

import MonarchMoney, { RequireMFAError } from 'monarchmoney';

// Create a new client
const mm = new MonarchMoney();

// Login using environment variables
const email = process.env.MONARCH_USER;
const password = process.env.MONARCH_PASSWORD;

if (!email || !password) {
  throw new Error('MONARCH_USER and MONARCH_PASSWORD environment variables must be set');
}

// Login
try {
  await mm.login({
    email,
    password
  });
} catch (error) {
  if (error instanceof RequireMFAError) {
    // Get MFA code from user
    const mfaCode = process.env.MONARCH_MFA || prompt('Enter MFA code:');
    
    await mm.authenticateWithMFA({
      email,
      password,
      mfaCode
    });
  } else {
    throw error;
  }
}

Using a Saved Session

You can save your session for later use:

// After logging in, save the session
mm.saveSession();

// Later, load the session
const mm = new MonarchMoney();
mm.loadSession();

// Now you can access data without logging in again
const accounts = await mm.getAccounts();

Accessing Data

// Get accounts
const accounts = await mm.getAccounts();
console.log(accounts);

// Get transactions for current month
const today = new Date();
const firstDayOfMonth = new Date(today.getFullYear(), today.getMonth(), 1);
const lastDayOfMonth = new Date(today.getFullYear(), today.getMonth() + 1, 0);

const transactions = await mm.getTransactions({
  limit: 10,
  filters: {
    startDate: firstDayOfMonth.toISOString().split('T')[0],
    endDate: lastDayOfMonth.toISOString().split('T')[0]
  }
});
console.log(transactions);

// Get budgets
const budgets = await mm.getBudgets();
console.log(budgets);

// Get account holdings
const holdings = await mm.getAccountHoldings('account-id-here');
console.log(holdings);

Running the Example

To run the included example, you have two options:

Option 1: Using a Browser Token (Easiest)

# Get the token from your browser after logging in to Monarch Money
# In Chrome: DevTools > Application > Storage > Local Storage > monarchmoney.com > find the auth token
export MONARCH_TOKEN="your-token-from-browser"

# Run the example
bun run example

Option 2: Using Username/Password

# Set your credentials as environment variables
export MONARCH_USER="your.email@example.com"
export MONARCH_PASSWORD="your-password"
# Optional: Set MFA code if required
export MONARCH_MFA="123456"

# Run the example
bun run example

Available Methods

This SDK provides read-only access to Monarch Money data:

  • getAccounts() - Get all accounts
  • getAccountTypeOptions() - Get all account types and subtypes
  • getAccountHoldings(accountId) - Get securities in a brokerage account
  • getAccountHistory(accountId) - Get daily account history
  • getInstitutions() - Get linked institutions
  • getBudgets(startDate, endDate) - Get budgets and actual amounts
  • getSubscriptionDetails() - Get account subscription status
  • getTransactionsSummary() - Get transaction summary data
  • getTransactions(options) - Get transaction data
  • getTransactionCategories() - Get transaction categories
  • getTransactionCategoryGroups() - Get transaction category groups
  • getTransactionDetails(transactionId) - Get details for a transaction
  • getTransactionSplits(transactionId) - Get transaction splits
  • getTransactionTags() - Get transaction tags
  • getCashflow(options) - Get cashflow data
  • getCashflowSummary(options) - Get cashflow summary
  • getRecurringTransactions(startDate, endDate) - Get recurring transactions

MCP Server for AI Agents

This SDK includes a Model Context Protocol (MCP) server that allows AI agents to interact with Monarch Money. The MCP server provides tools for querying accounts, transactions, budgets, and more.

To start the MCP server:

# Set up authentication via environment variables
export MONARCH_TOKEN="your-token-from-browser"

# Start the MCP server
bun run mcp

The MCP server will automatically authenticate using the MONARCH_TOKEN environment variable and provides the following tools:

  • check_authentication - Check if already authenticated
  • get_accounts - Get all accounts
  • get_account_holdings - Get holdings for an account
  • get_account_history - Get history for an account
  • get_transactions - Get transactions with filters
  • get_transaction_categories - Get transaction categories
  • get_budgets - Get budgets for a date range
  • get_cashflow - Get cashflow data with filters

Claude Desktop Configuration

To use this with Claude Desktop, add the following to your Claude Desktop configuration file (located at ~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "monarchMoney": {
      "command": "bun",
      "args": ["run", "mcp"],
      "env": {
        "MONARCH_TOKEN": "your-monarch-token-here"
      },
      "cwd": "/path/to/your/monarch-ts"
    }
  }
}

Replace /path/to/your/monarch-ts with the actual path to your project directory and your-monarch-token-here with your Monarch Money token from your browser.

License

MIT

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Playwright McpPlaywright MCP server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
DeepChatYour AI Partner on Desktop
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
ChatWiseThe second fastest AI chatbot™
CursorThe AI Code Editor
Serper MCP ServerA Serper MCP Server
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
WindsurfThe new purpose-built IDE to harness magic
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Amap Maps高德地图官方 MCP Server
Tavily Mcp