Skip to content

Commit 3ba92d5

Browse files
julienldjulienld
andauthored
docs: add Windows UV guide and reorganize assets (#34)
* docs: add Windows UV guide and reorganize assets * Revise Windows UV installation and Claude setup guide Updated installation instructions for uv and Git, streamlined the setup process, and revised configuration steps for Claude Desktop. * docs: simplify uv method instructions * Revise Method 3 for running Python with UV Updated method description and prerequisites for running Python with UV. Modified command examples for clarity. * docs: add uvx HTTP mode; feat: add ha-mcp-web console script * docs: switch Method 3 web client to uvx ha-mcp-web and simplify instructions * docs: restore cloudflared guidance for uvx web clients * docs: clean uvx method prerequisites and web instructions * docs: generalize web client instructions * Revise README for UV setup and client configuration Updated prerequisites and instructions for running Python with UV, including environment variable setup and Cloudflare Tunnel usage. * Update README with Cloudflare Tunnel instructions Clarify instructions for using Cloudflare Tunnel with public URL. * Clarify HTTP entry point comment in __main__.py Updated comment to clarify the HTTP entry point for web clients. * Update winget command and args format in guide * Update README.md * Update contributor links in README.md --------- Co-authored-by: julienld <julien@LAPTOP.localdomain>
1 parent accee54 commit 3ba92d5

7 files changed

Lines changed: 123 additions & 189 deletions

File tree

README.md

Lines changed: 49 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div align="center">
2-
<img src="img/ha-mcp-logo.png" alt="Home Assistant MCP Server Logo" width="300"/>
2+
<img src="docs/img/ha-mcp-logo.png" alt="Home Assistant MCP Server Logo" width="300"/>
33

44
# The Unofficial and Awesome Home Assistant MCP Server
55

@@ -22,7 +22,7 @@
2222

2323
---
2424

25-
![Home Assistant MCP Demo](img/demo.webp)
25+
![Home Assistant MCP Demo](docs/img/demo.webp)
2626

2727
**[YouTube version →](https://youtu.be/eCO93KfSvIM)**
2828

@@ -182,114 +182,91 @@ claude mcp add-json home-assistant '{
182182

183183
---
184184

185-
### Method 3: Python+UV
185+
### Method 3: Running Python with UV
186186

187187
**Best for:** When Docker is not available
188188

189-
**Prerequisites:**
190-
- [Git](ttps://git-scm.com/downloads)
191-
- [UV package manager](https://docs.astral.sh/uv/getting-started/installation/)
192-
- A long-lived token: ** Home Assistant → Your Profile → Security → Long-Lived Access Tokens
193-
194-
**Installation Steps:**
195-
196-
1. **Clone the repository:**
197-
```bash
198-
git clone https://github.com/homeassistant-ai/ha-mcp
199-
cd ha-mcp
200-
```
189+
> **Windows users:** Follow the [Windows UV setup guide](docs/Windows-uv-guide.md)
201190
202-
2. **(optional) Install dependencies and make sure uv is working:**
203-
```bash
204-
uv sync
205-
```
191+
**Prerequisites:**
192+
- [UV package manager](https://docs.astral.sh/uv/getting-started/installation/) and [Git binary](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
193+
- Windows: winget install astral-sh.uv Git.Git -e
194+
- MacOS: brew install git uv
195+
- Your Home assistant URL (ex: http://localhost:8123) for HOMEASSISTANT_URL variable
196+
- A Home Assistant long-lived access token (Profile → Security → Long-Lived Access Tokens) for HOMEASSISTANT_TOKEN variable
206197

207198
**Client Configuration:**
208199

209200
<details>
210201
<summary><b>📱 Claude Desktop or any mcp.json format</b></summary>
211202

212-
**Location:**
203+
**Config file:**
213204
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
214205
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
215206

216-
Add to your `mcp.json`:
217-
218-
Linux/WSL/macOS:
219-
```json
220-
{
221-
"mcpServers": {
222-
223-
"Home Assistant": {
224-
"command": "path/to/ha-mcp/run_mcp_server.sh",
225-
"args": [],
226-
"env": {
227-
"HOMEASSISTANT_URL": "http://localhost:8123",
228-
"HOMEASSISTANT_TOKEN": "your_long_lived_access_token_from_home_assistant_profile"
229-
}
230-
}
231-
232-
}
233-
}
234-
```
235-
236-
Windows:
237207
```json
238208
{
239209
"mcpServers": {
240-
241210
"Home Assistant": {
242-
"command": "C:\\path\\to\\ha-mcp\\run_mcp_server.bat",
243-
"args": [],
211+
"command": "uvx",
212+
"args": ["--from=git+https://github.com/homeassistant-ai/ha-mcp", "ha-mcp"],
244213
"env": {
245214
"HOMEASSISTANT_URL": "http://localhost:8123",
246-
"HOMEASSISTANT_TOKEN": "your_long_lived_access_token_from_home_assistant_profile"
215+
"HOMEASSISTANT_TOKEN": "your_long_lived_token"
247216
}
248217
}
249-
250218
}
251219
}
252220
```
221+
Note: replace both HOMEASSISTANT_URL and HOMEASSISTANT_TOKEN with your values.
253222

254223
</details>
255224

256225
<details>
257226
<summary><b>💻 Claude Code</b></summary>
258227

259228
```bash
260-
claude mcp add-json home-assistant '{
261-
"command": "C:\\path\\to\\ha-mcp\\run_mcp_server.bat",
262-
"args": [],
263-
"env": {
264-
"HOMEASSISTANT_URL": "http://localhost:8123",
265-
"HOMEASSISTANT_TOKEN": "your_long_lived_access_token_from_home_assistant_profile"
266-
}
267-
}'
229+
claude mcp add --transport stdio home-assistant \
230+
--env HOMEASSISTANT_URL=http://localhost:8123 \
231+
--env HOMEASSISTANT_TOKEN=your_long_lived_token \
232+
-- uvx --from=git+https://github.com/homeassistant-ai/ha-mcp ha-mcp
268233
```
269234

270235
</details>
271236

272237
<details>
273238
<summary><b>🌐 Web Clients (Claude.ai, ChatGPT, etc.)</b></summary>
274239

275-
1. **Download cloudflared binary:**
276-
- Download from: https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/
240+
Run the MCP server with uvx (replace the values of the environement variables):
277241

278-
2. **Start the MCP server with secret path:**
279-
```bash
280-
export HOMEASSISTANT_URL=http://localhost:8123
281-
export HOMEASSISTANT_TOKEN=your_long_lived_token
282-
export MCP_SECRET_PATH=/__my_secret__
283-
uv run fastmcp run fastmcp-webclient.json
284-
```
242+
Windows:
243+
```bash
244+
set HOMEASSISTANT_URL=http://localhost:8123
245+
set HOMEASSISTANT_TOKEN=your_long_lived_token
246+
set MCP_PORT=8086
247+
set MCP_SECRET_PATH=/__my_secret__
248+
uvx --from=git+https://github.com/homeassistant-ai/ha-mcp ha-mcp-web
249+
```
250+
Others:
251+
```bash
252+
export HOMEASSISTANT_URL=http://localhost:8123
253+
export HOMEASSISTANT_TOKEN=your_long_lived_token
254+
export MCP_PORT=8086
255+
export MCP_SECRET_PATH=/__my_secret__
256+
uvx --from=git+https://github.com/homeassistant-ai/ha-mcp ha-mcp-web
257+
```
285258

286-
3. **In another terminal, start Cloudflare Tunnel:**
287-
```bash
288-
cloudflared tunnel --url http://localhost:8086
289-
```
259+
Web client required https and a public URL. You need to use a proxy in front of `http://localhost:8086`.
290260

291-
4. **Use the URL from cloudflared output:** `https://abc-def.trycloudflare.com/__my_secret__`
261+
Easiest option is to download [Cloudflare Tunnel](https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/downloads/#latest-release)
292262

263+
**In another terminal, start Cloudflare Tunnel:**
264+
265+
```bash
266+
cloudflared tunnel --url http://localhost:8086
267+
```
268+
269+
Use the public url provided and add your secret path like so `https://XYZ.trycloudflare.com/__my_secret__`. This url must be used in your Web client MCP configuration and kept secret.
293270
</details>
294271

295272
**Development:** See [CONTRIBUTING.md](CONTRIBUTING.md) for testing and contribution guidelines.
@@ -405,3 +382,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
405382
- **[Model Context Protocol](https://modelcontextprotocol.io/)**: Standardized AI-application communication
406383
- **[Claude Code](https://github.com/anthropics/claude-code)**: AI-powered coding assistant
407384

385+
## 👥 Contributors
386+
387+
- **[@julienld](https://github.com/julienld)** — Project maintainer & core contributor.
388+
- **[@kingbear2](https://github.com/kingbear2)** — Windows UV setup guide.

docs/Windows-uv-guide.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Windows UV Setup Guide for ha-mcp
2+
3+
_Based on steps shared by @kingbear2._
4+
5+
This guide walks through running the ha-mcp server locally on Windows with Claude using the [uv](https://docs.astral.sh/uv/) package manager. Expect the process to take about 10 minutes.
6+
7+
## 1. Install uv and git
8+
9+
Open **PowerShell** or **cmd** and run:
10+
11+
```powershell
12+
winget install astral-sh.uv Git.Git -e
13+
```
14+
15+
## 2. Configure Claude Desktop
16+
17+
1. Open **Claude Desktop → Settings → Developer → Edit Config**.
18+
2. Replace `claude_desktop_config.json` with:
19+
20+
```json
21+
{
22+
"mcpServers": {
23+
"Home Assistant": {
24+
"command": "uvx",
25+
"args": ["--from=git+https://github.com/homeassistant-ai/ha-mcp", "ha-mcp"],
26+
"env": {
27+
"HOMEASSISTANT_URL": "http://homeassistant.local:8123",
28+
"HOMEASSISTANT_TOKEN": "your_long_lived_token"
29+
}
30+
}
31+
}
32+
}
33+
```
34+
35+
- HOMEASSISTANT_URL: use the same url (https or http) that you use for accessing home assistant
36+
- HOMEASSISTANT_TOKEN: : click your username on the bottom left of HA, click Security at the top, and scroll all the way down and create a new token. Note: this token will be displayed only once
37+
38+
3. Exit Claude completely, then relaunch it. Under **Settings → Developer** you should see the MCP server running.
39+
40+
Ask Claude to verify access (e.g., “Can you see my Home Assistant interface?”). If it enumerates integrations or entities, the setup succeeded.
41+
42+
## Troubleshooting
43+
44+
- **`uvx` not found:** Re-run the PATH export or use the full path to `uvx.exe`.
45+
- **Authentication failures:** Regenerate the long-lived token and update Claude’s config.
46+
- **Server closes immediately:** Check the console log for missing dependencies or incorrect configuration.
File renamed without changes.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "ha-mcp"
77
version = "3.1.6"
88
description = "Home Assistant MCP Server - Complete control of Home Assistant through MCP"
99
readme = "README.md"
10-
requires-python = ">=3.11"
10+
requires-python = ">=3.11,<3.14"
1111
license = {text = "MIT"}
1212
authors = [
1313
{name = "Julien", email = "github@qc-h.net"}
@@ -59,6 +59,7 @@ dev = [
5959
[project.scripts]
6060
ha-mcp = "ha_mcp.__main__:main"
6161
hamcp-test-env = "tests.test_env_manager:main"
62+
ha-mcp-web = "ha_mcp.__main__:main_web"
6263

6364
[tool.setuptools]
6465
package-dir = {"" = "src"}

src/ha_mcp/__main__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Home Assistant MCP Server."""
22

3+
import os
34
from ha_mcp.server import HomeAssistantSmartMCPServer # type: ignore[import-not-found]
45

56
# Create server instance once
@@ -15,5 +16,27 @@ def main() -> None:
1516
mcp.run()
1617

1718

19+
# HTTP entry point for web clients
20+
def main_web() -> None:
21+
"""Run server over HTTP for web-capable MCP clients.
22+
23+
Environment:
24+
- HOMEASSISTANT_URL (required)
25+
- HOMEASSISTANT_TOKEN (required)
26+
- MCP_PORT (optional, default: 8086)
27+
- MCP_SECRET_PATH (optional, default: "/mcp")
28+
"""
29+
30+
port = int(os.getenv("MCP_PORT", "8086"))
31+
path = os.getenv("MCP_SECRET_PATH", "/mcp")
32+
33+
mcp.run(
34+
transport="streamable-http",
35+
host="0.0.0.0",
36+
port=port,
37+
path=path,
38+
)
39+
40+
1841
if __name__ == "__main__":
1942
main()

0 commit comments

Comments
 (0)