Skip to main content
Glama
michaelkrasa

Alpha ESS MCP Server

by michaelkrasa

get_discharge_config

Retrieve battery discharge configuration for Alpha ESS systems to view structured period definitions and status, automatically selecting the system if only one exists.

Instructions

Get battery discharge configuration for a specific Alpha ESS system.
Returns structured configuration with clear period definitions and status.
If no serial provided, auto-selects if only one system exists.

Args:
    serial: The serial number of the Alpha ESS system (optional)
    
Returns:
    dict: Enhanced response with structured discharge configuration

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serialNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • main.py:735-802 (handler)
    The primary handler function for the 'get_discharge_config' MCP tool. Decorated with @mcp.tool() for automatic registration. Retrieves discharge configuration via Alpha ESS API, structures response using DischargeConfig model, handles serial auto-detection, and formats standardized output.
    @mcp.tool()
    async def get_discharge_config(serial: Optional[str] = None) -> dict[str, Any]:
        """
        Get battery discharge configuration for a specific Alpha ESS system.
        Returns structured configuration with clear period definitions and status.
        If no serial provided, auto-selects if only one system exists.
        
        Args:
            serial: The serial number of the Alpha ESS system (optional)
            
        Returns:
            dict: Enhanced response with structured discharge configuration
        """
        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 create_enhanced_response(
                        success=False,
                        message=f"Serial auto-discovery failed: {serial_info['message']}",
                        raw_data=None,
                        data_type="config",
                        metadata={"available_systems": serial_info.get('systems', [])}
                    )
                serial = serial_info['serial']
    
            app_id, app_secret = get_alpha_credentials()
            client = alphaess(app_id, app_secret)
    
            # Get discharge config
            config = await client.getDisChargeConfigInfo(serial)
    
            # Structure the config data
            structured = structure_config_data(config, "discharge")
    
            return create_enhanced_response(
                success=True,
                message=f"Successfully retrieved discharge config for {serial}",
                raw_data=config,
                data_type="config",
                serial_used=serial,
                metadata={
                    "config_type": "battery_discharging",
                    "total_periods": 2,
                    "units": {"soc": "%", "time": "HH:MM"}
                },
                structured_data=structured
            )
    
        except ValueError as e:
            return create_enhanced_response(
                success=False,
                message=f"Configuration error: {str(e)}",
                raw_data=None,
                data_type="config"
            )
        except Exception as e:
            return create_enhanced_response(
                success=False,
                message=f"Error retrieving discharge config: {str(e)}",
                raw_data=None,
                data_type="config"
            )
        finally:
            if client:
                await client.close()
  • Dataclass schema defining the structured DischargeConfig used in tool responses, including enable status, time periods (via ConfigPeriod), discharge limit SOC, and units.
    class DischargeConfig:
        enabled: bool
        periods: List[ConfigPeriod]
        discharge_limit_soc: int
        units: Dict[str, str]
  • Utility function that transforms raw API discharge config data into structured DischargeConfig instance, mapping fields like ctrDis to enabled, timeDisf1/e1 to periods, batUseCap to discharge_limit_soc.
    def structure_config_data(raw_data: Dict[str, Any], config_type: str) -> Union[ChargeConfig, DischargeConfig, Dict]:
        """Structure configuration data with better field names"""
        if config_type == "charge":
            return ChargeConfig(
                enabled=bool(raw_data.get('gridCharge', 0)),
                periods=[
                    ConfigPeriod(
                        period=1,
                        start_time=raw_data.get('timeChaf1', '00:00'),
                        end_time=raw_data.get('timeChae1', '00:00'),
                        active=raw_data.get('timeChaf1', '00:00') != '00:00' or raw_data.get('timeChae1', '00:00') != '00:00'
                    ),
                    ConfigPeriod(
                        period=2,
                        start_time=raw_data.get('timeChaf2', '00:00'),
                        end_time=raw_data.get('timeChae2', '00:00'),
                        active=raw_data.get('timeChaf2', '00:00') != '00:00' or raw_data.get('timeChae2', '00:00') != '00:00'
                    )
                ],
                charge_limit_soc=raw_data.get('batHighCap', 100),
                units={"soc": "%", "time": "HH:MM"}
            )
        elif config_type == "discharge":
            return DischargeConfig(
                enabled=bool(raw_data.get('ctrDis', 0)),
                periods=[
                    ConfigPeriod(
                        period=1,
                        start_time=raw_data.get('timeDisf1', '00:00'),
                        end_time=raw_data.get('timeDise1', '00:00'),
                        active=raw_data.get('timeDisf1', '00:00') != '00:00' or raw_data.get('timeDise1', '00:00') != '00:00'
                    ),
                    ConfigPeriod(
                        period=2,
                        start_time=raw_data.get('timeDisf2', '00:00'),
                        end_time=raw_data.get('timeDise2', '00:00'),
                        active=raw_data.get('timeDisf2', '00:00') != '00:00' or raw_data.get('timeDise2', '00:00') != '00:00'
                    )
                ],
                discharge_limit_soc=raw_data.get('batUseCap', 10),
                units={"soc": "%", "time": "HH:MM"}
            )
        return raw_data
  • Supporting schema for configuration periods used in both ChargeConfig and DischargeConfig, defining time windows for config activation.
    class ConfigPeriod:
        period: int
        start_time: str
        end_time: str
        active: bool
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses key behavioral traits: it's a read operation ('Get'), returns structured configuration, and has auto-selection logic for the serial parameter. However, it lacks details on permissions, rate limits, error handling, or what happens if multiple systems exist without a serial, leaving gaps in behavioral context.

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

Conciseness5/5

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

The description is appropriately sized and front-loaded: the first sentence states the core purpose, followed by key behavioral details and parameter/return info. Every sentence adds value, with no wasted words, making it efficient and easy to parse for an AI agent.

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 tool's moderate complexity (1 optional parameter) and the presence of an output schema (which handles return values), the description is largely complete. It covers purpose, usage guidelines, and parameter semantics adequately. However, without annotations, it could benefit from more behavioral details like error cases or system prerequisites.

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

Parameters4/5

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

The description adds meaningful semantics beyond the input schema, which has 0% coverage. It explains that 'serial' is optional, specifies it's 'The serial number of the Alpha ESS system,' and describes the auto-selection behavior when omitted. This compensates well for the low schema coverage, though it doesn't detail format constraints like length or pattern.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Get battery discharge configuration for a specific Alpha ESS system.' It specifies the verb ('Get') and resource ('battery discharge configuration'), distinguishing it from siblings like 'get_charge_config' or 'get_alpha_ess_data.' However, it doesn't explicitly differentiate from 'set_battery_discharge,' which is a write operation, though this is implied by the 'Get' verb.

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 usage: 'If no serial provided, auto-selects if only one system exists.' This guides when to omit the parameter. It doesn't explicitly mention when not to use this tool or name alternatives among siblings, but the context implies it's for read-only configuration retrieval, not for setting or other data types.

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