home-assistant-custom-components.ha_mcp_tools: Install Python module via Nix instead of UV - #556183
home-assistant-custom-components.ha_mcp_tools: Install Python module via Nix instead of UV#556183Masrepus wants to merge 1 commit into
Conversation
…via Nix instead of UV
|
@JamieMagee in case there is some other way you got this to work in its current form I'm happy to abandon the PR, but when investigating the failure on my machine, it looked like there simply was no way to bypass the UV installation attempt without code changes 🤔 |
|
I wonder is this a flow that is only hit when you attempt to add ha_mcp as a new integration. I've been happily running (and using) ha_mcp for the last 6 months or so. |
|
I did some investigation and the UV path only runs for the in-process server entry introduced in 7.10. Older entries are treated as the tools entry, which explains why my setup kept working. I've opened homeassistant-ai/ha-mcp#2272 to add support for externally managed packages through |
|
Ah, I didn't realize this was such a new feature, thanks for looking into it! When reading through the code and docstrings some more, I was hesitant to create the upstream PR as-is, since it did seem that the installation path was something that their architecture requires. Let's see what comes out of the issue you created 🙏 |
|
Looks like they fixed this upstream: homeassistant-ai/ha-mcp#2275. It should be available in 8.3.0. |
|
Very nice, that was quick! I'm guessing we'd still need to add the Python module to the component's dependencies list, but I'll test it locally to see if that's necessary |
Things done
HA-MCP refused to start on my system in its current form, with an error message about not being able to install the HA-MCP Python module using UV.
Adding this module to the custom component's dependencies explicitly and patching the
_async_ensure_packagefunction (https://github.com/homeassistant-ai/ha-mcp/blob/master/custom_components/ha_mcp_tools/embedded_server.py#L676) to bail out if the required version is already available makes it work.While this behavior is necessary on NixOS, it may also be beneficial for other systems, so I will also open a PR for this upstream.
This PR also contains one additional patch that removes the auto update entity that prompts the user to install an update, since this is not possible in a Nix-managed setup anyway.
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.