# Slack MCP

## Slack MCP

### What This Does

Enables Claude Code to list channels, read messages, post messages, and interact with Slack.

### Source

* **Docker Hub:** <https://hub.docker.com/r/mcp/slack>
* **Docker:** `mcp/slack`
* **Alternative:** <https://github.com/korotovsky/slack-mcp-server>

### Prerequisites

* Docker Desktop installed
* Access to Slack workspace (admin or ability to install apps)
* Slack Bot Token and Team ID

### Step 1: Create Local Config Folder

```bash
mkdir -p ~/.config/mcp/slack
```

### Step 2: Get Credentials

#### Create Slack App

1. Go to <https://api.slack.com/apps>
2. Click **Create New App**
3. Choose **From scratch**
4. Name: "MCP Bot"
5. Select your workspace
6. Click **Create App**

#### Configure Bot Permissions

1. Go to **OAuth & Permissions**
2. Under **Scopes → Bot Token Scopes**, add:

| Scope                | Purpose                       |
| -------------------- | ----------------------------- |
| `channels:history`   | Read public channel messages  |
| `channels:read`      | List public channels          |
| `chat:write`         | Post messages                 |
| `groups:history`     | Read private channel messages |
| `groups:read`        | List private channels         |
| `im:history`         | Read DM messages              |
| `im:read`            | List DMs                      |
| `im:write`           | Send DMs                      |
| `reactions:write`    | Add reactions                 |
| `users:read`         | List users                    |
| `users.profile:read` | Read user profiles            |

#### Install App to Workspace

1. Go to **OAuth & Permissions**
2. Click **Install to Workspace**
3. Click **Allow**
4. Copy the **Bot User OAuth Token** (starts with `xoxb-`)

#### Get Team ID

Option A - From browser:

1. Open Slack in browser
2. URL: `https://app.slack.com/client/TXXXXXXXX/...`
3. The `TXXXXXXXX` part is your Team ID

Option B - From desktop app:

1. Click workspace name → **Settings & administration** → **Workspace settings**
2. Team ID shown in URL

### Step 3: Save Credentials Locally

Create `~/.config/mcp/slack/.env`:

```bash
cat > ~/.config/mcp/slack/.env << 'EOF'
SLACK_BOT_TOKEN=xoxb-your-bot-token-here
SLACK_TEAM_ID=TXXXXXXXX
EOF
```

Replace with your actual values.

### Step 4: Pull Docker Image

```bash
docker pull mcp/slack
```

### Step 5: Test the Connection

```bash
source ~/.config/mcp/slack/.env && docker run --rm \
  -e SLACK_BOT_TOKEN="$SLACK_BOT_TOKEN" \
  -e SLACK_TEAM_ID="$SLACK_TEAM_ID" \
  mcp/slack --help
```

### Step 6: Add to Claude Code

Add to `~/.claude/settings.json`:

```json
{
  "mcpServers": {
    "slack": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "--env-file", "${HOME}/.config/mcp/slack/.env",
        "mcp/slack"
      ]
    }
  }
}
```

**Note:** If `${HOME}` doesn't expand, use absolute path:

```json
{
  "mcpServers": {
    "slack": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "--env-file", "/Users/yourname/.config/mcp/slack/.env",
        "mcp/slack"
      ]
    }
  }
}
```

### Step 7: Verify It Works

Restart Claude Code and test:

```
List all public Slack channels
```

Expected: List of channels in your workspace.

### Available Tools

| Tool                        | Description                        |
| --------------------------- | ---------------------------------- |
| `slack_list_channels`       | List public channels               |
| `slack_post_message`        | Post a new message to a channel    |
| `slack_reply_to_thread`     | Reply to a specific thread         |
| `slack_add_reaction`        | Add emoji reaction to a message    |
| `slack_get_channel_history` | Get recent messages from a channel |
| `slack_get_thread_replies`  | Get all replies in a thread        |
| `slack_get_users`           | List workspace users               |
| `slack_get_user_profile`    | Get specific user's profile        |

### Invite Bot to Channels

Before the bot can access a channel:

1. Go to the channel in Slack
2. Type `/invite @MCP Bot` (use your bot's name)
3. Or: Channel settings → Integrations → Add apps

### Limiting Channel Access (Optional)

For security, limit which channels the bot can access:

```bash
# Add to .env
SLACK_CHANNEL_IDS=C01234567,C89012345
```

Get channel IDs:

1. Right-click channel in Slack
2. Click **View channel details**
3. Scroll to bottom → Channel ID

### Troubleshooting

| Issue                      | Solution                                                |
| -------------------------- | ------------------------------------------------------- |
| "not\_authed"              | Check bot token is correct and starts with `xoxb-`      |
| "channel\_not\_found"      | Invite bot to the channel first                         |
| "missing\_scope"           | Add required scope in Slack app settings, reinstall app |
| "invalid\_auth"            | Token may be revoked, generate new one                  |
| Can't see private channels | Add `groups:read` scope, invite bot to channel          |
| Can't post messages        | Add `chat:write` scope                                  |
| env-file not found         | Use absolute path instead of `${HOME}`                  |
