Skip to main content
Glama
ESJavadex

REE MCP Server

by ESJavadex

get_international_exchanges

Retrieve electricity import/export data between Spain and neighboring countries (Andorra, Morocco, Portugal, France) at specific dates and times, providing net balance calculations for cross-border energy flow analysis.

Instructions

Get international electricity exchanges at a specific time.

Returns import/export data by country (Andorra, Morocco, Portugal, France) with net balance calculations.

Args: date: Date in YYYY-MM-DD format hour: Hour in HH format (00-23, default: 12)

Returns: JSON string with imports, exports, and net balance by country.

Examples: Get exchanges at noon on Oct 8: >>> await get_international_exchanges("2025-10-08", "12")

Get overnight exchanges:
>>> await get_international_exchanges("2025-10-08", "02")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateYes
hourNo12

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for get_international_exchanges using @mcp.tool() decorator. Builds datetime range, creates service, fetches exchanges, formats response.
    @mcp.tool()
    async def get_international_exchanges(date: str, hour: str = "12") -> str:
        """Get international electricity exchanges at a specific time.
    
        Returns import/export data by country (Andorra, Morocco, Portugal, France)
        with net balance calculations.
    
        Args:
            date: Date in YYYY-MM-DD format
            hour: Hour in HH format (00-23, default: 12)
    
        Returns:
            JSON string with imports, exports, and net balance by country.
    
        Examples:
            Get exchanges at noon on Oct 8:
            >>> await get_international_exchanges("2025-10-08", "12")
    
            Get overnight exchanges:
            >>> await get_international_exchanges("2025-10-08", "02")
        """
        try:
            start_datetime, end_datetime = DateTimeHelper.build_datetime_range(date, hour)
    
            async with ToolExecutor() as executor:
                use_case = executor.create_get_indicator_data_use_case()
                data_fetcher = DataFetcher(use_case)
                service = InternationalExchangeService(data_fetcher)
    
                result = await service.get_international_exchanges(start_datetime, end_datetime)
    
            return ResponseFormatter.success(result)
    
        except Exception as e:
            return ResponseFormatter.unexpected_error(e, context="Error getting exchanges")
  • Core logic in InternationalExchangeService.get_international_exchanges: fetches export/import data for each country using indicator config, computes net balances and totals.
    async def get_international_exchanges(self, start_date: str, end_date: str) -> dict[str, Any]:
        """Get international electricity exchanges.
    
        Args:
            start_date: Start datetime in ISO format
            end_date: End datetime in ISO format
    
        Returns:
            Exchange data by country with net balance
        """
        exchanges = IndicatorIDs.get_international_exchanges()
    
        result: dict[str, Any] = {
            "datetime": start_date,
            "exchanges": {},
            "totals": {"total_exports_mw": 0.0, "total_imports_mw": 0.0, "net_balance_mw": 0.0},
        }
    
        for country, indicators in exchanges.items():
            # Fetch export and import data
            export_mw = await self.data_fetcher.fetch_value_at_time(
                indicators["export"], start_date, end_date, "hour"
            )
            import_mw = await self.data_fetcher.fetch_value_at_time(
                indicators["import"], start_date, end_date, "hour"
            )
    
            if export_mw is not None and import_mw is not None:
                net_mw = import_mw - export_mw
    
                result["exchanges"][country] = {
                    "export_mw": export_mw,
                    "import_mw": import_mw,
                    "net_balance_mw": net_mw,
                    "net_flow": (
                        "import" if net_mw > 0 else "export" if net_mw < 0 else "balanced"
                    ),
                }
    
                result["totals"]["total_exports_mw"] += export_mw
                result["totals"]["total_imports_mw"] += import_mw
            else:
                result["exchanges"][country] = {"error": "Could not fetch exchange data"}
    
        result["totals"]["net_balance_mw"] = (
            result["totals"]["total_imports_mw"] - result["totals"]["total_exports_mw"]
        )
    
        return result
  • IndicatorIDs.get_international_exchanges provides the mapping of countries to export/import indicator metadata used by the service.
    def get_international_exchanges(cls) -> dict[str, dict[str, IndicatorMetadata]]:
        """Get international exchange indicators by country.
    
        Returns:
            Dictionary mapping country names to export/import indicators.
        """
        return {
            "andorra": {
                "export": cls.EXPORT_ANDORRA,
                "import": cls.IMPORT_ANDORRA,
            },
            "morocco": {
                "export": cls.EXPORT_MOROCCO,
                "import": cls.IMPORT_MOROCCO,
            },
            "portugal": {
                "export": cls.EXPORT_PORTUGAL,
                "import": cls.IMPORT_PORTUGAL,
            },
            "france": {
                "export": cls.EXPORT_FRANCE,
                "import": cls.IMPORT_FRANCE,
            },
        }
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by disclosing: the tool returns import/export data with net balance calculations, specifies the exact countries covered, shows default hour value, provides return format (JSON string), and includes concrete usage examples. However, it doesn't mention potential limitations like data availability constraints, rate limits, or authentication requirements.

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 well-structured and front-loaded: purpose statement first, then return details, followed by parameter documentation, return format, and practical examples. Every sentence adds value with no redundancy. The examples are particularly efficient at demonstrating usage.

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

Completeness5/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 (2 parameters), no annotations, but with output schema present, the description provides excellent coverage: clear purpose, parameter details with formats and defaults, return format specification, and practical examples. The output schema existence means the description doesn't need to exhaustively document return structure, allowing it to focus on usage context.

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?

Despite 0% schema description coverage, the description fully compensates by providing: date format (YYYY-MM-DD), hour format (HH, 00-23), hour default value (12), and concrete examples showing both parameters in use. The Args section clearly documents both parameters beyond what the bare schema provides.

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 tool's purpose: 'Get international electricity exchanges at a specific time' with specific resources (import/export data by country) and scope (Andorra, Morocco, Portugal, France with net balance calculations). It distinguishes itself from siblings like get_generation_mix or get_demand_summary by focusing specifically on cross-border electricity flows rather than domestic generation or consumption metrics.

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

Usage Guidelines3/5

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

The description implies usage context through examples showing date/hour parameter usage, but doesn't explicitly state when to use this tool versus alternatives like get_generation_mix (which might show domestic generation) or compare_forecast_actual (which might compare predictions). No explicit guidance on prerequisites, limitations, or when-not-to-use scenarios is provided.

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/ESJavadex/ree-mcp'

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