Provides serverless deployment platform for the MCP server with global distribution, state management through Durable Objects, and secure credential handling via Cloudflare secrets.
Enables sending notifications and messages to Discord channels via webhooks, supporting rich formatting with embeds, TTS messages, and mention controls for task completion alerts and status updates.
Discord Notification MCP Server
An MCP (Model Context Protocol) server that sends notifications to Discord when Claude Code completes tasks. Built with TypeScript using the Cloudflare Agents SDK and deployable on Cloudflare Workers.
Features
🤖 MCP Tool: Provides a
send_discord_message
tool for sending notifications🚀 Cloudflare Workers: Runs serverless with global distribution
🔐 Secure: Uses Cloudflare secrets for credentials
🌐 Dual Transport: Supports both SSE and Streamable HTTP for maximum compatibility
💾 Durable Objects: State management required by McpAgent
💬 Rich Formatting: Supports embeds, TTS messages, and mention controls
Architecture
This server implements the MCP specification using Cloudflare's Agents SDK:
GET /sse: SSE endpoint for MCP communication
POST /mcp: Streamable HTTP endpoint for MCP communication
Built with TypeScript, MCP SDK, and Cloudflare Agents SDK
Proper JSON-RPC 2.0 error handling
Durable Objects for stateful connections (required by McpAgent)
Node.js compatibility mode enabled
Setup
Prerequisites
Discord Webhook: Create a webhook in your Discord channel:
Right-click on the channel → Edit Channel → Integrations → Webhooks
Click "New Webhook" and copy the webhook URL
Cloudflare Account: Sign up at cloudflare.com
Installation
Clone this repository
Install dependencies:
pnpm install
Configuration
Create a
.dev.vars
file from the example:cp .dev.vars.example .dev.varsThen edit
.dev.vars
with your webhook URL. This file is used for both local development and deployment.For production deployment, set up Cloudflare secrets:
npx wrangler secret put WEBHOOK_URLUpdate
wrangler.toml
with your worker name if desired
Deployment
Deploy to Cloudflare Workers:
Alternative: Continuous Deployment
You can also set up continuous deployment directly from the Cloudflare dashboard. Learn more about Git Integration with Cloudflare
Claude Code Configuration
Add the MCP server to Claude Code using the CLI via SSE transport:
Note: This server supports both SSE (Server-Sent Events) and Streamable HTTP transport. While SSE works well, Streamable HTTP provides better reliability and is the newer standard.
You can verify the configuration with:
Usage
Once configured, Claude Code can send notifications to your Discord whenever you need them.
Available Tool
send_discord_message: Send a notification message to Discord
content
(required): The message content to sendtts
(optional): Send as Text-to-Speech messageembeds
(optional): Array of embed objects for rich formattingallowed_mentions
(optional): Control which mentions are parsed
Example usage:
When You'll Get Notifications
Claude Code sends notifications when:
You explicitly ask: "notify me when done" or "let me know on Discord"
Errors occur during execution
Important milestones are reached
User input or intervention is needed
Example Scenarios
Example Notifications
CLAUDE.md Examples
To encourage Claude Code to use Discord notifications effectively, add these to your CLAUDE.md:
Development
Run locally:
For local development, Wrangler will automatically load environment variables from your .dev.vars
file.
Run all checks before deployment:
This command runs:
pnpm format
- Format code with Biomepnpm lint:fix
- Fix linting issuespnpm cf-typegen
- Generate Cloudflare typespnpm type-check
- Check TypeScript types
Test the server:
Debugging
Testing the SSE Connection
You can test the SSE endpoint directly:
This should return an event stream starting with an endpoint
event.
Common Issues
Connection closes immediately: Check that your worker is running and accessible at the specified URL.
No endpoint event received: Ensure the SSE headers are being sent correctly and the stream is properly formatted.
Discord notifications not sent: Verify your
WEBHOOK_URL
is correctly set in the worker environment.
Technical Details
Language: TypeScript (ES2021 target)
Runtime: Cloudflare Workers with Node.js compatibility
Protocol: MCP (Model Context Protocol)
Transport: SSE and Streamable HTTP
State Management: Durable Objects (required by McpAgent)
Observability: Enabled for monitoring
References
This project was built following these guides:
Related Projects
Telegram Notification MCP - Send notifications to Telegram instead of Discord
License
MIT
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Enables Claude Code to send notifications to Discord channels via webhooks when tasks complete, errors occur, or user intervention is needed. Deployed serverlessly on Cloudflare Workers with support for rich message formatting and embeds.
Related MCP Servers
- -securityFlicense-qualityThis server allows integration with Discord, enabling message exchanges between Claude and a Discord channel using prompts and notifications.Last updated -01
- AsecurityAlicenseAqualityA tool integration that enables Claude to compose and send emails through the Resend API, supporting features like scheduled delivery and file attachments.Last updated -11594MIT License
- -securityAlicense-qualityAn MCP server that enables AI assistants like Claude to help users manage their GitHub notifications through natural language commands.Last updated -016MIT License
- AsecurityAlicenseAqualityIntegrates Claude Code with DingTalk (钉钉) robot notifications, allowing users to send task completion alerts and various message formats to DingTalk groups from Claude Code.Last updated -513MIT License