debug_session_loading
Diagnose and resolve authentication session loading problems in Monarch Money's secure keychain system.
Instructions
Debug keyring session loading issues.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/monarch_mcp/server.py:215-229 (handler)The debug_session_loading tool handler function that checks keyring for session tokens. It uses @mcp.tool() decorator for registration and calls secure_session.load_token() to retrieve the token from the system keyring.
@mcp.tool() def debug_session_loading() -> str: """Debug keyring session loading issues.""" try: # Check keyring access token = secure_session.load_token() if token: return f"Token found in keyring (length: {len(token)})" return "No token found in keyring. Run login_setup.py to authenticate." except Exception as e: # pylint: disable=broad-exception-caught error_details = traceback.format_exc() return ( f"Keyring access failed:\nError: {e}\n" f"Type: {type(e)}\nTraceback:\n{error_details}" ) - The load_token() method in SecureMonarchSession class that loads the authentication token from the system keyring. This is the core helper function used by debug_session_loading to check if a token exists.
def load_token(self) -> Optional[str]: """Load the authentication token from the system keyring.""" try: token = keyring.get_password(KEYRING_SERVICE, KEYRING_USERNAME) if token: logger.info("Token loaded from keyring") return token logger.info("No token found in keyring") return None except Exception as e: # pylint: disable=broad-exception-caught logger.error("Failed to load token from keyring: %s", e) return None - The global secure_session singleton instance of SecureMonarchSession that is imported and used by the debug_session_loading handler.
# Global session manager instance secure_session = SecureMonarchSession()