list_indicators
Browse and discover all available electricity indicators from Spain's grid operator REE, including data on demand, generation, prices, and emissions with metadata like units and frequencies.
Instructions
List all available electricity indicators from REE.
Returns metadata for all 1,967+ available indicators including their IDs, names, units, frequencies, and geographic scopes.
Args: limit: Maximum number of indicators to return (default: all) offset: Number of indicators to skip for pagination (default: 0)
Returns: JSON string with list of indicator metadata.
Examples: Get first 50 indicators: >>> await list_indicators(limit=50, offset=0)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| offset | No |
Implementation Reference
- MCP tool handler function for 'list_indicators'. This is the entry point decorated with @mcp.tool() that registers the tool, handles input parameters, executes the use case, and formats the JSON response.@mcp.tool() async def list_indicators(limit: int | None = None, offset: int = 0) -> str: """List all available electricity indicators from REE. Returns metadata for all 1,967+ available indicators including their IDs, names, units, frequencies, and geographic scopes. Args: limit: Maximum number of indicators to return (default: all) offset: Number of indicators to skip for pagination (default: 0) Returns: JSON string with list of indicator metadata. Examples: Get first 50 indicators: >>> await list_indicators(limit=50, offset=0) Get all indicators: >>> await list_indicators() """ try: async with ToolExecutor() as executor: use_case = executor.create_list_indicators_use_case() indicators = await use_case.execute(limit=limit, offset=offset) result = { "count": len(indicators), "indicators": [ind.model_dump() for ind in indicators], } return ResponseFormatter.success(result, ensure_ascii=False) except Exception as e: return ResponseFormatter.unexpected_error(e, context="Error listing indicators")
- Core business logic implementation in ListIndicatorsUseCase.execute(). Fetches indicators from repository and maps to DTO response objects.class ListIndicatorsUseCase: """Use case for listing all available indicators. Attributes: repository: Indicator repository implementation """ def __init__(self, repository: IndicatorRepository) -> None: """Initialize use case. Args: repository: Indicator repository """ self.repository = repository async def execute( self, limit: int | None = None, offset: int = 0 ) -> list[IndicatorMetadataResponse]: """Execute the use case. Args: limit: Maximum number of indicators to return offset: Number of indicators to skip Returns: List of indicator metadata. """ indicators = await self.repository.list_all_indicators(limit=limit, offset=offset) return [ IndicatorMetadataResponse( id=int(ind.id), name=ind.name, short_name=ind.short_name, description=ind.description, unit=ind.unit.value, frequency=ind.frequency, geo_scope=ind.geo_scope.value, ) for ind in indicators ]
- src/ree_mcp/interface/mcp_server.py:81-115 (registration)The @mcp.tool() decorator registers the list_indicators tool with the FastMCP server.@mcp.tool() async def list_indicators(limit: int | None = None, offset: int = 0) -> str: """List all available electricity indicators from REE. Returns metadata for all 1,967+ available indicators including their IDs, names, units, frequencies, and geographic scopes. Args: limit: Maximum number of indicators to return (default: all) offset: Number of indicators to skip for pagination (default: 0) Returns: JSON string with list of indicator metadata. Examples: Get first 50 indicators: >>> await list_indicators(limit=50, offset=0) Get all indicators: >>> await list_indicators() """ try: async with ToolExecutor() as executor: use_case = executor.create_list_indicators_use_case() indicators = await use_case.execute(limit=limit, offset=offset) result = { "count": len(indicators), "indicators": [ind.model_dump() for ind in indicators], } return ResponseFormatter.success(result, ensure_ascii=False) except Exception as e: return ResponseFormatter.unexpected_error(e, context="Error listing indicators")
- Factory method in ToolExecutor that creates the ListIndicatorsUseCase instance with injected repository.def create_list_indicators_use_case(self) -> ListIndicatorsUseCase: """Create a ListIndicatorsUseCase instance. Returns: Configured use case instance """ return ListIndicatorsUseCase(self.repository)
- Uses IndicatorMetadataResponse DTO for output schema/validation.from ..dtos import IndicatorMetadataResponse class ListIndicatorsUseCase: """Use case for listing all available indicators. Attributes: repository: Indicator repository implementation """ def __init__(self, repository: IndicatorRepository) -> None: """Initialize use case. Args: repository: Indicator repository """ self.repository = repository async def execute( self, limit: int | None = None, offset: int = 0 ) -> list[IndicatorMetadataResponse]: """Execute the use case. Args: limit: Maximum number of indicators to return offset: Number of indicators to skip Returns: List of indicator metadata. """ indicators = await self.repository.list_all_indicators(limit=limit, offset=offset) return [ IndicatorMetadataResponse( id=int(ind.id), name=ind.name, short_name=ind.short_name, description=ind.description, unit=ind.unit.value, frequency=ind.frequency, geo_scope=ind.geo_scope.value, ) for ind in indicators ]