一键导入
slack-mcp-setup
Set up Slack MCP server with xoxp User OAuth token. Use for initial setup or token rotation. Covers macOS (Keychain) and cloudbox (sops).
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Set up Slack MCP server with xoxp User OAuth token. Use for initial setup or token rotation. Covers macOS (Keychain) and cloudbox (sops).
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use on any NixOS host (devbox on Hetzner, cloudbox on GCP) when SSH connection fails, host key mismatch, NixOS issues, CPU/IO contention (high load), or verifying the host is properly configured
Launch headless opencode sessions from CLI. Use when you need to start a new opencode session in the background to work on a task in parallel, or when spawning work on a specific directory.
How to apply configuration changes to NixOS hosts (devbox, cloudbox). Use when you need to rebuild the system, apply home-manager changes, or recover from issues.
Use when setting up or rotating PagerDuty MCP auth for OpenCode on macOS Keychain or cloudbox sops, or when debugging missing PagerDuty tools.
Use when setting up or rotating Rollbar MCP auth for OpenCode on macOS Keychain or cloudbox sops, when triaging a Rollbar error paged via PagerDuty, or when debugging missing Rollbar tools.
Documents the OpenCode agent set — what each does, when to use it, and why the others were cut. Use when questioning agent choices or considering adding/removing agents.
| name | slack-mcp-setup |
| description | Set up Slack MCP server with xoxp User OAuth token. Use for initial setup or token rotation. Covers macOS (Keychain) and cloudbox (sops). |
Uses a registered Slack app with User OAuth (xoxp-* token) for stable authentication.
No browser cookie scraping -- tokens don't expire unless revoked.
| Platform | Token storage | Injection trigger |
|---|---|---|
| macOS | Keychain | darwin-rebuild switch |
| cloudbox | sops (/run/secrets/) | nixos-rebuild switch + home-manager switch |
slack — read + write (SLACK_MCP_ADD_MESSAGE_TOOL=true, so the post-message tool is registered)slack-ro — read-only (omits SLACK_MCP_ADD_MESSAGE_TOOL, so only read tools register; cannot post). Used by lgtm's read-only gather session (opencode-launch --mcp slack-ro)."enabled": false) to keep slack tools out of normal sessionsslack agent, or launch with --mcp slack / --mcp slack-roWhy disabled by default?
What
SLACK_MCP_ADD_MESSAGE_TOOLactually does (common gotcha): it enables the write tool (conversations_add_message) only. The korotovsky server registers all read tools by default regardless of this env var. So if a session is missing the Slack read tools, that is not a server or token-scope problem — it is an opencode gating/connection issue:
- the global
tools: {"slack_*": false, "slack-ro_*": false}gate disables the tools for every agent except theslacksubagent, andenabled: falsemeans the server is never auto-connected — a session only gets Slack if something runsPOST /mcp/<server>/connect(which is whatopencode-launch --mcp <server>does).Note also that
--mcpfolds the tools into a single prompt (per-turn scope), and the in-memory connect is lost on an opencode-serve restart (no auto-reconnect whileenabled: false). For durable interactive Slack use, delegate to the@slacksubagent rather than relying on a per-turn--mcpfold.
You need a registered Slack app with User OAuth scopes. If you don't have one:
channels:history, channels:readgroups:history, groups:readim:history, im:read, im:writempim:history, mpim:read, mpim:writeusers:readchat:writesearch:readusergroups:read, usergroups:writexoxp-)security add-generic-password -a "$USER" -s slack-mcp-xoxp-token -w "xoxp-YOUR-TOKEN" -U
The -U flag updates if the item already exists.
sudo darwin-rebuild switch --flake ~/Code/workstation#Y0FMQX93RR-2
From cloudbox:
sudo nix-shell -p sops --run "SOPS_AGE_KEY_FILE=/var/lib/sops-age-key.txt sops set secrets/cloudbox.yaml '[\"slack_mcp_xoxp_token\"]' '\"xoxp-YOUR-TOKEN\"'"
Commit and push the updated secrets file, then on cloudbox:
cd ~/projects/workstation && git pull
sudo nixos-rebuild switch --flake .#cloudbox # Deploys sops secrets
nix run home-manager -- switch --flake .#cloudbox # Injects into opencode.json
jq '{slack: .mcp.slack, "slack-ro": .mcp."slack-ro"}' ~/.config/opencode/opencode.json
# Both should show type, command, enabled: false, and environment with SLACK_MCP_XOXP_TOKEN.
# slack also has SLACK_MCP_ADD_MESSAGE_TOOL: "true"; slack-ro must NOT (read-only).
xoxp tokens from registered apps don't expire on their own. You only need to re-issue if:
If you do need to refresh:
| Error | Solution |
|---|---|
invalid_auth | Token revoked or app uninstalled. Get new token from app OAuth page. |
missing_scope | App needs additional scopes. Add them in app settings, reinstall. |
not_authed | Token not injected. Check Keychain/sops storage, re-apply config. |
| No Slack config after switch | macOS: security find-generic-password -s slack-mcp-xoxp-token. Cloudbox: cat /run/secrets/slack_mcp_xoxp_token. |
jq '.mcp.slack.enabled = true' ~/.config/opencode/opencode.json > /tmp/oc.json && mv /tmp/oc.json ~/.config/opencode/opencode.json
# Restart OpenCode, use slack tools
# Disable when done:
jq '.mcp.slack.enabled = false' ~/.config/opencode/opencode.json > /tmp/oc.json && mv /tmp/oc.json ~/.config/opencode/opencode.json
The slack agent enables the MCP automatically. Use it from OpenCode.
Available tools:
slack_channels_list - List channelsslack_conversations_history - Get channel messagesslack_conversations_replies - Get thread repliesslack_conversations_search_messages - Search messages with filtersslack_conversations_add_message - Post messages (use carefully)users/dev/opencode-config.nix (injectSlackMcpSecrets)users/dev/opencode-config.nix (injectSlackMcpSecretsSops)assets/opencode/agents/slack.md