Initial commit: Monarch MCP Custom SSE server

This commit is contained in:
Ben
2025-12-24 01:54:42 +00:00
commit 714897276b
20 changed files with 1933 additions and 0 deletions

64
login_setup.py Normal file
View File

@@ -0,0 +1,64 @@
#!/usr/bin/env python3
"""
Interactive Monarch Money login with MFA support.
Saves session securely and provides the token for Docker environment.
"""
import asyncio
import os
import getpass
import sys
from pathlib import Path
# Add src to sys.path
sys.path.insert(0, str(Path(__file__).parent / "src"))
from monarchmoney import MonarchMoney, RequireMFAException
from dotenv import load_dotenv
from monarch_mcp_custom.auth import save_token
async def main():
load_dotenv()
print("\n🏦 Monarch Money - Custom MCP Setup")
print("=" * 45)
print("This script will help you obtain an authentication token")
print("for use in your Docker .env file.\n")
mm = MonarchMoney()
try:
email = input("Email: ")
password = getpass.getpass("Password: ")
try:
await mm.login(email, password, use_saved_session=False, save_session=True)
print("✅ Login successful!")
except RequireMFAException:
print("🔐 MFA code required")
mfa_code = input("Two Factor Code: ")
await mm.multi_factor_authenticate(email, password, mfa_code)
print("✅ MFA authentication successful")
token = mm.token
if token:
print("\n" + "!" * 50)
print("🔑 YOUR MONARCH_TOKEN:")
print(f"\n{token}\n")
print("!" * 50)
print("\nCopy the token above into your .env file as:")
print(f"MONARCH_TOKEN={token}")
# Also save to local keyring for convenience
save_token(token)
print("\n✅ Token also saved to local system keyring.")
else:
print("❌ Failed to retrieve token from MonarchMoney instance.")
except Exception as e:
print(f"\n❌ Setup failed: {e}")
if __name__ == "__main__":
asyncio.run(main())