Skip to content

home-assistant-custom-components.ha_mcp_tools: Install Python module via Nix instead of UV - #556183

Open
Masrepus wants to merge 1 commit into
NixOS:masterfrom
Masrepus:ha-mcp-fixes
Open

home-assistant-custom-components.ha_mcp_tools: Install Python module via Nix instead of UV#556183
Masrepus wants to merge 1 commit into
NixOS:masterfrom
Masrepus:ha-mcp-fixes

Conversation

@Masrepus

Copy link
Copy Markdown
Contributor

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_package function (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.

@nixpkgs-ci
nixpkgs-ci Bot requested review from JamieMagee and mweinelt August 24, 2026 20:07
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Aug 24, 2026
@Masrepus

Copy link
Copy Markdown
Contributor Author

@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 🤔

@JamieMagee

Copy link
Copy Markdown
Member

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.

@JamieMagee

Copy link
Copy Markdown
Member

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 skip_pip. If that lands, nixpkgs should only need to add ha-mcp as a dependency and pass --skip-pip.

@Masrepus

Copy link
Copy Markdown
Contributor Author

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 🙏

@JamieMagee

Copy link
Copy Markdown
Member

Looks like they fixed this upstream: homeassistant-ai/ha-mcp#2275. It should be available in 8.3.0.

@Masrepus

Copy link
Copy Markdown
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants