Week 3 at CodeCraft Studios. Your automation system is already transforming how the team works:
The team is feeling much more confident… until Monday morning brings a new crisis.
The frontend team (Emma and Jake) spent the entire weekend debugging a nasty API integration issue. They tried everything: checked their network calls, validated request formats, even rewrote the error handling. Finally, at 2 AM Sunday, they discovered the backend team had fixed this exact issue on Friday and deployed the fix to staging - but forgot to announce it.
“We wasted 12 hours solving a problem that was already fixed!” Emma says, frustrated.
Meanwhile, the design team finished the new user onboarding flow illustrations last week, but the frontend team didn’t know they were ready. Those beautiful assets are still sitting unused while the team ships a temporary design.
The team realizes they have an information silo problem. Everyone’s working hard, but they’re not communicating effectively about what’s happening when.
Your mission: Complete the automation system with intelligent Slack notifications that keep the whole team informed about important developments automatically.
This final module completes the CodeCraft Studios transformation. You’ll integrate Tools and Prompts to create a smart notification system that sends formatted Slack messages about CI/CD events, demonstrating how all MCP primitives work together in a real-world scenario.
Building on the foundation from Modules 1 and 2, you’ll add the final piece of the puzzle:
The Final Piece: Watch how your complete automation system prevents those Monday morning surprises that plagued Emma and Jake!
What You’ll See:
get_recent_actions_events pulls fresh CI data, then send_slack_notification delivers the alertThe Smart Notification: Claude doesn’t just spam the team—it crafts a professional alert with:
Why This Matters: Remember the communication gap crisis? No more! This system ensures that when CI fails on demo-bad-pr branch, the whole team knows immediately. No more weekend debugging sessions for issues that were already fixed!
The Complete Journey: From Module 1’s PR chaos to Module 3’s intelligent team notifications—you’ve built a system that transforms how CodeCraft Studios collaborates. The weekend warriors become informed teammates! 🚀
By the end of this module, you’ll understand:
You’ll need everything from the previous modules plus:
This module demonstrates the complete workflow:
You’ll use Slack’s markdown for rich messages:
*bold text* for emphasis_italic text_ for details`code blocks` for technical info> quoted text for summaries<https://github.com/user/repo|Repository>slack-notification/
├── starter/ # Your starting point
│ ├── server.py # Modules 1+2 code + TODOs
│ ├── webhook_server.py # From Module 2
│ ├── pyproject.toml
│ └── README.md
└── solution/ # Complete implementation
├── server.py # Full Slack integration
├── webhook_server.py
└── README.mdCreate a Slack webhook:
Test webhook works (following webhook posting examples):
curl -X POST -H 'Content-type: application/json' \
--data '{"text":"Hello from MCP Course!"}' \
YOUR_WEBHOOK_URLSet environment variable:
export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/YOUR/WEBHOOK/URL"⚠️ Security Note: The webhook URL is a sensitive secret that grants permission to post messages to your Slack channel. Always:
Security Alert: Webhook URLs are sensitive credentials! Anyone with your webhook URL can send messages to your Slack channel. Always store them as environment variables and never commit them to version control.
Now that you have a working webhook, you’ll add a new MCP tool to your existing server.py from Module 2. This tool will handle sending notifications to Slack by making HTTP requests to the webhook URL.
Note: The starter code includes all improvements from Modules 1 & 2 (output limiting, webhook handling). Focus on the new Slack integration!
Add this tool to your server.py:
send_slack_notification:
import os
import requests
from mcp.types import TextContent
@mcp.tool()
def send_slack_notification(message: str) -> str:
"""Send a formatted notification to the team Slack channel."""
webhook_url = os.getenv("SLACK_WEBHOOK_URL")
if not webhook_url:
return "Error: SLACK_WEBHOOK_URL environment variable not set"
try:
# TODO: Send POST request to webhook_url
# TODO: Include message in JSON payload with "mrkdwn": true
# TODO: Handle response and return status
pass
except Exception as e:
return f"Error sending message: {str(e)}"Next, you’ll add MCP Prompts to your server - this is where the magic happens! These prompts will work with Claude to automatically format your GitHub webhook data into well-structured Slack messages. Remember from Module 1 that Prompts provide reusable instructions that Claude can use consistently.
Implement two prompts that generate Slack-formatted messages:
format_ci_failure_alert:
@mcp.prompt()
def format_ci_failure_alert() -> str:
"""Create a Slack alert for CI/CD failures."""
return """Format this GitHub Actions failure as a Slack message:
Use this template:
:rotating_light: *CI Failure Alert* :rotating_light:
A CI workflow has failed:
*Workflow*: workflow_name
*Branch*: branch_name
*Status*: Failed
*View Details*: <LOGS_LINK|View Logs>
Please check the logs and address any issues.
Use Slack markdown formatting and keep it concise for quick team scanning."""format_ci_success_summary:
@mcp.prompt()
def format_ci_success_summary() -> str:
"""Create a Slack message celebrating successful deployments."""
return """Format this successful GitHub Actions run as a Slack message:
Use this template:
:white_check_mark: *Deployment Successful* :white_check_mark:
Deployment completed successfully for [Repository Name]
*Changes:*
- Key feature or fix 1
- Key feature or fix 2
*Links:*
<PR_LINK|View Changes>
Keep it celebratory but informative. Use Slack markdown formatting."""Now comes the exciting part - testing your complete MCP workflow! You’ll have all three components working together: webhook capture from Module 2, prompt formatting from this module, and Slack notifications.
Start all services (just like in Module 2, but now with Slack integration):
# Terminal 1: Start webhook server
python webhook_server.py
# Terminal 2: Start MCP server
uv run server.py
# Terminal 3: Start Cloudflare Tunnel
cloudflared tunnel --url http://localhost:8080Test the complete integration with Claude Code:
You can test your implementation without setting up a real GitHub repository! See manual_test.md for curl commands that simulate GitHub webhook events.
Understanding the webhook event flow:
github_events.jsonQuick Test Workflow:
Manual Testing Alternative: For a complete testing experience without GitHub setup, follow the step-by-step curl commands in manual_test.md.
User: "Check recent CI events and notify the team about any failures"
Claude:
1. Uses get_recent_actions_events (from Module 2)
2. Finds a workflow failure
3. Uses format_ci_failure_alert prompt to create message
4. Uses send_slack_notification tool to deliver it
5. Reports back: "Sent failure alert to #dev-team channel"Failure Alert:
🚨 *CI Failure Alert* 🚨
A CI workflow has failed:
*Workflow*: CI (Run #42)
*Branch*: feature/slack-integration
*Status*: Failed
*View Details*: <https://github.com/user/mcp-course/actions/runs/123|View Logs>
Please check the logs and address any issues.Success Summary:
✅ *Deployment Successful* ✅
Deployment completed successfully for mcp-course
*Changes:*
- Added team notification system
- Integrated MCP Tools and Prompts
*Links:*
<https://github.com/user/mcp-course/pull/42|View Changes>*text* for bold (not **text**)"mrkdwn": true in webhook payload for proper formattingYou’ve now built a complete MCP workflow that demonstrates:
This shows the power of MCP for building practical development automation tools!
Key Learning: You’ve now built a complete MCP workflow that combines Tools (for external API calls) with Prompts (for consistent formatting). This pattern of Tools + Prompts is fundamental to advanced MCP development and can be applied to many other automation scenarios.
Congratulations! You’ve completed the final module of Unit 3 and built a complete end-to-end automation system. Your journey through all three modules has given you hands-on experience with:
You now have a solid foundation for building intelligent automation systems with MCP!
CodeCraft Studios has gone from chaotic development to a well-oiled machine. The automation system you built handles:
The team can now focus on building great products instead of fighting process problems. And you’ve learned advanced MCP patterns that you can apply to any automation challenge!