get_consumption_analysis
Returns the sample household's recorded consumption between two dates from the repository's data, for the model to analyse; the dates must fall inside that data's range.
Forecast and explain electricity use for the sample household the project ships with, and pull Spanish grid prices with your own ESIOS token.
LABSCO SUMMARY
The explainability tool is what separates this from a plain prediction endpoint: you can ask what drives the model's forecast for an appliance over a horizon, then line that against the actual price for the period. The forecasts describe the sample household the models were trained on, not yours, so read it as a worked example of the method. Note the licence before you build on it — the author restricts use to academic evaluation, reference and non-commercial educational purposes with attribution, and asks that commercial use be arranged directly.
A Python MCP server on top of a master's-thesis energy-prediction system: machine-learning models trained on one sample household (its data ships in the repository), SHAP values that explain them, and the ESIOS API for Spanish electricity prices.
predict_consumption() — the sample household's forecast consumption, in Wh, between a future init_date and end_dateget_consumption_analysis() — the sample household's recorded consumption over a date range, broken down by applianceexplain_predictions() — SHAP values for a given appliance over a horizon, so the forecast is not a black boxget_precio() — electricity prices for a date range and a price_typeget_precio_inteligente() — price for a target_date with automatic fallback when the primary source has nothingPython 3.8 or higher, an ESIOS account with Red Eléctrica de España, and the token in ESIOS_API_TOKEN. The client launches it with uv from your clone of the repository, whose bundled data and models the forecast tools read; the ESIOS token is only needed by the two price tools.
Build from source
USE CASES
Forecast the sample household's consumption for coming dates, then pull prices for those dates with your ESIOS token.
Run the historical analysis for dates inside the bundled data, split by appliance.
Ask for the SHAP explanation for the appliance and horizon that drives it.
Listed in project code.
get_consumption_analysisReturns the sample household's recorded consumption between two dates from the repository's data, for the model to analyse; the dates must fall inside that data's range.
predict_consumptionPredicts the sample household's consumption, in Wh, between two future dates with the project's trained models; for past dates use get_consumption_analysis.
get_precioGets electricity prices from the ESIOS API for a date range; price_type is actual or pvpc (PVPC prices), market (OMIE day-ahead), forecast, or marginal.
get_precio_inteligenteGets the electricity price for one date: real PVPC prices for past dates, the ESIOS forecast for future ones, or an estimate from the last 7 days' average when neither is available.
explain_predictionsReturns the stored SHAP values for one appliance of the sample household (e.g. Fridge, Washing_Machine) over a horizon in days, so the model can say which inputs weigh most.
BEFORE YOU INSTALL
5 tools registered in the project's code.
The documented client runs the server on your machine.
CONTEXT COST
Rated by the size of the 5 tool definitions that ride along on every turn, not by how many there are
INSTALLATION
git clone https://github.com/Davad122/TFM.git{
"mcpServers": {
"mcp-david-TFM": {
"command": "uv",
"args": [
"--directory",
"<YOUR_PATH_TO_PROJECT>",
"run",
"-m",
"davidElectric"
],
"env": {
"ESIOS_API_TOKEN": "<YOUR_ESIOS_API_TOKEN>"
}
}
}
}