HA-LineBot-MCP

Home assistant Line bot整合,結合MCP(Model Context Protocol) server。 / A Home Assistant integration for LINE Bot, combined with an MCP (Model Context Protocol) server

GitHub Stars

1

User Rating

Not Rated

Favorites

0

Views

20

Forks

0

Issues

1

README

Contributors
Forks
Stargazers
Issues
License

LINE Bot MCP Integration for Home Assistant

A custom integration for Home Assistant that integrates LINE Bot with the Model Context Protocol (MCP).

🌟 Features
  • 🤖 Full LINE Bot Support — Receive and send various LINE message types.
  • 🧠 MCP Server — Let AI assistants (Claude, ChatGPT) control your LINE Bot directly.
  • 🏠 Home Assistant Native Integration — Offers services and sensors.
  • 📱 Rich Message Types — Text, image, video, audio, location, sticker, Flex, and more.
  • 🔄 Smart Auto Reply — Integrates conversation agents for intelligent replies.
  • 📊 Real-Time Monitoring — Track bot status and quota usage.

[!Warning]
Auto reply is currently an experimental feature and may not always work as expected.

📋 Requirements
  • Home Assistant 2025.7.0 or later
  • A LINE Developers account
🚀 Getting Started
1. Install the Integration

Using HACS (recommended):

  1. Add the custom repository in HACS:
    HACS Repository
  2. Search for and install "LINE Bot MCP"
  3. Restart Home Assistant
2. Set Up the LINE Bot
  1. Go to LINE Developers Console
  2. Create a Messaging API Channel
  3. Copy your Channel Access Token and Channel Secret
3. Configure the Integration
  1. In Home Assistant, add the "LINE Bot MCP" integration
  2. Provide your Bot ID, Channel Access Token, and Channel Secret
  3. Go to the attributes of the bot info sensor to view the Webhook endpoint
  4. Enter the Webhook URL in the LINE Developer Console
🎯 Usage
Home Assistant Services
# Send a text message
service: notify.linebot_push_message
data:
  name: "@bot123"
  to: "U1234567890abcdef1234567890abcdef"
  messages:
    - type: "text"
      text: "Hello from Home Assistant!"

# Reply to a message
service: notify.linebot_reply_message
data:
  name: "@bot123"
  reply_token: "{{ trigger.event.data.reply_token }}"
  messages:
    - type: "text"
      text: "Got your message!"
Example Automation
automation:
  - alias: "LINE Bot Reply"
    trigger:
      platform: event
      event_type: linebot_@bot123_message_received
    action:
      service: notify.linebot_reply_message
      data:
        name: "@bot123"
        reply_token: "{{ trigger.event.data.reply_token }}"
        messages:
          - type: "text"
            text: "Hello! This is the Home Assistant LINE Bot"
MCP Tools

Available tools for AI assistants:

  • push_message — Send a message
  • reply_message — Reply to a message
  • get_quota — Get usage quota

MCP SSE Endpoint:

http://your-ha-url:8123/linebotmcp/sse
📱 Supported Message Types
Type Description Example
text Plain text message {"type": "text", "text": "Hello"}
textV2 Text with mentions/emojis Includes mentions and emojis
image Image message Requires image and preview URLs
video Video message Requires video and preview URLs
audio Audio message Requires audio URL and duration
location Location message Includes coordinates and address
sticker Sticker message Requires package ID and sticker ID
flex Flex message Custom layout design
imagemap Imagemap message Image map with actions
template Template message Buttons and text layout
🔧 Advanced Settings
Options
  • Agent ID — Specify which conversation agent to use (default: conversation.google_generative_ai)
  • Auto Reply — Enable or disable automatic responses
Events

This integration emits the following events:

  • linebot_mcp_{bot_name}_message_received — When a message is received
  • linebot_mcp_{bot_name}_postback — When a postback is received

Events include the user ID, message content, reply token, and other metadata.

🐛 Troubleshooting
Common Issues

Webhook not receiving messages:

  • Check the webhook URL configuration
  • Ensure Home Assistant is accessible from the internet
  • Verify the Channel Secret

MCP connection failed:

  • Check your network connection
  • Check Home Assistant logs

Failed to send messages:

  • Verify Channel Access Token
  • Ensure message format is correct
  • Confirm the recipient's user ID
Debug Logging
logger:
  default: warning
  logs:
    linebot_mcp: debug
📚 Resources
🙏 Acknowledgements

The MCP server part was developed with reference to homeassistant-mcp-server.