DominionZA/HomeAssistant-ChatGpt-MCP
If you are the rightful owner of HomeAssistant-ChatGpt-MCP and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Home Assistant ChatGPT MCP Server enables AI assistants to interact with Home Assistant using natural language commands via the Model Context Protocol.
Home Assistant ChatGPT MCP Server
A Model Context Protocol (MCP) server that allows AI assistants to send commands to ChatGPT in Home Assistant. Compatible with Claude Desktop, Cursor, and any MCP-enabled AI client.
Features
- Send natural language commands to ChatGPT in Home Assistant
- Works with any MCP-compatible AI client
- Secure environment variable configuration
- Real-time device state feedback
Prerequisites
- Home Assistant with OpenAI Conversation integration configured
- Python 3.8+
- Long-lived access token from Home Assistant
Installation
-
Clone the repository:
git clone https://github.com/DominionZA/HomeAssistant-ChatGpt-MCP.git cd HomeAssistant-ChatGpt-MCP
-
Install the MCP server:
pip install -e .
-
Set up environment variables:
Windows (PowerShell):
$env:HA_TOKEN = "your_long_lived_access_token_here" $env:HA_URL = "http://homeassistant.local:8123" # Optional, defaults to this
Windows (Command Prompt):
set HA_TOKEN=your_long_lived_access_token_here set HA_URL=http://homeassistant.local:8123
Linux/Mac:
export HA_TOKEN="your_long_lived_access_token_here" export HA_URL="http://homeassistant.local:8123" # Optional
To make environment variables permanent:
- Windows: Add them to System Environment Variables
- Linux/Mac: Add the export commands to your
~/.bashrc
or~/.zshrc
Getting Your Home Assistant Token
- Go to your Home Assistant web interface
- Click on your profile (bottom left)
- Scroll down to "Long-Lived Access Tokens"
- Click "Create Token"
- Give it a name like "MCP Server"
- Copy the token and use it as your
HA_TOKEN
Configuration for AI Clients
Claude Desktop
Add this to your Claude Desktop config file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
Mac: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"homeassistant-chatgpt": {
"command": "homeassistant-chatgpt-mcp",
"env": {
"HA_TOKEN": "your_long_lived_access_token_here",
"HA_URL": "http://homeassistant.local:8123"
}
}
}
}
Cursor
Add this to your Cursor config file:
Windows: %APPDATA%\Cursor\User\globalStorage\anysphere.cursor\settings\claude_desktop_config.json
{
"mcpServers": {
"homeassistant-chatgpt": {
"command": "homeassistant-chatgpt-mcp",
"env": {
"HA_TOKEN": "your_long_lived_access_token_here",
"HA_URL": "http://homeassistant.local:8123"
}
}
}
}
After adding the configuration, restart your AI client.
Usage
Once configured, you can use natural language commands in your AI client:
- "Turn on the living room lights"
- "Set the bedroom lamp to blue"
- "Turn off all the lights"
- "Set the thermostat to 72 degrees"
- "Turn the Pad Mi Lamp on and to one of the following colors - red, orange, pink, blue, yellow or purple. Don't choose a color it is currently."
The MCP server will:
- Send your command to ChatGPT in Home Assistant
- Return success/failure status
- Show which devices were affected
Environment Variables
Variable | Required | Default | Description |
---|---|---|---|
HA_TOKEN | Yes | None | Your Home Assistant long-lived access token |
HA_URL | No | http://homeassistant.local:8123 | Your Home Assistant URL |
Testing
Test the MCP server directly:
homeassistant-chatgpt-mcp
If configured correctly, it will start and wait for input. Press Ctrl+C to exit.
Troubleshooting
"HA_TOKEN environment variable is required"
- Make sure you've set the
HA_TOKEN
environment variable - Restart your terminal/AI client after setting variables
"Cannot connect to Home Assistant"
- Check that Home Assistant is running
- Verify your
HA_URL
is correct - Ensure your token has the right permissions
"No response from ChatGPT"
- Verify OpenAI Conversation integration is set up in Home Assistant
- Check that ChatGPT has access to control your devices
Security
- Never commit your Home Assistant token to version control
- Use environment variables to keep credentials secure
- Regularly rotate your access tokens
License
MIT License - see LICENSE file for details.