Initial commit: Monarch MCP Custom SSE server
This commit is contained in:
64
login_setup.py
Normal file
64
login_setup.py
Normal 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())
|
||||
Reference in New Issue
Block a user