A Model Context Protocol (MCP) server that provides seamless integration with Slack workspaces. This server enables AI assistants and automation tools to search messages, read threads, parse permalinks, reply to conversations, and retrieve complete channel content from Slack.
- Message Search: Search across your Slack workspace with flexible query options
- Thread Management: Retrieve complete thread conversations with all replies (accepts channel name, ID, URL, or permalink)
- Post Messages: Start new threads or reply to existing ones
- Channel Content: Get all messages and threads from any channel by name, ID, or URL
- Sidebar Sections: List your custom sidebar sections and their channels
- Python 3.13+
- uv package manager (recommended) or pip
- Slack workspace access with appropriate tokens
- MCP-compatible client (e.g., Claude Desktop, Cline, etc.)
uv is an extremely fast Python package installer and resolver, written in Rust. It's the modern way to manage Python projects and dependencies.
Why uv?
- β‘ 10-100x faster than pip for dependency resolution and installation
- π Reliable dependency locking with
uv.lockfor reproducible builds - π‘οΈ Automatic virtual environment management - no manual venv setup needed
- π― Drop-in replacement for pip, pip-tools, and virtualenv
- π¦ Better caching and parallel downloads
# Install uv (if you haven't already)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone the repository
git clone https://github.com/judexzhu/mcp-slack.git
cd mcp-slack
# Install dependencies (automatically creates and manages virtual environment)
uv sync
# Run the server
uv run python slack_mcp_server.pyIf you prefer traditional pip:
# Clone the repository
git clone https://github.com/judexzhu/mcp-slack.git
cd mcp-slack
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -e .You'll need two Slack tokens for authentication:
SLACK_XOXC_TOKEN: Session token for user authenticationSLACK_XOXD_TOKEN: Session token for request validation
- Open your Slack workspace in a web browser
- Open Developer Tools (F12)
- Go to the Network tab
- Make any request in Slack (send a message, change channel, etc.)
- Look for requests to
slack.com/api/endpoints - In the request headers, find:
Authorization: Bearer xoxc-...(this is your XOXC token)Cookie: d=xoxd-...(this is your XOXD token)
Create a .env file in the project root:
SLACK_XOXC_TOKEN=xoxc-your-token-here
SLACK_XOXD_TOKEN=xoxd-your-token-here
SLACK_WORKSPACE_URL=https://your-workspace.slack.comclaude mcp add --scope user --transport stdio slack \
-- uv run --directory /path/to/mcp-slack python slack_mcp_server.pySet the environment variables in your shell profile (.zshrc / .bashrc) or .env file in the project root. Verify with /mcp inside a Claude Code session.
Add to your client's MCP config JSON:
{
"mcpServers": {
"slack": {
"command": "uv",
"args": ["run", "python", "/path/to/mcp-slack/slack_mcp_server.py"],
"cwd": "/path/to/mcp-slack",
"env": {
"SLACK_XOXC_TOKEN": "xoxc-your-token-here",
"SLACK_XOXD_TOKEN": "xoxd-your-token-here",
"SLACK_WORKSPACE_URL": "https://your-workspace.slack.com"
}
}
}
}slack_search_messages: Search for messages across your Slack workspace with flexible query optionsslack_get_thread_messages: Retrieve complete thread conversations -- accepts a channel name/ID/URL + thread timestamp, or a full permalinkslack_reply_to_thread: Post replies to existing threads with broadcast support (standard markdown rendered natively via Block Kit)slack_post_message: Post a new message to any channel, starting a new threadslack_get_channel_content: Get all messages and thread replies from a channel by name, ID, or URLslack_list_sidebar_sections: List your custom sidebar sections and the channels in each one
This server is optimized to reduce token consumption while maintaining complete information integrity:
Key Optimizations:
- Removed redundant fields: Eliminated computed values like
message_count(usemessages.length),is_thread(checkthread_tspresence), and duplicatepreviewfield - Conditional inclusion: Only includes non-empty arrays and true boolean flags
- Shorter field names:
timestampβtsfor consistency with Slack API - No status wrappers: Returns
errorfield only when errors occur, notokfield on success - Minimal response structure: Only essential data, derivable information excluded
Expected Token Savings: 30-40% compared to standard implementations
{
"messages": [
{
"channel_id": "C08P3DY9MEU",
"channel_name": "general",
"text": "Full message text",
"ts": "1746036342.129679",
"thread_ts": "1746036342.129679", // Only if part of thread
"user": "U1234567890", // Only if present
"username": "john.doe", // Only if present
"permalink": "https://..." // Only if present
}
]
}{
"channel_id": "C08P3DY9MEU",
"thread_ts": "1746036342.129679",
"messages": [
{
"user": "U1234567890",
"text": "Message text",
"ts": "1746036342.129679",
"reactions": [...], // Only if present
"attachments": [...], // Only if present
"files": [...] // Only if present
}
],
"has_more": true // Only if true
}{
"error": "Error message",
"messages": [] // Partial data if available
}The slk CLI lets you interact with Slack from the command line.
# Local (in project)
uv sync
# Global
uv tool install . --force --reinstall# Search messages
slk search "error in:#general" --count 10
slk search "from:@username" -o table
# Read a thread (permalink or channel + timestamp)
slk thread "https://workspace.slack.com/archives/C01234567/p1746036342129679"
slk thread C01234567 --thread-ts 1746036342.129679
# Reply to a thread
slk reply C01234567 1746036342.129679 "Thanks for the update"
# Post a new message
slk post general "Hello team"
# Get channel content
slk channel general --limit 50
# List sidebar sections
slk sections --name Adobe -o tableAll commands support --output/-o json (default), --output/-o table, or --output/-o markdown.
Run slk --help for full details on all commands and options.
A Claude Code skill is included at skills/mcp-slack/SKILL.md to teach AI agents how to use the CLI effectively.
mcp-slack/
βββ mcp_slack/
β βββ __init__.py # Package version
β βββ client.py # SlackClient class (auth + HTTP)
β βββ tools.py # Business logic (async functions)
β βββ server.py # FastMCP tool wrappers + main()
β βββ cli.py # Click-based CLI
βββ slack_mcp_server.py # Backward-compat MCP entry point
βββ test_slack_tools.py # Test suite
βββ skills/mcp-slack/
β βββ SKILL.md # Claude Code skill docs
βββ pyproject.toml # Project configuration
βββ uv.lock # Lock file for dependencies
βββ README.md # This file
client.py:SlackClientclass β authentication, HTTP requests viahttpx.AsyncClienttools.py: All business logic as async functions, lazy client viaget_client()singletonserver.py:@mcp.tool()thin wrappers delegating totools.py, MCP server entry pointcli.py: Click CLI with matching commands for each toolslack_mcp_server.py: Re-exportsmcpfor backward-compatible MCP discovery
- Keep your Slack tokens secure and never commit them to version control
- Use environment variables or secure secret management
- Tokens provide full access to your Slack workspace - handle with care
- Consider using restricted tokens if available for your use case