KN

Knock MCP Server for Multi-Channel Messaging

Send unified product and customer messaging across email, in-app, push, SMS, Slack, and MS Teams with the Knock MCP server for reliable multi-channel delivery.

Quick Install
npx -y @knocklabs/agent-toolkit#model-context-protocol-mcp

Overview

The Knock MCP (Model Context Protocol) server is a lightweight service that centralizes message composition and delivery across multiple channels — email, in-app, push, SMS, Slack, and Microsoft Teams. It provides a single place to supply customer and product context (user profile, organization data, event metadata, templates, and channel preferences) and then renders and routes messages to the appropriate providers for each channel.

For developer teams building cross-channel notification systems, the MCP server reduces duplication of delivery logic, enforces channel-specific formatting, and simplifies fallbacks and retries. Instead of wiring templates and provider SDKs into many parts of your application, you send contextual payloads to the MCP server and let it produce channel-specific messages and dispatch them reliably.

Features

  • Single API for multi-channel messaging and context enrichment
  • Template rendering per channel (HTML for email, plaintext for SMS, blocks for Slack)
  • Channel preference resolution and recipient targeting
  • Fallbacks and retries to improve delivery reliability
  • Pluggable provider integrations (SMTP, push providers, SMS gateways, Slack, MS Teams)
  • Message deduplication and rate limiting support
  • Local development server and Docker support
  • Audit logs and webhooks for delivery events

Installation / Configuration

Minimum system requirements: Node.js 16+ (or run via Docker).

Quickstart (Node/npm)

git clone https://github.com/knocklabs/agent-toolkit.git
cd agent-toolkit
# example: mcp server lives under packages/mcp-server
cd packages/mcp-server
npm install
npm run build
# set environment variables, then start
export KNOCK_API_KEY=your_knock_api_key
export PORT=8080
npm start

Run with Docker

# docker-compose.yml
version: "3.8"
services:
  mcp:
    image: knocklabs/mcp-server:latest
    ports:
      - "8080:8080"
    environment:
      - KNOCK_API_KEY=${KNOCK_API_KEY}
      - NODE_ENV=production
      - PORT=8080

Environment variables

VariableDescriptionExample
KNOCK_API_KEYAPI key for Knock / provider servicesk_live_12345
PORTHTTP port the server listens on8080
LOG_LEVELLogging verbosity (info/debug/error)info
TEMPLATE_DIRPath to channel templates./templates
DEFAULT_FROM_EMAILDefault “from” address for email channel[email protected]

Configuration file (example config.json)

{
  "providers": {
    "email": { "type": "smtp", "host": "smtp.example.com", "port": 587 },
    "sms": { "type": "twilio", "accountSid": "...", "authToken": "..." },
    "slack": { "webhookUrl": "https://hooks.slack.com/services/..." }
  },
  "defaults": {
    "fromEmail": "[email protected]",
    "retryPolicy": { "retries": 3, "backoffMs": 2000 }
  }
}

Available Resources

  • Source code and examples: https://github.com/knocklabs/agent-toolkit#model-context-protocol-mcp
  • Local development: built-in server with hot reload (npm run dev)
  • Templates: channel-specific templates folder with examples for email, SMS, push, Slack blocks
  • Provider adapters: modular adapters for SMTP, Twilio, Firebase/APNs, Slack, and MS Teams
  • Webhook endpoints: delivery status and error callbacks for integration with analytics or audit stores

Use Cases

  1. Transactional notifications (order confirmations)

    • Send a unified message when an order is placed that includes an HTML email, in-app confirmation, push notification for mobile, and an SMS receipt if the user prefers SMS.
    • The MCP server accepts order context (order id, line items, user id) and generates channel-appropriate content from the same template source.
  2. Alerting and incident notifications

    • Send critical alerts to on-call engineers via Slack and SMS, with a fallback to email if other channels fail.
    • The server enforces rate limits and escalation rules to avoid alert storms.
  3. Feature announcements and product messaging

    • Target users based on segments and channel preference: in-app modals for active users, email for less-active users, and push for mobile users.
    • The MCP server handles templating and personalization across channels so product teams can author one message payload.
  4. Multi-tenant apps

    • Deliver tenant-specific branding and from-addresses by selecting tenant templates and provider credentials at send time.
    • The MCP server routes messages under the correct tenant context and logs events per tenant.

Example API

Below is a representative API request pattern to create a multi-channel message. The exact endpoint and payload shape can vary by implementation.

Request:

POST /mcp/v1/messages
Content-Type: application/json
Authorization: Bearer <MCP_API_KEY>

{
  "recipient": { "userId": "user_123", "channels": ["email","sms","slack"] },
  "context": {
    "user": { "name": "Ava", "email": "[email protected]", "phone": "+15550001111" },
    "order": { "id": "ord_987", "total": 49.99 }
  },
  "template": "order_confirmation",
  "metadata": { "source": "checkout" }
}

Typical response:

{
  "messageId": "msg_abc123",
  "status": "queued",
  "channels": {
    "email": { "status": "queued" },
    "sms": { "status": "queued" },
    "slack": { "status": "skipped", "reason": "recipient_not_connected" }
  }
}

Notes

  • Use the server’s webhooks or status endpoints to track delivery, bounces, and failures.
  • For production use, configure retries, monitoring, and provider credentials securely (secrets manager recommended).

If you need help mapping your existing notification logic into the MCP server model, check the GitHub repository for example adapters and templates to get started fast.