Skip to main content
Glama
michaelkrasa

Alpha ESS MCP Server

by michaelkrasa

set_battery_discharge

Configure battery discharge schedules and cutoff levels for Alpha ESS energy storage systems to optimize energy usage and manage power flow.

Instructions

Set battery discharge configuration for a specific Alpha ESS system.
If no serial provided, auto-selects if only one system exists.

Args:
    enabled: True to enable battery discharge, False to disable
    dp1_start: Start time for discharge period 1 (HH:MM format, minutes must be :00, :15, :30, :45)
    dp1_end: End time for discharge period 1 (HH:MM format, minutes must be :00, :15, :30, :45)
    dp2_start: Start time for discharge period 2 (HH:MM format, minutes must be :00, :15, :30, :45)
    dp2_end: End time for discharge period 2 (HH:MM format, minutes must be :00, :15, :30, :45)
    discharge_cutoff_soc: Percentage to stop discharging battery at (0-100)
    serial: The serial number of the Alpha ESS system (optional)
    
Returns:
    dict: Result of discharge configuration update with success status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
enabledYes
dp1_startYes
dp1_endYes
dp2_startYes
dp2_endYes
discharge_cutoff_socYes
serialNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • main.py:878-954 (handler)
    The core handler function for the 'set_battery_discharge' tool. It is decorated with @mcp.tool(), which registers it as an MCP tool. The function handles serial auto-discovery, authenticates with the Alpha ESS API, and calls updateDisChargeConfigInfo to set the discharge parameters.
    @mcp.tool()
    async def set_battery_discharge(
            enabled: bool,
            dp1_start: str,
            dp1_end: str,
            dp2_start: str,
            dp2_end: str,
            discharge_cutoff_soc: float,
            serial: Optional[str] = None
    ) -> dict[str, Any]:
        """
        Set battery discharge configuration for a specific Alpha ESS system.
        If no serial provided, auto-selects if only one system exists.
        
        Args:
            enabled: True to enable battery discharge, False to disable
            dp1_start: Start time for discharge period 1 (HH:MM format, minutes must be :00, :15, :30, :45)
            dp1_end: End time for discharge period 1 (HH:MM format, minutes must be :00, :15, :30, :45)
            dp2_start: Start time for discharge period 2 (HH:MM format, minutes must be :00, :15, :30, :45)
            dp2_end: End time for discharge period 2 (HH:MM format, minutes must be :00, :15, :30, :45)
            discharge_cutoff_soc: Percentage to stop discharging battery at (0-100)
            serial: The serial number of the Alpha ESS system (optional)
            
        Returns:
            dict: Result of discharge configuration update with success status
        """
        client = None
        try:
            # Auto-discover serial if not provided
            if not serial:
                serial_info = await get_default_serial()
                if not serial_info['success'] or not serial_info['serial']:
                    return {
                        "success": False,
                        "message": f"Serial auto-discovery failed: {serial_info['message']}",
                        "data": None,
                        "available_systems": serial_info.get('systems', [])
                    }
                serial = serial_info['serial']
    
            app_id, app_secret = get_alpha_credentials()
            client = alphaess(app_id, app_secret)
    
            # Update the discharge configuration using the proper method signature
            result = await client.updateDisChargeConfigInfo(
                serial,
                discharge_cutoff_soc,  # batUseCap
                1 if enabled else 0,  # ctrDis
                dp1_end,
                dp2_end,
                dp1_start,
                dp2_start
            )
    
            return {
                "success": True,
                "message": f"Successfully updated discharge config for {serial}",
                "data": result,
                "serial_used": serial
            }
    
        except ValueError as e:
            return {
                "success": False,
                "message": f"Configuration or parameter error: {str(e)}",
                "data": None
            }
        except Exception as e:
            return {
                "success": False,
                "message": f"Error setting battery discharge config: {str(e)}",
                "data": None
            }
        finally:
            if client:
                await client.close()
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes the mutation action ('Set'), the auto-selection fallback behavior, and the return format ('dict: Result of discharge configuration update'). However, it lacks details about permissions needed, whether changes are reversible, rate limits, or error conditions that would help an agent use it safely.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear purpose statement followed by organized parameter explanations and return value documentation. Every sentence adds value, though the parameter explanations could be slightly more concise by grouping format requirements rather than repeating them for each time parameter.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a 7-parameter mutation tool with no annotations, the description provides substantial context: purpose, parameter semantics, return format, and system selection logic. The existence of an output schema reduces the need to fully document return values. However, it could better address behavioral aspects like error handling or prerequisites.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description fully compensates by providing detailed semantics for all 7 parameters. It explains what each parameter controls, format requirements (HH:MM with specific minute increments), value ranges (0-100 for discharge_cutoff_soc), and the optional nature of the serial parameter with its auto-selection behavior.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Set battery discharge configuration') and resource ('for a specific Alpha ESS system'), distinguishing it from sibling tools like 'get_discharge_config' (read-only) and 'set_battery_charge' (different configuration type). It uses precise terminology that avoids tautology.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool (configuring battery discharge) and includes implicit guidance about the optional serial parameter (auto-selects if only one system exists). However, it doesn't explicitly state when NOT to use it or name alternatives like 'get_discharge_config' for checking current settings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/michaelkrasa/alpha-ess-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server