@jtalk22/slack-mcp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/SETUP.md ADDED
@@ -0,0 +1,134 @@
1
+ # Setup Guide
2
+
3
+ ## Prerequisites
4
+
5
+ - Node.js 18+
6
+ - Google Chrome (for token extraction)
7
+ - macOS (for Keychain storage - other platforms use file storage only)
8
+
9
+ ## Installation
10
+
11
+ ### 1. Clone or Copy the Project
12
+
13
+ ```bash
14
+ cd ~
15
+ git clone https://github.com/yourusername/slack-mcp-server.git
16
+ # or if already exists:
17
+ cd ~/slack-mcp-server
18
+ ```
19
+
20
+ ### 2. Install Dependencies
21
+
22
+ ```bash
23
+ npm install
24
+ ```
25
+
26
+ ### 3. Get Slack Tokens
27
+
28
+ **Option A: Automatic Extraction**
29
+
30
+ 1. Open Chrome
31
+ 2. Navigate to https://app.slack.com and log in
32
+ 3. Run:
33
+ ```bash
34
+ npm run tokens:auto
35
+ ```
36
+
37
+ **Option B: Manual Extraction**
38
+
39
+ 1. Open https://app.slack.com in Chrome
40
+ 2. Press F12 to open DevTools
41
+ 3. Go to **Application** → **Cookies** → **https://app.slack.com**
42
+ 4. Find the cookie named `d` and copy its value (starts with `xoxd-`)
43
+ 5. Go to **Console** and paste:
44
+ ```javascript
45
+ JSON.parse(localStorage.localConfig_v2).teams[Object.keys(JSON.parse(localStorage.localConfig_v2).teams)[0]].token
46
+ ```
47
+ 6. Copy the result (starts with `xoxc-`)
48
+ 7. Run:
49
+ ```bash
50
+ npm run tokens:refresh
51
+ ```
52
+ And paste both values when prompted.
53
+
54
+ ### 4. Configure Claude Desktop (GUI App)
55
+
56
+ Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:
57
+
58
+ ```json
59
+ {
60
+ "mcpServers": {
61
+ "slack": {
62
+ "command": "/opt/homebrew/bin/node",
63
+ "args": ["/Users/YOUR_USERNAME/slack-mcp-server/src/server.js"],
64
+ "env": {
65
+ "SLACK_TOKEN": "xoxc-your-token-here",
66
+ "SLACK_COOKIE": "xoxd-your-cookie-here",
67
+ "PATH": "/opt/homebrew/bin:/usr/bin:/bin"
68
+ }
69
+ }
70
+ }
71
+ }
72
+ ```
73
+
74
+ **Important:**
75
+ - Replace `YOUR_USERNAME` with your actual username
76
+ - Copy tokens from `~/.slack-mcp-tokens.json` into the env section
77
+ - Fully restart Claude Desktop (Cmd+Q, then reopen)
78
+
79
+ **Verify it's working:** Check `~/Library/Logs/Claude/mcp-server-slack.log`
80
+
81
+ ### 5. Configure Claude Code (CLI)
82
+
83
+ Edit `~/.claude.json` and add under `mcpServers`:
84
+
85
+ ```json
86
+ {
87
+ "mcpServers": {
88
+ "slack": {
89
+ "type": "stdio",
90
+ "command": "node",
91
+ "args": ["/Users/YOUR_USERNAME/slack-mcp-server/src/server.js"],
92
+ "env": {}
93
+ }
94
+ }
95
+ }
96
+ ```
97
+
98
+ Claude Code reads tokens from `~/.slack-mcp-tokens.json` automatically.
99
+
100
+ ### 6. Restart Claude
101
+
102
+ The Slack tools will now be available in both Claude Desktop and Claude Code.
103
+
104
+ ## Verification
105
+
106
+ In Claude Code, try:
107
+ ```
108
+ slack_health_check
109
+ ```
110
+
111
+ You should see your username and team name.
112
+
113
+ ## Troubleshooting
114
+
115
+ ### "No credentials found"
116
+
117
+ Run `npm run tokens:auto` with Slack open in Chrome, or `npm run tokens:refresh` to enter manually.
118
+
119
+ ### "invalid_auth" Error
120
+
121
+ Tokens have expired. Open Slack in Chrome and use `slack_refresh_tokens` in Claude Code.
122
+
123
+ ### MCP Server Not Loading
124
+
125
+ 1. Check `~/.claude.json` syntax
126
+ 2. Verify the path to server.js is correct
127
+ 3. Restart Claude Code
128
+
129
+ ### Chrome Extraction Fails
130
+
131
+ Make sure:
132
+ - Chrome is running (not just in dock)
133
+ - You have a Slack tab open (not the desktop app)
134
+ - You're logged into Slack in that tab
@@ -0,0 +1,216 @@
1
+ # Troubleshooting Guide
2
+
3
+ Common issues and their solutions.
4
+
5
+ ---
6
+
7
+ ## DMs Not Showing Up
8
+
9
+ **Symptom:** `slack_list_conversations` returns channels but no DMs.
10
+
11
+ **Cause:** Slack's `conversations.list` API doesn't return IMs when using xoxc browser tokens.
12
+
13
+ **Solution:** This is handled automatically. The server discovers DMs by calling `conversations.open` for each user in your workspace. This happens in `lib/handlers.js`.
14
+
15
+ If DMs still don't appear:
16
+ 1. Check you're requesting the right types: `slack_list_conversations types=im,mpim`
17
+ 2. Verify the user exists: `slack_list_users`
18
+
19
+ ---
20
+
21
+ ## Rate Limiting Errors
22
+
23
+ **Symptom:** `{"error":"ratelimited"}` in API responses.
24
+
25
+ **Cause:** Slack limits API calls, especially when listing many users/DMs.
26
+
27
+ **Solution:** The client (`lib/slack-client.js`) implements automatic retry with exponential backoff:
28
+ - First retry: Wait 5 seconds
29
+ - Second retry: Wait 10 seconds
30
+ - Third retry: Wait 15 seconds
31
+
32
+ If you still hit limits, reduce batch sizes:
33
+ ```
34
+ slack_list_conversations limit=50
35
+ ```
36
+
37
+ ---
38
+
39
+ ## Token Expiration
40
+
41
+ **Symptom:** `invalid_auth` or `token_expired` errors.
42
+
43
+ **Cause:** Browser tokens (xoxc/xoxd) expire after 1-2 weeks.
44
+
45
+ **Solution:** The server has 4 layers of token recovery:
46
+
47
+ 1. **Environment variables** - From MCP config (Claude Desktop)
48
+ 2. **Token file** - `~/.slack-mcp-tokens.json`
49
+ 3. **macOS Keychain** - Encrypted persistent storage
50
+ 4. **Chrome auto-extraction** - Fallback when all else fails
51
+
52
+ **To refresh tokens:**
53
+ ```bash
54
+ # Option 1: In Claude Code/Desktop
55
+ slack_refresh_tokens
56
+
57
+ # Option 2: CLI
58
+ npm run tokens:auto
59
+
60
+ # Option 3: Manual
61
+ npm run tokens:refresh
62
+ ```
63
+
64
+ ---
65
+
66
+ ## Web Server Issues
67
+
68
+ ### Server Stops When Terminal Closes
69
+
70
+ **Solution:** Use LaunchAgent for persistence:
71
+
72
+ ```bash
73
+ # Create LaunchAgent
74
+ cat > ~/Library/LaunchAgents/com.slack-web-api.plist << 'EOF'
75
+ <?xml version="1.0" encoding="UTF-8"?>
76
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
77
+ <plist version="1.0">
78
+ <dict>
79
+ <key>Label</key>
80
+ <string>com.slack-web-api</string>
81
+ <key>ProgramArguments</key>
82
+ <array>
83
+ <string>/opt/homebrew/bin/node</string>
84
+ <string>/Users/YOUR_USERNAME/slack-mcp-server/src/web-server.js</string>
85
+ </array>
86
+ <key>WorkingDirectory</key>
87
+ <string>/Users/YOUR_USERNAME/slack-mcp-server</string>
88
+ <key>RunAtLoad</key>
89
+ <true/>
90
+ <key>KeepAlive</key>
91
+ <true/>
92
+ </dict>
93
+ </plist>
94
+ EOF
95
+
96
+ launchctl load ~/Library/LaunchAgents/com.slack-web-api.plist
97
+ ```
98
+
99
+ ### API Key Invalid
100
+
101
+ **Default API Key:** `slack-mcp-local`
102
+
103
+ If you set a custom key, make sure it matches:
104
+ ```bash
105
+ SLACK_API_KEY=your-custom-key npm run web
106
+ ```
107
+
108
+ ### Can't Connect to localhost:3000
109
+
110
+ Check if the server is running:
111
+ ```bash
112
+ curl http://localhost:3000/health -H "Authorization: Bearer slack-mcp-local"
113
+ ```
114
+
115
+ Check LaunchAgent status:
116
+ ```bash
117
+ launchctl list | grep slack-web-api
118
+ ```
119
+
120
+ Check logs:
121
+ ```bash
122
+ cat /tmp/slack-web-api.log
123
+ cat /tmp/slack-web-api.error.log
124
+ ```
125
+
126
+ ---
127
+
128
+ ## Claude Desktop Issues
129
+
130
+ ### Slack Tools Not Appearing
131
+
132
+ **Symptom:** Claude Desktop doesn't show Slack tools after adding config.
133
+
134
+ **Solutions:**
135
+
136
+ 1. **Fully restart Claude Desktop:**
137
+ - Cmd+Q (don't just close window)
138
+ - Reopen the app
139
+
140
+ 2. **Check config syntax:**
141
+ ```bash
142
+ cat ~/Library/Application\ Support/Claude/claude_desktop_config.json | python -m json.tool
143
+ ```
144
+
145
+ 3. **Check MCP logs:**
146
+ ```bash
147
+ cat ~/Library/Logs/Claude/mcp-server-slack.log
148
+ ```
149
+
150
+ 4. **Verify node path:**
151
+ ```bash
152
+ which node
153
+ # Use this full path in config
154
+ ```
155
+
156
+ ### MCP Server Crashes on Start
157
+
158
+ **Check the log:**
159
+ ```bash
160
+ tail -50 ~/Library/Logs/Claude/mcp-server-slack.log
161
+ ```
162
+
163
+ **Common causes:**
164
+ - Node.js not found (use full path like `/opt/homebrew/bin/node`)
165
+ - Missing tokens in env section
166
+ - Invalid JSON syntax in config
167
+
168
+ ---
169
+
170
+ ## Chrome Extraction Fails
171
+
172
+ **Symptom:** `slack_refresh_tokens` returns "Could not extract from Chrome"
173
+
174
+ **Requirements:**
175
+ 1. Google Chrome must be running (not just in Dock)
176
+ 2. Have a Slack tab open at `app.slack.com` (not desktop app)
177
+ 3. Be logged into Slack in that tab
178
+ 4. Grant accessibility permissions to Terminal/Claude
179
+
180
+ **Check permissions:**
181
+ System Preferences → Privacy & Security → Accessibility → Ensure Terminal is enabled
182
+
183
+ ---
184
+
185
+ ## Why Browser Tokens Instead of Slack App?
186
+
187
+ **Question:** Why not just create a Slack app with proper OAuth?
188
+
189
+ **Answer:** Slack apps cannot access DMs without explicit OAuth authorization for each conversation. This is by design for privacy.
190
+
191
+ Browser tokens (xoxc/xoxd) provide the same access you have in Slack's web interface - everything you can see, Claude can see.
192
+
193
+ **Trade-offs:**
194
+ - ✅ Full access to all your conversations
195
+ - ✅ No per-conversation authorization needed
196
+ - ❌ Tokens expire every 1-2 weeks
197
+ - ❌ Requires Chrome for token extraction
198
+
199
+ ---
200
+
201
+ ## Getting Help
202
+
203
+ 1. Check logs:
204
+ - MCP: `~/Library/Logs/Claude/mcp-server-slack.log`
205
+ - Web: `/tmp/slack-web-api.log`
206
+
207
+ 2. Test manually:
208
+ ```bash
209
+ cd ~/slack-mcp-server
210
+ node src/server.js # Should say "running"
211
+ ```
212
+
213
+ 3. Verify tokens:
214
+ ```bash
215
+ npm run tokens:status
216
+ ```
@@ -0,0 +1,277 @@
1
+ # Web API Reference
2
+
3
+ The Slack Web Server exposes all MCP tools as REST endpoints, accessible from any browser or HTTP client. This is useful for accessing Slack from claude.ai (which doesn't support MCP).
4
+
5
+ ## Starting the Server
6
+
7
+ ```bash
8
+ cd ~/slack-mcp-server
9
+ npm run web
10
+ ```
11
+
12
+ The server will:
13
+ 1. Start on port 3000
14
+ 2. Serve the web UI at http://localhost:3000
15
+ 3. Use default API key `slack-mcp-local` (or set `SLACK_API_KEY` env var)
16
+
17
+ ## Auto-Start on Login (Recommended)
18
+
19
+ Create a LaunchAgent to auto-start the web server on login:
20
+
21
+ ```bash
22
+ cat > ~/Library/LaunchAgents/com.slack-web-api.plist << 'EOF'
23
+ <?xml version="1.0" encoding="UTF-8"?>
24
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
25
+ <plist version="1.0">
26
+ <dict>
27
+ <key>Label</key>
28
+ <string>com.slack-web-api</string>
29
+ <key>ProgramArguments</key>
30
+ <array>
31
+ <string>/opt/homebrew/bin/node</string>
32
+ <string>/Users/YOUR_USERNAME/slack-mcp-server/src/web-server.js</string>
33
+ </array>
34
+ <key>WorkingDirectory</key>
35
+ <string>/Users/YOUR_USERNAME/slack-mcp-server</string>
36
+ <key>RunAtLoad</key>
37
+ <true/>
38
+ <key>KeepAlive</key>
39
+ <true/>
40
+ <key>StandardOutPath</key>
41
+ <string>/tmp/slack-web-api.log</string>
42
+ <key>StandardErrorPath</key>
43
+ <string>/tmp/slack-web-api.error.log</string>
44
+ </dict>
45
+ </plist>
46
+ EOF
47
+
48
+ # Load it
49
+ launchctl load ~/Library/LaunchAgents/com.slack-web-api.plist
50
+ ```
51
+
52
+ **Manage the service:**
53
+ ```bash
54
+ # Check status
55
+ launchctl list | grep slack-web-api
56
+
57
+ # Restart
58
+ launchctl kickstart -k gui/$(id -u)/com.slack-web-api
59
+
60
+ # Stop
61
+ launchctl unload ~/Library/LaunchAgents/com.slack-web-api.plist
62
+ ```
63
+
64
+ ## Authentication
65
+
66
+ All API requests require the API key in the Authorization header:
67
+
68
+ ```
69
+ Authorization: Bearer <your-api-key>
70
+ ```
71
+
72
+ **Default API Key:** `slack-mcp-local`
73
+
74
+ To use a custom key:
75
+ ```bash
76
+ SLACK_API_KEY=your-custom-key npm run web
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Endpoints
82
+
83
+ ### GET /
84
+ Server info and available endpoints (no auth required).
85
+
86
+ ### GET /health
87
+ Check Slack connection status.
88
+
89
+ ```bash
90
+ curl -H "Authorization: Bearer $API_KEY" http://localhost:3000/health
91
+ ```
92
+
93
+ **Response:**
94
+ ```json
95
+ {
96
+ "status": "OK",
97
+ "user": "james",
98
+ "team": "Rêvasser"
99
+ }
100
+ ```
101
+
102
+ ---
103
+
104
+ ### POST /refresh
105
+ Force token refresh from Chrome.
106
+
107
+ ```bash
108
+ curl -X POST -H "Authorization: Bearer $API_KEY" http://localhost:3000/refresh
109
+ ```
110
+
111
+ ---
112
+
113
+ ### GET /conversations
114
+ List conversations (DMs/channels).
115
+
116
+ **Query Parameters:**
117
+ | Param | Default | Description |
118
+ |-------|---------|-------------|
119
+ | types | im,mpim | Conversation types |
120
+ | limit | 100 | Max results |
121
+
122
+ **Types:** `im`, `mpim`, `public_channel`, `private_channel`
123
+
124
+ ```bash
125
+ curl -H "Authorization: Bearer $API_KEY" "http://localhost:3000/conversations?types=im"
126
+ ```
127
+
128
+ **Response:**
129
+ ```json
130
+ {
131
+ "count": 5,
132
+ "conversations": [
133
+ { "id": "D063M4403MW", "name": "Gwen Santos", "type": "dm" }
134
+ ]
135
+ }
136
+ ```
137
+
138
+ ---
139
+
140
+ ### GET /conversations/:id/history
141
+ Get messages from a conversation.
142
+
143
+ **Query Parameters:**
144
+ | Param | Default | Description |
145
+ |-------|---------|-------------|
146
+ | limit | 50 | Messages to fetch |
147
+ | oldest | - | Unix timestamp start |
148
+ | latest | - | Unix timestamp end |
149
+ | resolve_users | true | Convert user IDs to names |
150
+
151
+ ```bash
152
+ curl -H "Authorization: Bearer $API_KEY" "http://localhost:3000/conversations/D063M4403MW/history?limit=10"
153
+ ```
154
+
155
+ ---
156
+
157
+ ### GET /conversations/:id/full
158
+ Export full conversation with threads.
159
+
160
+ **Query Parameters:**
161
+ | Param | Default | Description |
162
+ |-------|---------|-------------|
163
+ | max_messages | 2000 | Max messages |
164
+ | include_threads | true | Fetch replies |
165
+ | oldest | - | Unix timestamp start |
166
+ | latest | - | Unix timestamp end |
167
+ | output_file | - | Save to file path |
168
+
169
+ ```bash
170
+ curl -H "Authorization: Bearer $API_KEY" "http://localhost:3000/conversations/D063M4403MW/full?max_messages=500"
171
+ ```
172
+
173
+ ---
174
+
175
+ ### GET /conversations/:id/thread/:ts
176
+ Get thread replies.
177
+
178
+ ```bash
179
+ curl -H "Authorization: Bearer $API_KEY" "http://localhost:3000/conversations/D063M4403MW/thread/1767368030.607599"
180
+ ```
181
+
182
+ ---
183
+
184
+ ### GET /search
185
+ Search messages across workspace.
186
+
187
+ **Query Parameters:**
188
+ | Param | Default | Description |
189
+ |-------|---------|-------------|
190
+ | q | *required* | Search query |
191
+ | count | 20 | Max results |
192
+
193
+ **Query Syntax:**
194
+ - `from:@username` - From specific user
195
+ - `in:#channel` - In specific channel
196
+ - `before:2026-01-01` - Before date
197
+ - `after:2025-12-01` - After date
198
+
199
+ ```bash
200
+ curl -H "Authorization: Bearer $API_KEY" "http://localhost:3000/search?q=from:@gwen%20meeting"
201
+ ```
202
+
203
+ ---
204
+
205
+ ### POST /messages
206
+ Send a message.
207
+
208
+ **Body:**
209
+ ```json
210
+ {
211
+ "channel_id": "D063M4403MW",
212
+ "text": "Hello!",
213
+ "thread_ts": "1767368030.607599" // optional, for replies
214
+ }
215
+ ```
216
+
217
+ ```bash
218
+ curl -X POST -H "Authorization: Bearer $API_KEY" \
219
+ -H "Content-Type: application/json" \
220
+ -d '{"channel_id":"D063M4403MW","text":"Hello!"}' \
221
+ http://localhost:3000/messages
222
+ ```
223
+
224
+ ---
225
+
226
+ ### GET /users
227
+ List all workspace users.
228
+
229
+ ```bash
230
+ curl -H "Authorization: Bearer $API_KEY" "http://localhost:3000/users?limit=50"
231
+ ```
232
+
233
+ ---
234
+
235
+ ### GET /users/:id
236
+ Get user details.
237
+
238
+ ```bash
239
+ curl -H "Authorization: Bearer $API_KEY" http://localhost:3000/users/U05GPEVH7J9
240
+ ```
241
+
242
+ ---
243
+
244
+ ## Web UI
245
+
246
+ Open http://localhost:3000 in your browser for a visual interface.
247
+
248
+ The UI auto-connects with the default API key:
249
+ 1. Select a conversation from the sidebar
250
+ 2. View messages, threads, and user info
251
+ 3. Search messages across the workspace
252
+ 4. Send messages directly from the browser
253
+
254
+ **Using with claude.ai:**
255
+ 1. Open the web UI alongside claude.ai
256
+ 2. Browse/search for relevant conversations
257
+ 3. Copy-paste message content into claude.ai as needed
258
+
259
+ ---
260
+
261
+ ## Environment Variables
262
+
263
+ | Variable | Default | Description |
264
+ |----------|---------|-------------|
265
+ | PORT | 3000 | Server port |
266
+ | SLACK_API_KEY | (generated) | API key for authentication |
267
+ | SLACK_TOKEN | - | Slack xoxc token |
268
+ | SLACK_COOKIE | - | Slack xoxd cookie |
269
+
270
+ ---
271
+
272
+ ## Security Notes
273
+
274
+ 1. **API Key**: Keep it secret. Anyone with the key can access your Slack.
275
+ 2. **Local Only**: By default, only accessible from localhost.
276
+ 3. **HTTPS**: For remote access, put behind a reverse proxy with HTTPS.
277
+ 4. **Token Storage**: Slack tokens are stored in keychain and token file.
Binary file
Binary file
Binary file
Binary file