@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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,295 @@
1
+ # Slack MCP Server
2
+
3
+ [![CI](https://github.com/jtalk22/slack-mcp-server/actions/workflows/ci.yml/badge.svg)](https://github.com/jtalk22/slack-mcp-server/actions/workflows/ci.yml)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org/)
6
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/jtalk22/slack-mcp-server/pulls)
7
+ [![GitHub Sponsors](https://img.shields.io/github/sponsors/jtalk22?style=social)](https://github.com/sponsors/jtalk22)
8
+
9
+ A [Model Context Protocol](https://modelcontextprotocol.io/) server that gives Claude full access to your Slack workspace - including **DMs**, channels, and message history.
10
+
11
+ <p align="center">
12
+ <img src="docs/images/demo-main.png" alt="Slack MCP Server Web UI" width="800">
13
+ </p>
14
+
15
+ > **[Try the Interactive Demo](https://jtalk22.github.io/slack-mcp-server/public/demo.html)** - See the Web UI in action with mock data
16
+
17
+ ## Why This Exists
18
+
19
+ Official Slack integrations require OAuth and can't access DMs without explicit per-conversation authorization. This server uses your browser session tokens to provide the same access you have in Slack's web interface.
20
+
21
+ **Works with:**
22
+ - Claude Desktop (macOS/Windows)
23
+ - Claude Code (CLI)
24
+ - claude.ai (via Web UI)
25
+
26
+ ## Features
27
+
28
+ - **Read Messages** - Fetch history from any DM or channel
29
+ - **Full Export** - Export conversations with threads and resolved usernames
30
+ - **Search** - Search messages across your workspace
31
+ - **Send Messages** - Send to DMs or channels
32
+ - **Auto Token Recovery** - Refreshes expired tokens from Chrome automatically
33
+ - **Rate Limit Handling** - Automatic retry with exponential backoff
34
+ - **Web UI** - Browser interface for use with claude.ai
35
+
36
+ ## Quick Start
37
+
38
+ ### 1. Install
39
+
40
+ ```bash
41
+ # Clone the repository
42
+ git clone https://github.com/jtalk22/slack-mcp-server.git
43
+ cd slack-mcp-server
44
+
45
+ # Install dependencies
46
+ npm install
47
+ ```
48
+
49
+ ```
50
+
51
+ ### 2. Get Your Slack Tokens
52
+
53
+ You need two tokens from your browser session:
54
+
55
+ **Option A: Automatic (Recommended)**
56
+ ```bash
57
+ # Open Chrome with Slack (app.slack.com) logged in
58
+ npm run tokens:auto
59
+ ```
60
+
61
+ **Option B: Manual**
62
+
63
+ 1. Open https://app.slack.com in Chrome
64
+ 2. Press F12 → Application → Cookies → Find `d` cookie (starts with `xoxd-`)
65
+ 3. Press F12 → Console → Run:
66
+ ```javascript
67
+ JSON.parse(localStorage.localConfig_v2).teams[Object.keys(JSON.parse(localStorage.localConfig_v2).teams)[0]].token
68
+ ```
69
+ 4. Copy both values and run:
70
+ ```bash
71
+ npm run tokens:refresh
72
+ ```
73
+
74
+ ### 3. Configure Claude
75
+
76
+ #### For Claude Desktop
77
+
78
+ Edit `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
79
+
80
+ ```json
81
+ {
82
+ "mcpServers": {
83
+ "slack": {
84
+ "command": "node",
85
+ "args": ["/path/to/slack-mcp-server/src/server.js"],
86
+ "env": {
87
+ "SLACK_TOKEN": "xoxc-your-token",
88
+ "SLACK_COOKIE": "xoxd-your-cookie"
89
+ }
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ #### For Claude Code
96
+
97
+ Add to `~/.claude.json`:
98
+
99
+ ```json
100
+ {
101
+ "mcpServers": {
102
+ "slack": {
103
+ "type": "stdio",
104
+ "command": "node",
105
+ "args": ["/path/to/slack-mcp-server/src/server.js"]
106
+ }
107
+ }
108
+ }
109
+ ```
110
+
111
+ Claude Code reads tokens from `~/.slack-mcp-tokens.json` automatically.
112
+
113
+ ### 4. Restart Claude
114
+
115
+ The Slack tools will now be available.
116
+
117
+ ## Available Tools
118
+
119
+ | Tool | Description |
120
+ |------|-------------|
121
+ | `slack_health_check` | Verify token validity and show workspace info |
122
+ | `slack_refresh_tokens` | Auto-extract fresh tokens from Chrome |
123
+ | `slack_list_conversations` | List DMs and channels with resolved names |
124
+ | `slack_conversations_history` | Get messages from a channel or DM |
125
+ | `slack_get_full_conversation` | Export full history with threads |
126
+ | `slack_search_messages` | Search across workspace |
127
+ | `slack_send_message` | Send a message |
128
+ | `slack_get_thread` | Get thread replies |
129
+ | `slack_users_info` | Get user details |
130
+ | `slack_list_users` | List workspace users |
131
+
132
+ ## Web UI (for claude.ai)
133
+
134
+ Since claude.ai doesn't support MCP, you can use the web server:
135
+
136
+ ```bash
137
+ npm run web
138
+ ```
139
+
140
+ Open http://localhost:3000 in your browser. It auto-connects with the default API key (`slack-mcp-local`).
141
+
142
+ <details>
143
+ <summary><strong>View Web UI Screenshots</strong></summary>
144
+
145
+ | DMs View | Channels View |
146
+ |----------|---------------|
147
+ | ![DMs](docs/images/demo-main.png) | ![Channels](docs/images/demo-channels.png) |
148
+
149
+ </details>
150
+
151
+ ### Auto-Start on Login (macOS)
152
+
153
+ ```bash
154
+ # Create LaunchAgent
155
+ cat > ~/Library/LaunchAgents/com.slack-mcp-server.plist << 'EOF'
156
+ <?xml version="1.0" encoding="UTF-8"?>
157
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
158
+ <plist version="1.0">
159
+ <dict>
160
+ <key>Label</key>
161
+ <string>com.slack-mcp-server</string>
162
+ <key>ProgramArguments</key>
163
+ <array>
164
+ <string>/usr/local/bin/node</string>
165
+ <string>/path/to/slack-mcp-server/src/web-server.js</string>
166
+ </array>
167
+ <key>WorkingDirectory</key>
168
+ <string>/path/to/slack-mcp-server</string>
169
+ <key>RunAtLoad</key>
170
+ <true/>
171
+ <key>KeepAlive</key>
172
+ <true/>
173
+ </dict>
174
+ </plist>
175
+ EOF
176
+
177
+ launchctl load ~/Library/LaunchAgents/com.slack-mcp-server.plist
178
+ ```
179
+
180
+ ## Token Management
181
+
182
+ Tokens are stored in multiple layers for reliability:
183
+
184
+ 1. **Environment variables** - From MCP config
185
+ 2. **Token file** - `~/.slack-mcp-tokens.json` (chmod 600)
186
+ 3. **macOS Keychain** - Encrypted persistent storage
187
+ 4. **Chrome auto-extraction** - Fallback when tokens expire
188
+
189
+ ### When Tokens Expire
190
+
191
+ Tokens typically last 1-2 weeks. When they expire:
192
+
193
+ ```bash
194
+ # Option 1: In Claude
195
+ slack_refresh_tokens
196
+
197
+ # Option 2: CLI
198
+ npm run tokens:auto
199
+ ```
200
+
201
+ ## Troubleshooting
202
+
203
+ ### DMs Not Showing
204
+
205
+ This is handled automatically. The server discovers DMs by calling `conversations.open` for each user (Slack's `conversations.list` doesn't return DMs with browser tokens).
206
+
207
+ ### Rate Limiting
208
+
209
+ The client implements automatic retry with exponential backoff. If you still hit limits, reduce batch sizes in your queries.
210
+
211
+ ### Claude Desktop Not Seeing Tools
212
+
213
+ 1. Verify JSON syntax in config
214
+ 2. Check logs: `~/Library/Logs/Claude/mcp-server-slack.log`
215
+ 3. Fully restart Claude Desktop (Cmd+Q, then reopen)
216
+
217
+ ### Chrome Extraction Fails
218
+
219
+ - Chrome must be running (not just in Dock)
220
+ - Have a Slack tab open at `app.slack.com`
221
+ - Be logged into Slack
222
+
223
+ ## How It Works
224
+
225
+ This server uses Slack's internal Web API with browser session tokens (`xoxc-` token and `xoxd-` cookie). This provides the same access level as the Slack web interface.
226
+
227
+ **Why not a Slack App?**
228
+
229
+ Slack apps require OAuth and cannot access DMs without explicit per-conversation authorization from users. Browser tokens bypass this limitation.
230
+
231
+ **Trade-offs:**
232
+ - ✅ Full access to all conversations
233
+ - ✅ No per-conversation authorization
234
+ - ❌ Tokens expire every 1-2 weeks
235
+ - ❌ Requires Chrome for token extraction
236
+ - ❌ Not officially supported by Slack
237
+
238
+ ## Security Notes
239
+
240
+ - Tokens are stored with `chmod 600` (owner read/write only)
241
+ - macOS Keychain provides encrypted storage
242
+ - Never commit tokens to version control
243
+ - Web server only accessible on localhost by default
244
+
245
+ ## Project Structure
246
+
247
+ ```
248
+ slack-mcp-server/
249
+ ├── src/
250
+ │ ├── server.js # MCP server entry point
251
+ │ └── web-server.js # REST API + Web UI
252
+ ├── lib/
253
+ │ ├── token-store.js # 4-layer token persistence
254
+ │ ├── slack-client.js # API client with retry logic
255
+ │ ├── tools.js # MCP tool definitions
256
+ │ └── handlers.js # Tool implementations
257
+ ├── public/
258
+ │ ├── index.html # Web UI
259
+ │ └── demo.html # Interactive demo with mock data
260
+ ├── scripts/
261
+ │ └── token-cli.js # Token management CLI
262
+ └── docs/
263
+ ├── images/ # Screenshots
264
+ ├── SETUP.md # Detailed setup guide
265
+ ├── API.md # Tool reference
266
+ ├── WEB-API.md # REST API reference
267
+ └── TROUBLESHOOTING.md
268
+ ```
269
+
270
+ ## Contributing
271
+
272
+ Contributions welcome! Please:
273
+
274
+ 1. Fork the repository
275
+ 2. Create a feature branch
276
+ 3. Make your changes
277
+ 4. Submit a pull request
278
+
279
+ ## Support
280
+
281
+ If you find this useful, consider supporting the project:
282
+
283
+ - [GitHub Sponsors](https://github.com/sponsors/jtalk22)
284
+ - [Ko-fi](https://ko-fi.com/jtalk22)
285
+ - [Buy Me a Coffee](https://www.buymeacoffee.com/jtalk22)
286
+
287
+ Star the repo if it helped you!
288
+
289
+ ## License
290
+
291
+ MIT - See [LICENSE](LICENSE) for details.
292
+
293
+ ## Disclaimer
294
+
295
+ This project uses unofficial Slack APIs. Use at your own risk. The authors are not responsible for any account issues that may arise from using this software.
package/docs/API.md ADDED
@@ -0,0 +1,286 @@
1
+ # API Reference
2
+
3
+ ## Tools
4
+
5
+ ### slack_health_check
6
+
7
+ Check if Slack tokens are valid.
8
+
9
+ **Parameters:** None
10
+
11
+ **Returns:**
12
+ ```json
13
+ {
14
+ "status": "OK",
15
+ "user": "james",
16
+ "team": "Rêvasser",
17
+ "token_source": "environment",
18
+ "token_updated": "2026-01-03T00:00:00Z"
19
+ }
20
+ ```
21
+
22
+ ---
23
+
24
+ ### slack_refresh_tokens
25
+
26
+ Force refresh tokens from Chrome.
27
+
28
+ **Prerequisites:** Chrome must be running with a Slack tab open (app.slack.com).
29
+
30
+ **Parameters:** None
31
+
32
+ **Returns:**
33
+ ```json
34
+ {
35
+ "status": "SUCCESS",
36
+ "user": "james",
37
+ "team": "Rêvasser"
38
+ }
39
+ ```
40
+
41
+ ---
42
+
43
+ ### slack_list_conversations
44
+
45
+ List all DMs and channels.
46
+
47
+ **Parameters:**
48
+ | Name | Type | Default | Description |
49
+ |------|------|---------|-------------|
50
+ | types | string | "im,mpim" | Conversation types to include |
51
+ | limit | number | 100 | Maximum results |
52
+
53
+ **Types:**
54
+ - `im` - Direct messages
55
+ - `mpim` - Group DMs
56
+ - `public_channel` - Public channels
57
+ - `private_channel` - Private channels
58
+
59
+ **Returns:**
60
+ ```json
61
+ {
62
+ "count": 5,
63
+ "conversations": [
64
+ {
65
+ "id": "D063M4403MW",
66
+ "name": "Gwen Santos",
67
+ "type": "dm",
68
+ "user_id": "U05GPEVH7J9"
69
+ }
70
+ ]
71
+ }
72
+ ```
73
+
74
+ ---
75
+
76
+ ### slack_conversations_history
77
+
78
+ Get messages from a channel or DM.
79
+
80
+ **Parameters:**
81
+ | Name | Type | Default | Description |
82
+ |------|------|---------|-------------|
83
+ | channel_id | string | *required* | Channel or DM ID |
84
+ | limit | number | 50 | Messages to fetch (max 100) |
85
+ | oldest | string | - | Unix timestamp, get messages after |
86
+ | latest | string | - | Unix timestamp, get messages before |
87
+ | resolve_users | boolean | true | Convert user IDs to names |
88
+
89
+ **Returns:**
90
+ ```json
91
+ {
92
+ "channel": "D063M4403MW",
93
+ "message_count": 50,
94
+ "has_more": true,
95
+ "messages": [
96
+ {
97
+ "ts": "1767368030.607599",
98
+ "user": "Gwen Santos",
99
+ "user_id": "U05GPEVH7J9",
100
+ "text": "Hello!",
101
+ "datetime": "2026-01-02T15:33:50.000Z",
102
+ "has_thread": false
103
+ }
104
+ ]
105
+ }
106
+ ```
107
+
108
+ ---
109
+
110
+ ### slack_get_full_conversation
111
+
112
+ Export full conversation with threads.
113
+
114
+ **Parameters:**
115
+ | Name | Type | Default | Description |
116
+ |------|------|---------|-------------|
117
+ | channel_id | string | *required* | Channel or DM ID |
118
+ | oldest | string | - | Unix timestamp start |
119
+ | latest | string | - | Unix timestamp end |
120
+ | max_messages | number | 2000 | Max messages (up to 10000) |
121
+ | include_threads | boolean | true | Fetch thread replies |
122
+ | output_file | string | - | Save to file path |
123
+
124
+ **Timestamps:**
125
+ - Dec 1, 2025 = `1733011200`
126
+ - Jan 1, 2026 = `1735689600`
127
+
128
+ **Returns:**
129
+ ```json
130
+ {
131
+ "channel": "D063M4403MW",
132
+ "exported_at": "2026-01-03T16:00:00Z",
133
+ "total_messages": 150,
134
+ "date_range": {
135
+ "oldest": "2025-12-01T00:00:00Z",
136
+ "latest": "now"
137
+ },
138
+ "saved_to": "/Users/james/export.json",
139
+ "messages": [...]
140
+ }
141
+ ```
142
+
143
+ ---
144
+
145
+ ### slack_search_messages
146
+
147
+ Search messages across the workspace.
148
+
149
+ **Parameters:**
150
+ | Name | Type | Default | Description |
151
+ |------|------|---------|-------------|
152
+ | query | string | *required* | Search query |
153
+ | count | number | 20 | Number of results (max 100) |
154
+
155
+ **Query Syntax:**
156
+ - `from:@username` - From specific user
157
+ - `in:#channel` - In specific channel
158
+ - `has:link` - Has links
159
+ - `before:2026-01-01` - Before date
160
+ - `after:2025-12-01` - After date
161
+
162
+ **Returns:**
163
+ ```json
164
+ {
165
+ "query": "project update",
166
+ "total": 25,
167
+ "matches": [
168
+ {
169
+ "ts": "1767368030.607599",
170
+ "channel": "general",
171
+ "channel_id": "C05GPEVH7J9",
172
+ "user": "James Lambert",
173
+ "text": "Here's the project update...",
174
+ "datetime": "2026-01-02T15:33:50.000Z",
175
+ "permalink": "https://..."
176
+ }
177
+ ]
178
+ }
179
+ ```
180
+
181
+ ---
182
+
183
+ ### slack_send_message
184
+
185
+ Send a message.
186
+
187
+ **Parameters:**
188
+ | Name | Type | Default | Description |
189
+ |------|------|---------|-------------|
190
+ | channel_id | string | *required* | Channel or DM ID |
191
+ | text | string | *required* | Message text |
192
+ | thread_ts | string | - | Thread to reply to |
193
+
194
+ **Returns:**
195
+ ```json
196
+ {
197
+ "status": "sent",
198
+ "channel": "D063M4403MW",
199
+ "ts": "1767368030.607599",
200
+ "message": "Hello!"
201
+ }
202
+ ```
203
+
204
+ ---
205
+
206
+ ### slack_get_thread
207
+
208
+ Get all replies in a thread.
209
+
210
+ **Parameters:**
211
+ | Name | Type | Default | Description |
212
+ |------|------|---------|-------------|
213
+ | channel_id | string | *required* | Channel or DM ID |
214
+ | thread_ts | string | *required* | Thread parent timestamp |
215
+
216
+ **Returns:**
217
+ ```json
218
+ {
219
+ "channel": "D063M4403MW",
220
+ "thread_ts": "1767368030.607599",
221
+ "message_count": 5,
222
+ "messages": [
223
+ {
224
+ "ts": "1767368030.607599",
225
+ "user": "James Lambert",
226
+ "text": "Original message",
227
+ "datetime": "2026-01-02T15:33:50.000Z",
228
+ "is_parent": true
229
+ }
230
+ ]
231
+ }
232
+ ```
233
+
234
+ ---
235
+
236
+ ### slack_users_info
237
+
238
+ Get user details.
239
+
240
+ **Parameters:**
241
+ | Name | Type | Default | Description |
242
+ |------|------|---------|-------------|
243
+ | user_id | string | *required* | Slack user ID |
244
+
245
+ **Returns:**
246
+ ```json
247
+ {
248
+ "id": "U05GPEVH7J9",
249
+ "name": "gwen",
250
+ "real_name": "Gwen Santos",
251
+ "display_name": "Gwen",
252
+ "email": "gwen@example.com",
253
+ "title": "Assistant",
254
+ "timezone": "America/New_York",
255
+ "is_bot": false,
256
+ "is_admin": false
257
+ }
258
+ ```
259
+
260
+ ---
261
+
262
+ ### slack_list_users
263
+
264
+ List all workspace users.
265
+
266
+ **Parameters:**
267
+ | Name | Type | Default | Description |
268
+ |------|------|---------|-------------|
269
+ | limit | number | 100 | Maximum users to return |
270
+
271
+ **Returns:**
272
+ ```json
273
+ {
274
+ "count": 10,
275
+ "users": [
276
+ {
277
+ "id": "U05GPEVH7J9",
278
+ "name": "gwen",
279
+ "real_name": "Gwen Santos",
280
+ "display_name": "Gwen",
281
+ "email": "gwen@example.com",
282
+ "is_admin": false
283
+ }
284
+ ]
285
+ }
286
+ ```