Course/Scale/Lesson 5

Lesson 3.5: Connect to Business Systems

Duration: 35 min

Learning Objectives

  • Connect Claude to Slack via MCP for automated notifications
  • Store credentials securely using environment variables
  • Build an end-to-end automated workflow that runs without intervention
🎯 What You'll Learn: How to give Claude access to business tools, starting with Slack, so your automation chain can complete itself
⏱️ Time Required: 35 minutes

The Notification Gap

Riley's filesystem MCP is working. Claude reads her data files directly. But Marcus Webb doesn't check file folders, he checks Slack.

"The report generates automatically at 8am on Monday via cron. But then I still have to open it, copy the summary, and paste it to #risk-operations. What if Claude could just post it there?"
β€” Riley Harper

The answer: Slack MCP.


How Multi-Server MCP Works

You can configure multiple MCP servers simultaneously. Each adds a new capability:

ServerWhat Claude gains
filesystemRead/write local files
slackPost messages, read channels
postgresQuery databases
githubCreate issues, read repos

Claude can use all configured servers in a single session. Riley's complete automation calls the filesystem server to read the report, then calls the Slack server to post the summary.


Exercise: Connect Slack MCP (35 min)

Step 1: Create a Slack Bot (10 min)

You need a Slack bot with posting permissions.

