usage-examples.mdā¢2.89 kB
# Slack MCP Usage Examples
This document provides examples of how to use the Slack MCP server tools.
## Setup
1. Set your environment variables:
```bash
export SLACK_TOKEN="xoxb-your-bot-token-here"
export SLACK_TEAM_ID="T1234567890"
```
2. Run the MCP server:
```bash
npm run build
npm start
```
## Tool Usage Examples
### 1. List Channels
**Basic usage:**
```json
{
"tool": "slack_list_channels",
"arguments": {
"limit": 20
}
}
```
**With pagination:**
```json
{
"tool": "slack_list_channels",
"arguments": {
"limit": 50,
"cursor": "dXNlcjpVMDYxTkZUVDI="
}
}
```
### 2. Post Message
```json
{
"tool": "slack_post_message",
"arguments": {
"channel_id": "C1234567890",
"text": "Hello from MCP! š"
}
}
```
### 3. Reply to Thread
```json
{
"tool": "slack_reply_to_thread",
"arguments": {
"channel_id": "C1234567890",
"thread_ts": "1234567890.123456",
"text": "This is a thread reply!"
}
}
```
### 4. Add Reaction
```json
{
"tool": "slack_add_reaction",
"arguments": {
"channel_id": "C1234567890",
"timestamp": "1234567890.123456",
"reaction": "thumbsup"
}
}
```
### 5. Get Channel History
```json
{
"tool": "slack_get_channel_history",
"arguments": {
"channel_id": "C1234567890",
"limit": 10
}
}
```
### 6. Get Thread Replies
```json
{
"tool": "slack_get_thread_replies",
"arguments": {
"channel_id": "C1234567890",
"thread_ts": "1234567890.123456"
}
}
```
### 7. Get Users
```json
{
"tool": "slack_get_users",
"arguments": {
"limit": 25
}
}
```
### 8. Get User Profile
```json
{
"tool": "slack_get_user_profile",
"arguments": {
"user_id": "U1234567890"
}
}
```
## Common Use Cases
### 1. Send a welcome message to a channel
```json
{
"tool": "slack_post_message",
"arguments": {
"channel_id": "C1234567890",
"text": "š Welcome to our team! Feel free to introduce yourself and ask any questions."
}
}
```
### 2. React to a message with multiple emojis
First get the message timestamp from channel history, then add reactions:
```json
{
"tool": "slack_add_reaction",
"arguments": {
"channel_id": "C1234567890",
"timestamp": "1234567890.123456",
"reaction": "eyes"
}
}
```
### 3. Follow up on a thread
```json
{
"tool": "slack_reply_to_thread",
"arguments": {
"channel_id": "C1234567890",
"thread_ts": "1234567890.123456",
"text": "Thanks for the update! This looks great š"
}
}
```
## Tips
1. **Channel IDs**: You can get channel IDs by listing channels first
2. **Timestamps**: Message timestamps are in the format `1234567890.123456`
3. **Reactions**: Use emoji names without colons (e.g., `thumbsup` not `:thumbsup:`)
4. **Pagination**: Use the `next_cursor` from responses for pagination
5. **Caching**: The server caches responses for 30 minutes to improve performance