Give Duo in Slack access to Slack's MCP server

What does this MR do and why?

Lets GitLab Duo in Slack fetch more Slack context on demand, instead of relying only on the messages we pass in up front. For slack_assistant/v1 sessions, Slack's hosted MCP server (https://mcp.slack.com/mcp) is added to the session's MCP servers, authenticated with the mentioning user's own Slack token. Every read therefore uses that user's Slack permissions.

Most of the plumbing already exists in the AI Catalog MCP servers (OAuth connect flow, per-user token storage, refresh). This MR:

  • Requests channels:history and search:read.public when connecting Slack's MCP server.
  • Sends OAuth client credentials in the request body when the auth server only supports client_secret_post (Slack does not support header based auth). Basic auth stays the default.
  • Adds the Slack MCP server to Slack sessions when the user has connected it.
  • Adds the user scopes and is_mcp_enabled to the generated Slack app manifest.

Everything is behind the slack_duo_mcp_server wip flag, for internal dogfooding.

This first iteration doesn't restrict the agent to the current channel. It can read anything the user can read in Slack, and Slack tool calls need approval. Later on, we can either restrict the MCP calls to just the current channel, on the Workhorse side, or ensure we have enough guardrails in place to prevent any data leaking from private channels

What's left:

  • Restrict requests to current channel
  • Update the goal to include IDs of the previous messages so Duo can get replies from those threads
  • Either merge the 2 authentication links the user must visit, or send both and explain what the user must do
  • Prevent users from having to enable external MCP tools in their group, instead count this as an exception
  • Automatically set up a Slack MCP tool for Self Managed and dedicated
  • Make the Slack tool approval clearer (It's not clear what you're approving)
  • Consider removing the Slack tool approval requirement (or leaving this up to the admins)

References

How to set up and validate locally

  1. Set up GitLab Duo in Slack by following Set up GitLab Duo in Slack for local development, using the GitLab Duo for Slack flow.

  2. In a Rails console, enable the feature flag:

    Feature.enable(:slack_duo_mcp_server)
  3. Re-install the Slack application by going to "GitLab for Slack app" in the admin settings and clicking "Create Slack App"

  4. In your Slack app, go to Agents & AI Apps and turn on Slack Model Context Protocol (MCP) Server. The manifest setting alone doesn't turn it on.

  5. In your default GitLab Duo namespace's top-level group, go to Settings > GitLab Duo and turn on Allow external MCP tools.

  6. Go to Explore > AI Catalog > MCP (/explore/ai-catalog/mcp-servers), select New MCP server, and enter:

    • Server URL: https://mcp.slack.com/mcp
    • Authentication method: OAuth
    • OAuth Client ID and OAuth Client Secret: from your Slack app's Basic Information page

    After saving, note the server ID in the URL.

  7. Go to http://gdk.test:8080/oauth/mcp_connectors/connect?id=<server ID>&return_to=/ and select Allow in Slack.

  8. In a Slack channel, post a message and add a few replies in its thread.

  9. In a different thread, mention the bot and ask about that discussion. (With a link. It can't find a thread ID on its own yet)

  10. When the bot asks you to review the slack_ tool call, approve it. The answer should use the replies from the other thread.

Edited by Keeyan Nejad

Merge request reports

Loading
Loading