LINE Channel for Claude Code
Chat with Claude directly from LINE — messages relay through Claude Code via MCP, giving you full tool use (file access, bash, web search) in your LINE conversations.
Architecture
LINE User (mobile)
│
▼
LINE Messaging API
│ POST /webhook
▼
Cloudflare Tunnel → localhost:8000
│
▼
server.ts (Bun + MCP stdio)
├── HTTP webhook server — validates LINE signature, routes events
├── MCP notifications — delivers messages to Claude Code
└── MCP tools — reply, download_attachment
│
▼
Claude Code (full tool use, conversation, reasoning)
│
▼
LINE Push Message API → LINE User / Group
Prerequisites
- Bun runtime (
curl -fsSL https://bun.sh/install | bash)
- Claude Code CLI installed and authenticated
- LINE Developers account with a Messaging API channel
- A public HTTPS URL pointing to
localhost:8000 — Cloudflare Tunnel works well (see below)
Setup
1. Get your LINE credentials
- Go to LINE Developers Console
- Select your Messaging API channel
- Basic settings tab → copy Channel secret → this is
LINE_CHANNEL_SECRET
- Messaging API tab → Channel access token → click Issue → copy → this is
LINE_CHANNEL_ACCESS_TOKEN
2. Save credentials
Run in Claude Code:
/line:configure <LINE_CHANNEL_SECRET> <LINE_CHANNEL_ACCESS_TOKEN>
This writes credentials to ~/.claude/channels/line/.env (chmod 600).
Or create the file manually:
mkdir -p ~/.claude/channels/line
cat > ~/.claude/channels/line/.env << 'EOF'
LINE_CHANNEL_SECRET=your_secret_here
LINE_CHANNEL_ACCESS_TOKEN=your_token_here
EOF
chmod 600 ~/.claude/channels/line/.env
3. Expose port 8000 via Cloudflare Tunnel
The LINE Messaging API requires a public HTTPS webhook URL. Cloudflare Tunnel routes LINE's HTTPS requests to localhost:8000 on your machine.
Option A — Cloudflare Dashboard (recommended)
-
Install cloudflared:
# Linux (amd64)
wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64
chmod +x cloudflared-linux-amd64
sudo mv cloudflared-linux-amd64 /usr/local/bin/cloudflared
-
Go to https://one.dash.cloudflare.com → Networks → Tunnels → Create a tunnel
-
Name it line-claude-bot, copy the token from the install command shown
-
Add a Public Hostname: subdomain bot, your domain, service HTTP, URL localhost:8000
-
Start the tunnel:
cloudflared tunnel run --protocol http2 --token <your_tunnel_token>
Your webhook URL: https://bot.yourdomain.com/webhook
Option B — Terraform (infrastructure as code)
cd terraform
cp terraform.tfvars.example terraform.tfvars
# edit terraform.tfvars with your Cloudflare API token, account ID, zone ID
terraform init && terraform apply
terraform output webhook_url # set this in LINE console
Start the tunnel:
cloudflared tunnel run --protocol http2 --token $(terraform output -raw tunnel_token)
Option C — Quick tunnel (testing only, URL changes on restart)
cloudflared tunnel --url http://localhost:8000
# Prints: https://something.trycloudflare.com
4. Set the LINE webhook URL
- LINE Developers Console → your channel → Messaging API tab
- Webhook URL:
https://bot.yourdomain.com/webhook
- Click Verify — should return success
- Enable Use webhook
5. Start the LINE channel listener
In a dedicated terminal, run:
claude --dangerously-skip-permissions --dangerously-load-development-channels plugin:line@personal
This starts Claude Code in channel-only mode — no interactive session, just LINE message handling. Leave this terminal running.
Verify the MCP server is up:
curl http://localhost:8000/health
# → {"status":"ok"}
Note: --dangerously-load-development-channels both registers the channel and bypasses the plugin allowlist. Pass the channel name to this flag only — do not also pass --channels, which creates a duplicate non-dev entry that fails with "not on the approved channels allowlist". The allowedChannelPlugins setting in settings.json is enterprise-only and has no effect for personal plugins.
6. Pair your LINE account
Message your LINE bot from your phone. It replies with a pairing code:
Pairing required — run this in your Claude Code terminal:
/line:access pair a1b2c3
Run the command in Claude Code. Within 5 seconds your LINE app shows:
Paired! Say hi to Claude.
You're ready — send messages from LINE and Claude Code responds.
Group chats
Enable group support in LINE console
Before adding the bot to a group, make sure "Allow bot to join group chats" is enabled: