Slack MCP Server

Slack MCP Server

Enables comprehensive Slack workspace integration through AI assistants, allowing users to manage channels, send messages, upload files, search conversations, and interact with users through natural language commands.

Category
访问服务器

README

Slack MCP Server

A TypeScript-based Model Context Protocol (MCP) server that provides comprehensive Slack workspace integration. This server enables AI assistants to interact with Slack channels, users, messages, files, and more through the MCP protocol.

Table of Contents

Features

Channel Management

  • list_channels - List workspace channels with filtering options
  • get_channel_info - Get detailed information about a specific channel
  • create_channel - Create new public or private channels
  • archive_channel - Archive channels

User Management

  • list_users - List all users in the workspace
  • get_user_info - Get detailed user profile information
  • invite_to_channel - Invite users to channels

Messaging

  • send_message - Send text messages to channels
  • update_message - Update existing messages
  • delete_message - Delete messages
  • get_channel_history - Fetch message history with pagination
  • search_messages - Search messages across the workspace
  • send_formatted_message - Send messages with Block Kit formatting

File Operations

  • upload_file - Upload files to channels

Reactions

  • add_reaction - Add emoji reactions to messages
  • remove_reaction - Remove emoji reactions

Workspace Information

  • get_team_info - Get workspace/team information

Prerequisites

Before you begin, ensure you have:

  • Node.js 18 or higher - Verify with: node --version
  • npm - Verify with: npm --version
  • Slack workspace admin access - You need permission to create and install apps
  • Estimated setup time: ~20 minutes

Installation & Setup

Step 1: Project Setup (5 minutes)

Clone the repository and install dependencies:

# Clone the repository
git clone <your-repo-url>
cd slack-bot-mcp

# Install dependencies
npm install

✓ Verification: Run npm list @modelcontextprotocol/sdk to confirm the MCP SDK is installed.


Step 2: Create Slack App (10 minutes)

2.1 Create the App

  1. Go to https://api.slack.com/apps
  2. Click "Create New App""From scratch"
  3. Enter an app name (e.g., "MCP Bot") and select your workspace
  4. Click "Create App"

2.2 Configure OAuth Scopes

Navigate to "OAuth & Permissions" in the sidebar, scroll to "Scopes", and add these Bot Token Scopes:

Scope Purpose Used By
channels:read View basic channel information list_channels, get_channel_info
channels:write Create channels create_channel
channels:manage Archive channels, invite users archive_channel, invite_to_channel
users:read View user profiles list_users, get_user_info
chat:write Send and update messages send_message, update_message, delete_message
files:write Upload files to Slack upload_file
reactions:write Add/remove emoji reactions add_reaction, remove_reaction
team:read Get workspace information get_team_info
search:read Search messages search_messages

💡 Tip: Each scope is necessary for specific tools to function. Missing scopes will cause "missing_scope" errors.

2.3 Install to Workspace

  1. Scroll to "OAuth Tokens for Your Workspace"
  2. Click "Install to Workspace"
  3. Review permissions and click "Allow"

2.4 Copy Your Bot Token

  1. After installation, you'll see the "Bot User OAuth Token"
  2. Click "Copy" (token starts with xoxb-)
  3. Keep this token secure - you'll need it in the next step

✓ Verification: Your token should look like: xoxb-<numbers>-<numbers>-<random-string>


Step 3: Configure Environment (2 minutes)

Create your environment configuration:

# Copy the example file
cp .env.example .env

Edit .env and add your bot token:

SLACK_BOT_TOKEN=xoxb-your-actual-token-here

✓ Verification: Run this command to confirm your token is loaded:

node -e "require('dotenv').config(); console.log('Token loaded:', !!process.env.SLACK_BOT_TOKEN)"

You should see: Token loaded: true

⚠️ Common Issue: Make sure your token starts with xoxb- (not xoxp- or xoxa-)


Step 4: Build & Verify (3 minutes)

Build the TypeScript project:

npm run build

✓ Verification: Confirm the build/ directory was created:

ls build/index.js

You should see the compiled index.js file.


Testing Your Setup

Before integrating with Claude Desktop, test that everything works:

Using MCP Inspector

The MCP Inspector provides a GUI to test your tools:

npx @modelcontextprotocol/inspector node build/index.js

This will open a web interface where you can:

  • See all available tools
  • Test individual tools with sample inputs
  • View responses and debug errors

Quick Test Commands

Try these simple tests in the MCP Inspector:

  1. List channels:

    • Tool: list_channels
    • Arguments: {"limit": 5}
    • Expected: List of your workspace channels
  2. Get team info:

    • Tool: get_team_info
    • Arguments: {}
    • Expected: Your workspace name and details
  3. List users:

    • Tool: list_users
    • Arguments: {"limit": 5}
    • Expected: List of workspace users

✓ Success Indicator: If these commands return data (not errors), your setup is working correctly!

⚠️ Troubleshooting: If you see "invalid_auth" or "token_revoked", double-check your SLACK_BOT_TOKEN in the .env file.


Usage

With Claude Desktop

Add to your Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%/Claude/claude_desktop_config.json

Option 1: Direct from GitHub (Recommended)

Use npx to run directly from the GitHub repository:

{
  "mcpServers": {
    "slack": {
      "command": "npx",
      "args": [
        "github:Hais/slack-bot-mcp"
      ],
      "env": {
        "SLACK_BOT_TOKEN": "xoxb-your-token-here"
      }
    }
  }
}

Benefits:

  • ✓ No local installation needed
  • ✓ Always uses the latest version
  • ✓ Simpler configuration
  • ✓ Works on any machine with Node.js

Option 2: Local Installation

For local development or offline use:

{
  "mcpServers": {
    "slack": {
      "command": "node",
      "args": ["/absolute/path/to/slack-bot-mcp/build/index.js"],
      "env": {
        "SLACK_BOT_TOKEN": "xoxb-your-token-here"
      }
    }
  }
}

Setup for local installation:

  1. Clone and build the project (see Installation & Setup)
  2. Replace /absolute/path/to/slack-bot-mcp with your full project path
    • Find it by running pwd in your project directory
    • Example: /Users/yourname/projects/slack-bot-mcp/build/index.js

Important notes:

  1. Token configuration: Set SLACK_BOT_TOKEN in the config file as shown above

    • The config file token takes precedence over .env files
    • Keep your token secure and never commit it to version control
  2. Restart required: Restart Claude Desktop after editing the config file

  3. First run: The first time using npx, it will download and cache the package (may take a few seconds)

✓ Verification: Open Claude Desktop and type: "List my Slack channels". If configured correctly, Claude will use the list_channels tool.

With Other MCP Clients

The server runs on stdio transport and can be integrated with any MCP client:

node build/index.js

Development Mode

For development with hot reload:

npm run dev

Tool Examples

List Channels

{
  "name": "list_channels",
  "arguments": {
    "types": "public_channel,private_channel",
    "exclude_archived": true,
    "limit": 50
  }
}

Send Message

{
  "name": "send_message",
  "arguments": {
    "channel": "C1234567890",
    "text": "Hello from MCP!"
  }
}

Send Formatted Message with Block Kit

{
  "name": "send_formatted_message",
  "arguments": {
    "channel": "C1234567890",
    "text": "Fallback text",
    "blocks": [
      {
        "type": "section",
        "text": {
          "type": "mrkdwn",
          "text": "*Hello* from MCP with _formatting_!"
        }
      }
    ]
  }
}

Search Messages

{
  "name": "search_messages",
  "arguments": {
    "query": "important announcement",
    "count": 10,
    "sort": "timestamp"
  }
}

Upload File

{
  "name": "upload_file",
  "arguments": {
    "channels": ["C1234567890"],
    "content": "File content here",
    "filename": "report.txt",
    "title": "Monthly Report"
  }
}

Add Reaction

{
  "name": "add_reaction",
  "arguments": {
    "channel": "C1234567890",
    "timestamp": "1234567890.123456",
    "name": "thumbsup"
  }
}

Required OAuth Scopes

Make sure your Slack app has these scopes:

Scope Purpose
channels:read List and get channel information
channels:write Create channels
channels:manage Archive channels
users:read List and get user information
chat:write Send, update, and delete messages
files:write Upload files
reactions:write Add and remove reactions
team:read Get workspace information
search:read Search messages

Project Structure

slack-bot-mcp/
├── src/
│   ├── index.ts              # MCP server entry point
│   ├── tools/
│   │   ├── channels.ts       # Channel management tools
│   │   ├── users.ts          # User management tools
│   │   ├── messages.ts       # Messaging tools
│   │   ├── files.ts          # File upload tool
│   │   ├── reactions.ts      # Reaction tools
│   │   └── workspace.ts      # Workspace info tool
│   ├── config/
│   │   └── credentials.ts    # Environment config loader
│   ├── types/
│   │   └── slack.ts          # TypeScript interfaces
│   └── utils/
│       ├── slack-client.ts   # Slack API wrapper
│       └── validators.ts     # Zod input validators
├── build/                    # Compiled JavaScript
├── .env                      # Your environment variables
├── .env.example             # Environment template
├── package.json
├── tsconfig.json
└── README.md

Troubleshooting

Setup Issues

"SLACK_BOT_TOKEN environment variable is required"

Cause: The server can't find your bot token.

Solutions:

  1. Verify .env file exists in project root: ls -la .env
  2. Check token format: cat .env (should show SLACK_BOT_TOKEN=xoxb-...)
  3. If using Claude Desktop config, ensure the token is in the env section
  4. Restart your MCP client after making changes

"Missing required OAuth scope"

Cause: Your bot token doesn't have necessary permissions.

Solution:

  1. Go to https://api.slack.com/apps → Your App → "OAuth & Permissions"
  2. Add the missing scope (error message will specify which one)
  3. Click "Reinstall to Workspace" (this is required after adding scopes)
  4. Copy the new bot token and update your configuration

💡 Note: You must reinstall the app after changing scopes. The old token won't gain new permissions automatically.

Runtime Issues

"Channel not found" or "User not found"

Cause: You're using channel/user names instead of IDs.

Solution:

  • Channel IDs start with C (public), G (private), or D (DM)
  • User IDs start with U
  • Use list_channels or list_users tools to find the correct IDs

Example:

// ❌ Wrong
{"channel": "general"}

// ✓ Correct
{"channel": "C1234567890"}

"invalid_auth" or "token_revoked"

Cause: Bot token is incorrect or expired.

Solution:

  1. Go to https://api.slack.com/apps → Your App → "OAuth & Permissions"
  2. Copy the current "Bot User OAuth Token"
  3. Update your .env file or Claude Desktop config
  4. Restart the MCP server

Rate Limiting

Cause: Slack API has rate limits (Tier 3: 50+ requests per minute).

Solution:

  • Add delays between rapid requests
  • Use pagination parameters (limit, cursor) for large data sets
  • Monitor rate limit headers in error messages

MCP Inspector Won't Start

Cause: Port already in use or Node.js issues.

Solution:

# Kill any existing inspector processes
pkill -f "mcp.*inspector"

# Try again
npx @modelcontextprotocol/inspector node build/index.js

Getting Help

If you're still stuck:

  1. Check the build output: Run npm run build and look for TypeScript errors
  2. Verify Node version: Run node --version (need 18+)
  3. Test token manually: Use Slack's API tester at https://api.slack.com/methods/auth.test/test
  4. Enable debug logging: Set DEBUG=* environment variable

Still having issues? Open an issue at the GitHub repository with:

  • Error message (full text)
  • Your Node.js version
  • Steps to reproduce

Development

Building

npm run build

Running in Development

npm run dev

Testing with MCP Inspector

npx @modelcontextprotocol/inspector node build/index.js

License

ISC

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Acknowledgments

Ported from the Python implementation: https://github.com/piekstra/slack-mcp-server

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选