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

View File

@@ -110,7 +110,21 @@ async def get_transactions(
async def get_budgets(reason: Optional[str] = None) -> str:
"""Get current budget information."""
client = await get_authenticated_client()
budgets = await client.get_budgets()
try:
budgets = await client.get_budgets()
except Exception as e:
error_msg = str(e)
# Check if this is a Monarch API error about budgets not being set up
if "Something went wrong" in error_msg:
return serialize_json(
{
"error": "Budget data unavailable",
"detail": "The Monarch Money API returned an error. This may occur if budgets are not configured in your account.",
"raw_error": error_msg,
}
)
raise
# Build a category lookup from categoryGroups
category_lookup = {}