authenticate_alphaess
Validate credentials for Alpha ESS solar inverter and battery system API access to enable energy monitoring and configuration.
Instructions
Authenticate with the Alpha ESS Open API to validate credentials.
Returns:
dict: Authentication result with success status and message
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- main.py:310-357 (handler)The main handler function for the 'authenticate_alphaess' tool, decorated with @mcp.tool() for automatic registration in FastMCP. It authenticates using credentials from env vars, creates an alphaess client, calls client.authenticate(), and returns success/failure dict.@mcp.tool() async def authenticate_alphaess() -> dict[str, Any]: """ Authenticate with the Alpha ESS Open API to validate credentials. Returns: dict: Authentication result with success status and message """ client = None try: app_id, app_secret = get_alpha_credentials() # Create Alpha ESS client instance with credentials client = alphaess(app_id, app_secret) # Attempt authentication auth_result = await client.authenticate() if auth_result: return { "success": True, "message": "Successfully authenticated with Alpha ESS API", "authenticated": True } else: return { "success": False, "message": "Authentication failed - invalid credentials or API error", "authenticated": False } except ValueError as e: return { "success": False, "message": f"Configuration error: {str(e)}", "authenticated": False } except Exception as e: return { "success": False, "message": f"Unexpected error during authentication: {str(e)}", "authenticated": False } finally: # Clean up the client connection if client: await client.close()
- main.py:229-238 (helper)Helper function to retrieve Alpha ESS app_id and app_secret from environment variables, used by the authenticate_alphaess handler.def get_alpha_credentials(): """Get Alpha ESS credentials from environment variables""" app_id = os.getenv('ALPHA_ESS_APP_ID') app_secret = os.getenv('ALPHA_ESS_APP_SECRET') if not app_id or not app_secret: raise ValueError("ALPHA_ESS_APP_ID and ALPHA_ESS_APP_SECRET environment variables must be set") return app_id, app_secret
- main.py:310-310 (registration)The @mcp.tool() decorator registers the authenticate_alphaess function as an MCP tool.@mcp.tool()