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
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:
56
test_token.py
Executable file
56
test_token.py
Executable 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())
|
||||
Reference in New Issue
Block a user