Skip to main content
Esta página todavía está en inglés. La traducción al español está en progreso.

Channels Reference — Building Custom Channels

Technical reference for building an MCP server that pushes webhooks, alerts, and chat messages into a Claude Code session.
To use existing channels (Telegram, Discord, iMessage), see the Channels Guide.

Overview

A channel is an MCP server that runs on the same machine as Claude Code. Claude Code spawns it as a subprocess and communicates over stdio. Your channel server bridges external systems and the session:
  • Chat platforms (Telegram, Discord): your plugin runs locally and polls the platform’s API. When someone DMs the bot, the plugin receives the message and forwards it to Claude.
  • Webhooks (CI, monitoring): your server listens on a local HTTP port. External systems POST to that port, and your server pushes the payload to Claude.

Requirements

Your server must:
  1. Declare the claude/channel capability so Claude Code registers a notification listener
  2. Emit notifications/claude/channel events when something happens
  3. Connect via stdio transport

Example: Webhook Receiver

A single-file server that listens for HTTP requests and forwards them into your Claude Code session.

1. Create the Project

2. Write the Server

3. Register in MCP Config

4. Test

The payload arrives as:

Server Options

Notification Format

Emit notifications/claude/channel with two params:
Result in Claude’s context:
Note on meta keys: only letters, digits, and underscores. Keys with hyphens are silently dropped.

Expose a Reply Tool (Two-Way)

For bidirectional channels (chat bridges), expose a standard MCP tool:
Update instructions so Claude knows to use the tool:

Gate Inbound Messages (Security)

An ungated channel is a prompt injection vector. Always check the sender against an allowlist before emitting:
Important: Gate on the sender’s ID (message.from.id), not the chat/room (message.chat.id). In group chats, anyone in the room could inject messages.

Permission Relay

Requires Claude Code v2.1.81+
Bidirectional channels can forward permission prompts for remote approval.

How It Works

  1. Claude Code generates a request ID and notifies your server
  2. Your server forwards the prompt to the chat platform
  3. The remote user replies with yes <id> or no <id>
  4. Your handler parses the reply and emits a verdict
The local terminal dialog stays open — the first response (local or remote) is applied.

Implementation

1. Declare the capability:
2. Handle incoming request:
3. Intercept verdict in inbound handler:

Permission Request Fields

Package as a Plugin

To make your channel installable and shareable:
  1. Package it as a plugin
  2. Publish to a marketplace
  3. Users install with /plugin install and enable with --channels plugin:<name>@<marketplace>
Channels published to custom marketplaces still require --dangerously-load-development-channels until added to the official allowlist or the organization’s allowedChannelPlugins.

Testing During the Research Preview

Custom channels are not on the approved allowlist. Use the development flag:
The bypass is per-entry. The channelsEnabled organization policy still applies.

References

  • Channels Guide — setup for official channels (Telegram, Discord, iMessage)
  • Working implementations — complete server code with pairing, reply tools, and file attachments
  • MCP — the underlying protocol that channel servers implement