fix: add graceful error handling for get_budgets API errors
All checks were successful
Build and Push Monarch MCP Docker Image / build (push) Successful in 16s

Returns informative error message when Monarch Money API fails,
which may occur if budgets are not configured in the account.
This commit is contained in:
Ben
2025-12-25 04:20:39 +00:00
parent 4a309cbfb3
commit a229537599
6 changed files with 87 additions and 4 deletions

56
test_token.py Executable file
View File

@@ -0,0 +1,56 @@
import asyncio
import os
from monarchmoney import MonarchMoney
from dotenv import load_dotenv
async def test_token():
load_dotenv(override=True)
token = os.getenv("MONARCH_TOKEN")
email = os.getenv("MONARCH_EMAIL")
password = os.getenv("MONARCH_PASSWORD")
if token and token.strip():
# Strip potential prefix
if token.startswith("MONARCH_TOKEN="):
token = token.replace("MONARCH_TOKEN=", "")
print(f"Testing with TOKEN: {token[:10]}...")
mm = MonarchMoney(token=token)
elif email and password:
print(f"Testing with EMAIL: {email}")
mm = MonarchMoney()
try:
await mm.login(email, password)
print("✅ Login successful with email/password!")
except Exception as e:
print(f"❌ Login failed: {e}")
return
else:
print("❌ No credentials found in .env")
return
try:
accounts = await mm.get_accounts()
print(f"Success! Found {len(accounts.get('accounts', []))} accounts.")
except Exception as e:
print(f"Error fetching accounts: {e}")
if __name__ == "__main__":
asyncio.run(test_token())