Files
comet-ml--opik/.agents/docs/SLACK_MCP_SETUP.md
T
wehub-resource-sync 5a558eb09e
TypeScript SDK Compatibility V1.x E2E Tests / Select Node version matrix (push) Has been cancelled
TypeScript SDK Compatibility V1.x E2E Tests / TypeScript SDK Compatibility V1.x E2E Tests Node ${{matrix.node_version}} (push) Has been cancelled
TypeScript SDK E2E Tests / TypeScript SDK E2E Tests Node ${{matrix.node_version}} (push) Has been cancelled
Opik Optimizer - E2E Tests / build-opik (push) Has been cancelled
TypeScript SDK Compatibility V1.x E2E Tests / build-opik (push) Has been cancelled
Python SDK E2E Tests / Select Python version matrix (push) Has been cancelled
Python SDK E2E Tests / Python SDK E2E Tests ${{matrix.python_version}} (push) Has been cancelled
Python SDK E2E Tests / build-opik (push) Has been cancelled
Python SDK Compatibility V1.x E2E Tests / Select Python version matrix (push) Has been cancelled
Python SDK Compatibility V1.x E2E Tests / Python SDK Compatibility V1.x E2E Tests ${{matrix.python_version}} (push) Has been cancelled
Python SDK Compatibility V1.x E2E Tests / build-opik (push) Has been cancelled
TypeScript SDK E2E Tests / Select Node version matrix (push) Has been cancelled
TypeScript SDK E2E Tests / build-opik (push) Has been cancelled
Opik Optimizer - E2E Tests / Opik Optimizer E2E Tests Python ${{matrix.python_version}} (push) Has been cancelled
Opik Optimizer - E2E Tests / Opik Optimizer Integration Smoke Tests (push) Has been cancelled
🐙 Code Quality / detect (push) Has been cancelled
🐙 Code Quality / lint (${{ matrix.leg.name }}) (push) Has been cancelled
🐙 Code Quality / summary (push) Has been cancelled
TypeScript SDK Library Integration Tests / Check Secrets (push) Has been cancelled
TypeScript SDK Library Integration Tests / opik-vercel (Vercel AI SDK / eve) (push) Has been cancelled
SDK Library Integration Tests Runner / Check Secrets (push) Has been cancelled
SDK Library Integration Tests Runner / Missed OpenAI API Key Warning (push) Has been cancelled
SDK Library Integration Tests Runner / Build (push) Has been cancelled
SDK Library Integration Tests Runner / openai_tests (push) Has been cancelled
SDK Library Integration Tests Runner / langchain_tests (push) Has been cancelled
SDK Library Integration Tests Runner / langchain_legacy_tests (push) Has been cancelled
SDK Library Integration Tests Runner / llama_index_tests (push) Has been cancelled
SDK Library Integration Tests Runner / anthropic_tests (push) Has been cancelled
SDK Library Integration Tests Runner / mistral_tests (push) Has been cancelled
SDK Library Integration Tests Runner / groq_tests (push) Has been cancelled
SDK Library Integration Tests Runner / aisuite_tests (push) Has been cancelled
SDK Library Integration Tests Runner / haystack_tests (push) Has been cancelled
SDK Library Integration Tests Runner / dspy_tests (push) Has been cancelled
SDK Library Integration Tests Runner / crewai_v0_tests (push) Has been cancelled
SDK Library Integration Tests Runner / crewai_v1_tests (push) Has been cancelled
SDK Library Integration Tests Runner / genai_tests (push) Has been cancelled
SDK Library Integration Tests Runner / adk_tests (push) Has been cancelled
SDK Library Integration Tests Runner / adk_legacy_1_3_0_tests (push) Has been cancelled
SDK Library Integration Tests Runner / evaluation_metrics_tests (push) Has been cancelled
SDK Library Integration Tests Runner / bedrock_tests (push) Has been cancelled
SDK Library Integration Tests Runner / litellm_tests (push) Has been cancelled
SDK Library Integration Tests Runner / harbor_tests (push) Has been cancelled
SDK Library Integration Tests Runner / Slack Notification (push) Has been cancelled
Lint Opik Helm Chart / render-equality (push) Has been cancelled
Opik Optimizer - Unit Tests / Opik Optimizer Unit Tests Python ${{matrix.python_version}} (push) Has been cancelled
Python BE E2E Tests / Python BE E2E (push) Has been cancelled
Python Backend Tests / run-python-backend-tests (push) Has been cancelled
Python SDK Unit Tests / Python SDK Unit Tests ${{matrix.python_version}} (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
SDK E2E Libraries Integration Tests / Check Secrets (push) Has been cancelled
SDK E2E Libraries Integration Tests / Missed OpenAI API Key Warning (push) Has been cancelled
SDK E2E Libraries Integration Tests / build-opik (push) Has been cancelled
SDK E2E Libraries Integration Tests / E2E Lib Integration Python ${{matrix.python_version}} (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-gemini) (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-langchain) (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-openai) (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-otel) (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-vercel) (push) Has been cancelled
TypeScript SDK Build & Publish / build-and-publish (push) Has been cancelled
TypeScript SDK Unit Tests / Test on Node ${{ matrix.node-version }} (push) Has been cancelled
Backend Tests / discover-tests (push) Has been cancelled
Backend Tests / ${{ matrix.name }} (push) Has been cancelled
Build and Publish SDK / build-and-publish (push) Has been cancelled
Build Opik Docker Images / set-version (push) Has been cancelled
Build Opik Docker Images / build-backend (push) Has been cancelled
Build Opik Docker Images / build-sandbox-executor-python (push) Has been cancelled
Build Opik Docker Images / build-python-backend (push) Has been cancelled
Build Opik Docker Images / build-frontend (push) Has been cancelled
Build Opik Docker Images / create-git-tag (push) Has been cancelled
ClickHouse Migration Cluster Check / validate-clickhouse-migrations (push) Has been cancelled
Docs - Publish / run (push) Has been cancelled
E2E Tests - Post Merge (v2) / 🧪 E2E v2 Tests (${{ github.event.inputs.tier || 't1' }}) (push) Has been cancelled
E2E Tests - Post Merge (v2) / 📢 Slack Notification (push) Has been cancelled
Frontend Unit Tests / Test on Node 20 (push) Has been cancelled
Guardrails E2E Tests / Select Python version matrix (push) Has been cancelled
Guardrails E2E Tests / Guardrails E2E Tests ${{matrix.python_version}} (push) Has been cancelled
Guardrails E2E Tests / 📢 Slack Notification (push) Has been cancelled
Guardrails Backend Unit Tests / Guardrails Backend Unit Tests (push) Has been cancelled
Guardrails Backend Unit Tests / 📢 Slack Notification (push) Has been cancelled
Lint Opik Helm Chart / lint-helm-chart (Helm v3.21.0) (push) Has been cancelled
Lint Opik Helm Chart / lint-helm-chart (Helm v4.2.0) (push) Has been cancelled
Lint Opik Helm Chart / unittest-helm-chart (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:25:44 +08:00

205 lines
9.6 KiB
Markdown

# Slack MCP Configuration Guide
This guide explains how to configure the **Slack MCP server** for use with Cursor IDE, specifically for the `send-code-review-slack` command.
## Slack MCP Server Setup
This setup uses the **custom Slack MCP server** (`ghcr.io/korotovsky/slack-mcp-server`) which supports **User OAuth Tokens** (`SLACK_MCP_XOXP_TOKEN`). Messages will be posted as your authenticated user account, not as a bot.
### Setup Overview
**Workspace-Level Setup (One-Time, Done by Admin):**
- **Step 1**: Create a Slack App
- **Step 2**: Configure User Token Scopes
**User-Level Setup (Per Developer):**
- **Step 3**: Install App to Workspace
- **Step 4**: Get Your User OAuth Token
- **Step 5**: Environment Variables
- **Step 6**: Restart Cursor
---
### Step 1: Create a Slack App
**Note**: This is a one-time workspace setup step, typically done by a workspace admin. Once the app is created and configured, all users in the workspace can use it.
1. Go to [Slack API Apps](https://api.slack.com/apps)
2. Click **"Create New App"** → **"From scratch"**
3. Name your app (e.g., "Opik Code Review")
4. Select your workspace
5. Click **"Create App"**
### Step 2: Configure User Token Scopes
**Note**: This is a one-time workspace setup step, typically done by a workspace admin. Once the scopes are configured, all users in the workspace will have access to these scopes when they install the app.
**CRITICAL**: You must add scopes to **"User Token Scopes"** (NOT "Bot Token Scopes") for the User OAuth Token to appear.
1. In your app settings, go to **"OAuth & Permissions"**
2. Scroll down to the **"Scopes"** section
3. Find **"User Token Scopes"** section (this is different from "Bot Token Scopes" which is above it)
- You'll see the description: *"Scopes that access user data and act on behalf of users that authorize them."*
- This confirms you're in the right section - these scopes allow the app to act as YOU, not as a bot
4. Click **"Add an OAuth Scope"** under "User Token Scopes"
5. Add the following scopes one by one:
- `chat:write` - Send messages as your authenticated user account
- `channels:read` - View basic information about public channels
- `users:read` - Read user information (required by the MCP server for caching)
- `channels:history` - View messages in public channels (required by the MCP server for channel caching)
6. Click **"Save Changes"**
**Note**: The `users:read` and `channels:history` scopes are required by the `ghcr.io/korotovsky/slack-mcp-server` to properly cache and access channel information. Without these, you may see "missing_scope" errors in the logs, though basic message posting may still work.
### Step 3: Install App to Workspace
**Note**: This is a per-user step. Each developer needs to install the app to their workspace to authorize it and get their own User OAuth Token.
1. Scroll to the top of **"OAuth & Permissions"**
2. Click **"Install to Workspace"** (or **"Reinstall to Workspace"** if you already installed it)
3. Review permissions and click **"Allow"**
- **Note**: The permission screen may say "Send messages as [App Name]" - this is just the app requesting permission. When you use the User OAuth Token, messages will be posted as **your personal account**, not as the app.
### Step 4: Get Your User OAuth Token
**After installing/reinstalling the app**, you need to find your **User OAuth Token**:
1. Stay on the **"OAuth & Permissions"** page (or refresh it)
2. Scroll down to the **"OAuth Tokens for Your Workspace"** section
3. Look for **"User OAuth Token"** (NOT "Bot User OAuth Token")
- If you only see "Bot User OAuth Token", you need to:
- Go back to Step 2 and make sure you added scopes to **"User Token Scopes"** (not "Bot Token Scopes")
- Then come back here and click **"Reinstall to Workspace"** again
4. The User OAuth Token should start with `xoxp-` (not `xoxb-`)
5. Click **"Show"** or **"Reveal"** to see the full token
6. **Copy this token** - this is what will post messages as your authenticated user account
### Step 5: Environment Variables
2. **Create or edit `.env.local`** in your project root and add your User OAuth Token:
```bash
SLACK_MCP_XOXP_TOKEN=xoxp-your-user-oauth-token-here
```
**Important Configuration Options:**
1. **`mcp-server --transport stdio`**: Required for the server to communicate with Cursor via the MCP protocol. Without these, the server will start an SSE server instead, which won't work with Cursor's MCP integration.
2. **`SLACK_MCP_ADD_MESSAGE_TOOL`**: Required to enable the `conversations_add_message` tool (disabled by default for safety).
- `true` or `1`: Enable for all channels and DMs
- Channel IDs (comma-separated): Enable only for specific channels (e.g., `XXXXXXXX,YYYYYYYY`)
- `!XXXXXXXX`: Enable for all channels except the specified one
- **For the code review command**: Use `true` to enable posting to `#code-review`
3. **`envFile`**: Points to `${workspaceFolder}/.env.local` where your `SLACK_MCP_XOXP_TOKEN` is stored securely.
**Important**:
- Replace `xoxp-your-user-oauth-token-here` in `.env.local` with your **User OAuth Token** from Step 4 (starts with `xoxp-`, NOT `xoxb-`)
- The token is loaded from `.env.local` via the `envFile` configuration, keeping it out of `mcp.json`
**Note**: This configuration uses the custom Slack MCP server that supports User OAuth Tokens. Messages will be posted as your authenticated user account, not as a bot.
**Requirements**:
- Docker must be installed and running on your system
- The Docker image `ghcr.io/korotovsky/slack-mcp-server:latest` will be pulled automatically on first use
- `.env.local` should be added to `.gitignore` to prevent committing your token
### Step 6: Restart Cursor
1. Close and reopen Cursor IDE
2. The Slack MCP server should now be available with message posting enabled
3. You can verify by checking Cursor Settings > Features > MCP
4. Test by running: `cursor send-code-review-slack`
---
## Security Notes
- **Never commit tokens to Git**:
- Add `.env.local` to `.gitignore` to prevent committing your token
- The `mcp.json` file references the token via environment variable, but it may contain secrets, check it before committing
- **Token storage**: The `SLACK_MCP_XOXP_TOKEN` is stored in `.env.local` (which should be in `.gitignore`), not directly in `mcp.json`
---
## Troubleshooting
### MCP Server Not Appearing
1. Check that `mcp.json` is in the correct location (`.cursor/mcp.json` or `~/.cursor/mcp.json`)
2. Verify JSON syntax is valid (use a JSON validator)
3. **Restart Cursor completely** (quit and reopen, not just reload window)
4. Check Cursor Settings > Features > MCP for error messages
5. Verify Docker is installed and running: `docker --version` and `docker ps`
### Docker Command Errors
If you see errors like "Usage: docker [OPTIONS] COMMAND" in the MCP logs:
1. **Verify Docker is running**:
```bash
docker ps
```
If this fails, start Docker Desktop or Docker daemon
2. **Test the Docker command manually**:
```bash
docker run -i --rm -e SLACK_MCP_XOXP_TOKEN=xoxp-your-token -e LOG_LEVEL=error ghcr.io/korotovsky/slack-mcp-server:latest
```
This should start the MCP server. If it fails, check the error message.
3. **Pull the Docker image**:
```bash
docker pull ghcr.io/korotovsky/slack-mcp-server:latest
```
4. **Check mcp.json structure**: Ensure the `args` array is properly formatted with each argument as a separate string element
### Authentication Errors
1. **Verify your user token is correct** (should start with `xoxp-`, NOT `xoxb-`)
- If you see `xoxb-` in the logs, you're using a bot token instead of a user token
- Go back to Step 4 and get the **User OAuth Token** (not Bot User OAuth Token)
2. Ensure the app has been installed to your workspace
3. Verify user token scopes include all required scopes in **User Token Scopes**:
- `chat:write` (required for posting messages)
- `channels:read` (required for channel access)
- `users:read` (required by MCP server for caching)
- `channels:history` (recommended for full functionality)
4. Make sure you're using `SLACK_MCP_XOXP_TOKEN` in your Docker args (not `SLACK_BOT_TOKEN`)
5. **Check your actual mcp.json file** - the token in the Docker args should be `xoxp-...`
6. **Restart Cursor completely** after updating the token in mcp.json
7. Verify Docker is running and can pull the image
### Missing Scope Errors
If you see "missing_scope" errors in the MCP logs:
1. **Check which scope is missing** - the error message will indicate the specific scope
2. **Add the missing scope** to your Slack app's **User Token Scopes**:
- Go to your Slack app's "OAuth & Permissions" page
- Scroll to "User Token Scopes"
- Click "Add an OAuth Scope" and add the missing scope
- Common missing scopes: `users:read`, `channels:history`
3. **Reinstall the app** to your workspace after adding scopes
4. **Update the token** in `mcp.json` if a new token was generated
5. **Restart Cursor** to reload the MCP configuration
**Note**: Some "missing_scope" errors may be warnings that don't prevent basic functionality (like posting messages), but adding all recommended scopes ensures full MCP server functionality.
### Permission Errors
1. Ensure the user token has `chat:write` scope in **User Token Scopes**
2. Verify you have access to the `#code-review` channel
3. Check that you're a member of the channel
4. If using Docker, ensure Docker has network access to reach Slack API
---
## Additional Resources
- [Model Context Protocol Documentation](https://modelcontextprotocol.io/)
- [Slack API Documentation](https://api.slack.com/)
- [Custom Slack MCP Server](https://github.com/korotovsky/slack-mcp-server)