Skip to main content
Glama
michaelkrasa

Alpha ESS MCP Server

by michaelkrasa

set_battery_charge

Configure battery charging from the grid for Alpha ESS systems by setting enabled status, two time periods, and charge cutoff percentage.

Instructions

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

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
enabledYes
dp1_startYes
dp1_endYes
dp2_startYes
dp2_endYes
charge_cutoff_socYes
serialNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • main.py:805-876 (handler)
    The handler function for the 'set_battery_charge' tool. Decorated with @mcp.tool() for automatic registration in FastMCP. Handles input parameters, auto-selects serial number if not provided, authenticates with Alpha ESS API, and calls updateChargeConfigInfo to set the battery charge configuration.
    @mcp.tool()
    async def set_battery_charge(
            enabled: bool,
            dp1_start: str,
            dp1_end: str,
            dp2_start: str,
            dp2_end: str,
            charge_cutoff_soc: float,
            serial: Optional[str] = None
    ) -> dict[str, Any]:
        """
        Set battery charging configuration for a specific Alpha ESS system.
        If no serial provided, auto-selects if only one system exists.
        
        Args:
            enabled: True to enable charging from grid, False to disable
            dp1_start: Start time for charging period 1 (HH:MM format, minutes must be :00, :15, :30, :45)
            dp1_end: End time for charging period 1 (HH:MM format, minutes must be :00, :15, :30, :45)
            dp2_start: Start time for charging period 2 (HH:MM format, minutes must be :00, :15, :30, :45)
            dp2_end: End time for charging period 2 (HH:MM format, minutes must be :00, :15, :30, :45)
            charge_cutoff_soc: Percentage to stop charging from grid at (0-100)
            serial: The serial number of the Alpha ESS system (optional)
            
        Returns:
            dict: Result of charge 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)
    
            # Set battery charge configuration
            result = await client.updateChargeConfigInfo(
                serial, enabled, dp1_start, dp1_end,
                dp2_start, dp2_end, charge_cutoff_soc
            )
    
            return {
                "success": True,
                "message": f"Successfully updated charge 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 charge config: {str(e)}",
                "data": None
            }
        finally:
            if client:
                await client.close()
  • main.py:805-805 (registration)
    The @mcp.tool() decorator registers the set_battery_charge function as an MCP tool.
    @mcp.tool()
  • Dataclass defining the structure for ChargeConfig, which matches the input parameters of set_battery_charge (enabled, periods with start/end times, charge_limit_soc). Used in related get_charge_config tool for output structuring.
    class ChargeConfig:
        enabled: bool
        periods: List[ConfigPeriod]
        charge_limit_soc: int
        units: Dict[str, str]
  • Dataclass for ConfigPeriod used in ChargeConfig periods, corresponding to dp1_start/end and dp2_start/end parameters.
    class ConfigPeriod:
        period: int
        start_time: str
        end_time: str
        active: bool
  • Helper function called by set_battery_charge to auto-select serial number if not provided.
    async def get_default_serial() -> dict[str, Any]:
        """
        Get the default serial number to use. If only one system is registered,
        returns that serial. If multiple systems, returns list for user to choose.
        
        Returns:
            dict: Result with serial info
        """
        client = None
        try:
            app_id, app_secret = get_alpha_credentials()
            client = alphaess(app_id, app_secret)
    
            # Get ESS list
            ess_list = await client.getESSList()
    
            if not ess_list or len(ess_list) == 0:
                return {
                    "success": False,
                    "message": "No Alpha ESS systems found in your account",
                    "serial": None,
                    "systems": []
                }
    
            if len(ess_list) == 1:
                # Auto-select the only system
                system = ess_list[0]
                serial = system.get('sysSn') if isinstance(system, dict) else getattr(system, 'sysSn', None)
                return {
                    "success": True,
                    "message": f"Auto-selected single system: {serial}",
                    "serial": serial,
                    "systems": ess_list
                }
            else:
                # Multiple systems - return list for user choice
                systems_info = []
                for system in ess_list:
                    if isinstance(system, dict):
                        systems_info.append({
                            "serial": system.get('sysSn'),
                            "name": system.get('sysName', 'Unknown'),
                            "status": system.get('sysStatus', 'Unknown')
                        })
                    else:
                        systems_info.append({
                            "serial": getattr(system, 'sysSn', 'Unknown'),
                            "name": getattr(system, 'sysName', 'Unknown'),
                            "status": getattr(system, 'sysStatus', 'Unknown')
                        })
    
                return {
                    "success": True,
                    "message": f"Found {len(ess_list)} systems. Please specify which serial to use.",
                    "serial": None,
                    "systems": systems_info
                }
    
        except Exception as e:
            return {
                "success": False,
                "message": f"Error getting system list: {str(e)}",
                "serial": None,
                "systems": []
            }
        finally:
            if client:
                await client.close()
    
    
    @mcp.tool()
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 configuration update behavior and mentions the auto-selection logic for serial numbers, which is useful context. However, it doesn't address important behavioral aspects like whether this requires authentication, what permissions are needed, whether changes are reversible, or any rate limits or side effects.

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 documentation. Every sentence earns its place, though the formatting with 'Args:' and 'Returns:' sections could be slightly more concise. The information is front-loaded with the core purpose stated first.

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 configuration tool with no annotations, the description does well by explaining all parameters and mentioning the return type. However, for a mutation tool that changes system behavior, it should ideally mention authentication requirements or permission prerequisites. The existence of an output schema reduces the need to fully document return values.

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 semantic information for all 7 parameters. It explains what each parameter means, provides format constraints (HH:MM with specific minute values), value ranges (0-100 for charge_cutoff_soc), and clarifies which parameters are optional (serial). This adds significant value beyond the bare schema.

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 verb 'Set' and resource 'battery charging configuration for a specific Alpha ESS system', making the purpose specific and actionable. It distinguishes from sibling tools like 'set_battery_discharge' by focusing on charging rather than discharging.

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: to configure battery charging settings for an Alpha ESS system. It includes the helpful detail about auto-selecting the system if only one exists when no serial is provided. However, it doesn't explicitly mention when NOT to use it or alternatives like 'set_battery_discharge' for discharge configuration.

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