Initial FlexMeasures MCP server#1
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
FastMCP server over the FlexMeasures API v3_0, built on flexmeasures-client: - 23 curated tools (26 with gated delete/authenticate) whose names match the stable operationIds in the FlexMeasures OpenAPI spec - prompts for the core workflows (build site + schedule, forecast, report automation, failed-job diagnosis) and flex-model/context resources - env-based credentials; stdio (default) and streamable-http transports - ExtendedFlexMeasuresClient adds forecasts, jobs, automations and health endpoints, accepting both 202 (API v3.0-32+) and 200 (older servers) - unit tests through the MCP protocol; opt-in e2e suite with its own docker-compose stack - server.json for the MCP registry (PyPI package, stdio) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0199yMJvFFPK5HyQRJAMpHpU Signed-off-by: F.N. Claessen <felix@seita.nl>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0199yMJvFFPK5HyQRJAMpHpU Signed-off-by: F.N. Claessen <felix@seita.nl>
Plain pytest collects e2e modules before deselecting them by marker, and the relative conftest import breaks that collection. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0199yMJvFFPK5HyQRJAMpHpU Signed-off-by: F.N. Claessen <felix@seita.nl>
92714d5 to
94cfa4a
Compare
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
|
Pushed follow-up fixes and test coverage improvements:
Verification:
|
What
A FastMCP server over the FlexMeasures API v3_0, built on
flexmeasures-client>=0.9, so agents can build and operate complete sites while the FlexMeasures server's auth and permission model stays authoritative.delete_asset/delete_automation/authenticateenabled), whose names match the stableoperationIds being added to the FlexMeasures OpenAPI spec: connection/health, asset & sensor CRUD, time-series post/read, forecast + schedule trigger/retrieve, uniform job polling (get_job_status), and automations CRUD (create_report_automationfor reports, which only run via cron automations).build_site_and_run_schedule(the full 8-step recipe),add_measurements_and_forecast,setup_report_automation,diagnose_failed_job.FLEXMEASURES_HOST/EMAIL/PASSWORD/ACCESS_TOKEN/SSL); stdio transport by default,--transport streamable-httpfor remote mode (single-identity, documented warning).flexmeasures_mcp.toolsentry-point group lets plugin packages register extra tools; broken plugins are logged and skipped.pytest -m e2e) with a self-contained docker-compose stack.server.json(namespaceio.github.flexmeasures/flexmeasures, PyPI + stdio) and themcp-name:marker in the README.Verification
uv run pytest— 52 passed, 2 deselected.uv run --with pytest-cov pytest --cov=flexmeasures_mcp --cov-report=term-missing— 95% coverage.uv run pytest -m e2e— 2 passed against the Docker Compose FlexMeasures stack.health_checkreturned FlexMeasures0.33.2.dev0+gac4f2ca48.d20260703with SQL/Redis ready,connection_inforeturned the toy user, and bad credentials returned an MCP tool error.How to test
How to demo
Requires Docker and Claude Code (or any MCP client; see below for MCP Inspector).
1. Start a throwaway FlexMeasures stack (own Postgres + Redis + worker, on port 5001) and seed the toy account:
docker compose -f tests/e2e/docker-compose.yml up -d docker compose -f tests/e2e/docker-compose.yml exec server \ flexmeasures add toy-account --kind battery2. Register the MCP server (from the repo root, so
"$PWD"points at your clone):claude mcp add flexmeasures \ -e FLEXMEASURES_HOST=localhost:5001 -e FLEXMEASURES_SSL=false \ -e FLEXMEASURES_EMAIL=toy-user@flexmeasures.io \ -e FLEXMEASURES_PASSWORD=toy-password \ -- uv --directory "$PWD" run flexmeasures-mcp3. Demo. In Claude Code, try:
or invoke the bundled
build_site_and_run_scheduleprompt. Expect the agent to walk throughcreate_asset→create_sensor→post_sensor_data→trigger_schedule→get_job_statuspolling →get_schedule, and to explain the result (charging in the cheap hours). Also fun: ask it to break something (e.g. an impossiblesoc-max) and then to run thediagnose_failed_jobprompt.Without Claude:
npx @modelcontextprotocol/inspectorlets you poke at the tools directly — set the sameFLEXMEASURES_*env vars and useuv run flexmeasures-mcpas the command.4. End-to-end test suite against the same stack:
The e2e schedule smoke test defaults to a short schedule horizon; tune it with
FLEXMEASURES_E2E_SCHEDULE_HOURS,FLEXMEASURES_E2E_POLL_SECONDS, andFLEXMEASURES_E2E_POLL_ATTEMPTSif needed.Clean up with
docker compose -f tests/e2e/docker-compose.yml down -v.🤖 Generated with Claude Code
https://claude.ai/code/session_0199yMJvFFPK5HyQRJAMpHpU