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:
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:
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.
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
# 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:
❌ *CI Failed* - [Repository Name]
> Brief summary of what failed
*Details:*
• Workflow: `workflow_name`
• Branch: `branch_name`
• Commit: `commit_hash`
*Next Steps:*
• <PR_LINK|View Pull Request>
• <LOGS_LINK|Check Action Logs>
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:
✅ *Deployment Successful* - [Repository Name]
> Brief summary of what was deployed
*Changes:*
• Key feature or fix 1
• Key feature or fix 2
*Links:*
• <PR_LINK|View Changes>
• <DEPLOY_LINK|Visit Site>
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 Failed* - mcp-course
> Tests failed in Module 3 implementation
*Details:*
• Workflow: `CI`
• Branch: `feature/slack-integration`
• Commit: `abc123f`
*Next Steps:*
• <https://github.com/user/mcp-course/pull/42|View Pull Request>
• <https://github.com/user/mcp-course/actions/runs/123|Check Action Logs>Success Summary:
✅ *Deployment Successful* - mcp-course
> Module 3 Slack integration deployed to staging
*Changes:*
• Added team notification system
• Integrated MCP Tools and Prompts
*Links:*
• <https://github.com/user/mcp-course/pull/42|View Changes>
• <https://staging.example.com|Visit Site>You’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!