In Slack:

  • Go to api.slack.com/apps
  • Create New App β†’ From scratch
  • Name it (e.g., "Claude Code Bot")
  • Select your workspace
  • Go to OAuth & Permissions β†’ Bot Token Scopes
  • Add these scopes:
  • chat:write, post messages
  • channels:read, verify channel exists
  • Click Install to Workspace
  • Copy the Bot User OAuth Token (starts with xoxb-)
  • In the target Slack channel, type /invite @Claude Code Bot
  • Find your Team ID:

    Open Slack in a browser. The URL will show something like app.slack.com/client/T01234567/..., the T01234567 part is your Team ID.

    Step 2: Store Credentials Securely (5 min)

    Never put your Slack token in a settings file. Use environment variables.

    Mac / Linux, add to ~/.bashrc or ~/.zshrc:

    export SLACK_BOT_TOKEN="xoxb-your-token-here"
    export SLACK_TEAM_ID="T01234567"
    

    Windows, PowerShell:

    [System.Environment]::SetEnvironmentVariable("SLACK_BOT_TOKEN", "xoxb-your-token-here", "User")
    [System.Environment]::SetEnvironmentVariable("SLACK_TEAM_ID", "T01234567", "User")
    

    After setting them, restart your terminal (or Claude Code).

    Step 3: Configure Slack MCP (10 min)

    Update your .mcp.json to add the Slack server alongside your filesystem server:

    {
      "mcpServers": {
        "filesystem": {
          "command": "npx",
          "args": [
            "-y",
            "@modelcontextprotocol/server-filesystem",
            "/Users/riley/margin-automation/data",
            "/Users/riley/margin-automation/outputs"
          ]
        },
        "slack": {
          "command": "npx",
          "args": [
            "-y",
            "@modelcontextprotocol/server-slack"
          ],
          "env": {
            "SLACK_BOT_TOKEN": "${SLACK_BOT_TOKEN}",
            "SLACK_TEAM_ID": "${SLACK_TEAM_ID}"
          }
        }
      }
    }
    

    The ${SLACK_BOT_TOKEN} syntax references the environment variable, the token never appears in the file.

    ⚠️ Package note: The Slack MCP server is now community/vendor-maintained rather than part of Anthropic's core reference servers. These steps show the pattern, which is what matters. Before you rely on it, confirm the current Slack MCP server (ask Claude "what's the current Slack MCP server and how do I add it?" or check the MCP registry) and use that package name in place of @modelcontextprotocol/server-slack. The filesystem server you set up in 3.4 is in the actively maintained core set.

    Restart Claude Code to load the new configuration.

    Step 4: Test and Integrate (10 min)

    Check both servers are connected:

    /mcp
    

    Both filesystem and slack should show as active.

    Test a post:

    Ask Claude: "Post a test message to #[your-channel] that says 'Claude Code test, please ignore'"

    If it works, you'll see the message appear in Slack from your bot. If it fails, check /mcp for the server status and error details.

    Connect it to your existing automation:

    Riley's Stop hook already runs a script when a pipeline session ends. Now she can extend that script to trigger a Slack notification.

    πŸ’‘ You don't need to write this script yourself. Tell Claude: "Write me a bash script that checks for the latest .md file in ~/margin-automation/outputs and triggers a new Claude Code session to post a 3-bullet summary to #risk-operations. Save it as on-pipeline-complete.sh." Claude will generate the exact script for your setup, and explain each line if you ask.

    Riley's completed script (generated by Claude, then saved):

    #!/bin/bash
    # on-pipeline-complete.sh
    REPORT_DIR=~/margin-automation/outputs
    LATEST=$(ls -t "$REPORT_DIR"/*.md 2>/dev/null | head -1)
    
    if [ -z "$LATEST" ]; then
      exit 0
    fi
    
    # Run a separate Claude session to post the Slack summary
    /usr/local/bin/claude \
      --print "Read $LATEST and post a 3-bullet summary to #risk-operations. Keep it under 200 words." \
      --allowedTools "Read" \
      >> ~/logs/slack-notification.log 2>&1
    

    This approach keeps the MCP server active only when needed, the main cron job generates the report, and the Stop hook triggers a second brief session that reads the result and posts to Slack.


    Riley's Complete Automated Flow

    Sunday night:
      Riley exports from Prime Broker portal β†’ drops CSV in ~/margin-automation/data
    
    Monday 8:00 AM (cron triggers):
      cd ~/margin-automation && claude --print "Run /weekly-margin-report"
        β†’ Reads CSV via filesystem MCP
        β†’ Generates report, saves to ~/margin-automation/outputs/
    
      Stop hook fires:
        on-pipeline-complete.sh runs
          β†’ New Claude session reads the report
          β†’ Posts summary to #risk-operations via Slack MCP
    
    Monday 8:05 AM:
      Marcus Webb (Head of Risk Operations) sees report in Slack
      Riley reviews full report over coffee
      No manual work done
    

    Security Checklist for MCP

    Before considering an MCP connection production-ready:

    CheckWhy
    Token in environment variable, not in .mcp.jsonConfig files get checked into version control; env vars stay local
    Filesystem scoped to specific foldersNot ~ or /, only what the toolkit needs
    API scopes minimal (chat:write not admin)Over-permissioned = larger blast radius
    Token documented in SECURITY.mdWhoever takes over knows what exists
    .gitignore includes .envPrevents accidental token commit

    βœ… Success Criteria:

    Slack bot created with chat:write and channels:read scopes only
    Bot token stored in environment variable, not in any file
    /mcp shows both filesystem and slack as connected
    Test message posts successfully to target channel
    Full workflow tested end-to-end: cron triggers β†’ report generates β†’ Slack receives summary

    Module 3 Complete

    "Week 3 was the transformation. I went from 'Claude helps when I ask' to 'Claude runs my Monday automatically.' Scheduled automation, event-driven hooks, filesystem MCP, Slack integration, my workflow runs itself. The first Monday it worked, I was on a 7:45am call. At 8:03 I got a Slack message: the report was already there. I hadn't touched my computer."
    β€” Riley Harper
    LessonWhat you built
    3.1Audit log hook, PostToolUse on Write
    3.2Scheduled automation, cron + Claude CLI
    3.3Event-driven chains, Stop hook automation
    3.4Filesystem MCP, Claude reads files directly
    3.5Slack MCP, Claude completes the notification chain

    Next Up

    Module 4: Sharing Your Automation

    You've built a complete automated system. Now you'll package it into a toolkit your team can install in ten minutes, so the work you put in benefits everyone.

    AI Automation Academy is an independent course created by Mercedes Perez-Capilla. It is not affiliated with, endorsed by, or produced by Anthropic. Claudeβ„’ is a trademark of Anthropic. All tool references are for educational purposes.