Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(ai): slack mcp (#3298)
Eric Hayes7afc69eb5310
diff --git a/infra/stacks/document-cognition-service/index.ts b/infra/stacks/document-cognition-service/index.tsindex 8fd85edf9b..6349cd4e0e 100644--- a/infra/stacks/document-cognition-service/index.ts+++ b/infra/stacks/document-cognition-service/index.ts@@ -82,6 +82,18 @@ const PERPLEXITY_API_KEY = aws.secretsmanager}).apply((secret) => secret.secretString);+const SLACK_MCP_CLIENT_ID = aws.secretsmanager+ .getSecretVersionOutput({+ secretId: config.get('slack-mcp-client-id') ?? '',+ })+ .apply((secret) => secret.secretString);++const SLACK_MCP_CLIENT_SECRET = aws.secretsmanager+ .getSecretVersionOutput({+ secretId: config.get('slack-mcp-client-secret') ?? '',+ })+ .apply((secret) => secret.secretString);+const AUTHENTICATION_SERVICE_INTERNAL_API_KEY_SECRET_NAME = config.require('authentication_service_internal_api_key');@@ -305,6 +317,14 @@ const documentCognitionService = new DocumentCognitionService(name: 'DOCUMENT_COGNITION_SERVICE_URL',value: `https://${SERVICE_DOMAIN_NAME}`,},+ {+ name: 'SLACK_MCP_CLIENT_ID',+ value: pulumi.interpolate`${SLACK_MCP_CLIENT_ID}`,+ },+ {+ name: 'SLACK_MCP_CLIENT_SECRET',+ value: pulumi.interpolate`${SLACK_MCP_CLIENT_SECRET}`,+ },],isPrivate: false,tags,diff --git a/js/app/packages/core/component/AI/constant/mcpServers.ts b/js/app/packages/core/component/AI/constant/mcpServers.tsindex d097bda8d6..515be6fa63 100644--- a/js/app/packages/core/component/AI/constant/mcpServers.ts+++ b/js/app/packages/core/component/AI/constant/mcpServers.ts@@ -2,6 +2,7 @@ import IconDatadog from '@macro-icons/mcp-datadog.svg';import IconGrafana from '@macro-icons/mcp-grafana.svg';import IconLinear from '@macro-icons/mcp-linear.svg';import IconPostHog from '@macro-icons/mcp-posthog.svg';+import IconSlack from '@macro-icons/mcp-slack.svg';import type { Component, JSX } from 'solid-js';export type SvgIcon = Component<JSX.SvgSVGAttributes<SVGSVGElement>>;@@ -27,6 +28,11 @@ export const QUICK_CONNECT_SERVERS = [url: 'https://mcp.grafana.com/mcp',icon: IconGrafana as SvgIcon,},+ {+ server_name: 'Slack',+ url: 'https://mcp.slack.com/mcp',+ icon: IconSlack as SvgIcon,+ },] as const;export const QUICK_CONNECT_ICON_MAP: Map<string, SvgIcon> = new Map(diff --git a/js/app/packages/macro-icons/mcp-slack.svg b/js/app/packages/macro-icons/mcp-slack.svgnew file mode 100644index 0000000000..d9e091b4bc--- /dev/null+++ b/js/app/packages/macro-icons/mcp-slack.svg@@ -0,0 +1 @@+<svg fill="currentColor" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Slack</title><path d="M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zm1.271 0a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zm0 1.271a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zm10.122 2.521a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zm-1.268 0a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zm-2.523 10.122a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zm0-1.268a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z"/></svg>diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lockindex 57d09a6cd0..d3c59125be 100644--- a/rust/cloud-storage/Cargo.lock+++ b/rust/cloud-storage/Cargo.lock@@ -6733,6 +6733,7 @@ dependencies = ["axum","base64 0.22.1","futures",+ "macro_env_var","macro_user_id","model-error-response","model_user",diff --git a/rust/cloud-storage/document_cognition_service/src/api/context/test.rs b/rust/cloud-storage/document_cognition_service/src/api/context/test.rsindex aea4b95d78..3b9ade1294 100644--- a/rust/cloud-storage/document_cognition_service/src/api/context/test.rs+++ b/rust/cloud-storage/document_cognition_service/src/api/context/test.rs@@ -397,6 +397,7 @@ pub async fn test_api_context(pool: sqlx::Pool<sqlx::Postgres>) -> std::sync::Armcp_repo.clone(),mcp_state_store,"http://localhost/mcp/servers/auth/callback".to_string(),+ mcp_client::domain::provider_registry::PreRegisteredProviders::from_env(),);mcp_client::inbound::McpRouterState::new(mcp_repo, mcp_oauth)},diff --git a/rust/cloud-storage/document_cognition_service/src/main.rs b/rust/cloud-storage/document_cognition_service/src/main.rsindex 9c7ea08606..52d15c09d8 100644--- a/rust/cloud-storage/document_cognition_service/src/main.rs+++ b/rust/cloud-storage/document_cognition_service/src/main.rs@@ -410,10 +410,13 @@ async fn main() -> anyhow::Result<()> {);let mcp_oauth_state_store =mcp_client::outbound::redis_state_store::RedisOAuthStateStore::new(redis_client.clone());+ let mcp_pre_registered =+ mcp_client::domain::provider_registry::PreRegisteredProviders::from_env();let mcp_oauth = mcp_client::domain::service::OAuthService::new(mcp_server_repo.clone(),mcp_oauth_state_store,mcp_redirect_uri,+ mcp_pre_registered,);let mcp_state = mcp_client::inbound::McpRouterState::new(mcp_server_repo, mcp_oauth);diff --git a/rust/cloud-storage/mcp_client/Cargo.toml b/rust/cloud-storage/mcp_client/Cargo.tomlindex fb95a6a618..533613464a 100644--- a/rust/cloud-storage/mcp_client/Cargo.toml+++ b/rust/cloud-storage/mcp_client/Cargo.toml@@ -4,6 +4,10 @@ version = "0.1.0"edition = "2024"publish = false+[features]+default = ["providers"]+providers = ["macro_env_var"]+[dependencies]aes-gcm = "0.10"ai = { path = "../ai" }@@ -14,6 +18,7 @@ base64.workspace = trueasync-openai.workspace = trueaxum.workspace = truefutures.workspace = true+macro_env_var = { path = "../macro_env_var", optional = true }macro_user_id = { path = "../macro_user_id" }model-error-response = { path = "../model-error-response" }model_user = { path = "../model_user", features = ["axum"] }diff --git a/rust/cloud-storage/mcp_client/src/domain/mod.rs b/rust/cloud-storage/mcp_client/src/domain/mod.rsindex 96ce5f58c6..f6993d267d 100644--- a/rust/cloud-storage/mcp_client/src/domain/mod.rs+++ b/rust/cloud-storage/mcp_client/src/domain/mod.rs@@ -2,5 +2,8 @@pub mod models;/// Port traits consumed by the domain service.pub mod ports;+/// Registry for MCP servers with pre-registered OAuth credentials.+#[cfg(feature = "providers")]+pub mod provider_registry;/// Service orchestration for MCP connections and tool calls.pub mod service;diff --git a/rust/cloud-storage/mcp_client/src/domain/provider_registry/mod.rs b/rust/cloud-storage/mcp_client/src/domain/provider_registry/mod.rsnew file mode 100644index 0000000000..81fd8bbbdc--- /dev/null+++ b/rust/cloud-storage/mcp_client/src/domain/provider_registry/mod.rs@@ -0,0 +1,68 @@+//! Some providers don't support dynamic client registration.+//! They are configured on a per-provider basis and config loaded here++/// Slack MCP server URL.+const SLACK_SERVER_URL: &str = "https://mcp.slack.com/mcp";++macro_env_var::env_var! {+ /// Environment variables for pre-registered MCP providers.+ #[allow(missing_docs)]+ pub struct ProviderEnvVars {+ /// Slack MCP OAuth client ID (`SLACK_MCP_CLIENT_ID`).+ pub SlackMcpClientId,+ /// Slack MCP OAuth client secret (`SLACK_MCP_CLIENT_SECRET`).+ pub SlackMcpClientSecret,+ }+}++fn slack_scopes() -> Vec<String> {+ let manifest: serde_json::Value =+ serde_json::from_str(include_str!("slack/manifest.json")).expect("valid slack manifest");+ manifest["oauth_config"]["scopes"]["user"]+ .as_array()+ .expect("manifest missing oauth_config.scopes.user")+ .iter()+ .map(|v| v.as_str().expect("scope must be a string").to_owned())+ .collect()+}++/// Pre-registered OAuth credentials for an MCP server that doesn't support DCR.+#[derive(Clone, Debug)]+pub struct PreRegisteredCredentials {+ /// OAuth client ID.+ pub client_id: String,+ /// OAuth client secret.+ pub client_secret: String,+ /// Scopes to request during authorization.+ pub scopes: Vec<String>,+}++/// Registry of MCP servers with pre-registered OAuth credentials.+///+/// Servers in this registry skip Dynamic Client Registration and use the+/// stored credentials directly.+pub struct PreRegisteredProviders {+ env: Option<ProviderEnvVars>,+}++impl PreRegisteredProviders {+ /// Build the registry from environment variables.+ pub fn from_env() -> Self {+ Self {+ env: ProviderEnvVars::new().ok(),+ }+ }++ /// Look up pre-registered credentials for a server URL.+ pub fn get(&self, server_url: &str) -> Option<PreRegisteredCredentials> {+ let env = self.env.as_ref()?;+ match server_url {+ SLACK_SERVER_URL => Some(PreRegisteredCredentials {+ client_id: env.slack_mcp_client_id.to_string(),+ client_secret: env.slack_mcp_client_secret.to_string(),+ scopes: slack_scopes(),+ }),+ _ => None,+ }+ }+}diff --git a/rust/cloud-storage/mcp_client/src/domain/provider_registry/slack/README.md b/rust/cloud-storage/mcp_client/src/domain/provider_registry/slack/README.mdnew file mode 100644index 0000000000..9542a5643f--- /dev/null+++ b/rust/cloud-storage/mcp_client/src/domain/provider_registry/slack/README.md@@ -0,0 +1,30 @@+# Slack MCP Provider++Slack's MCP server (`https://mcp.slack.com/mcp`) does not support Dynamic Client Registration.+A pre-registered Slack app provides the `client_id` and `client_secret` used by the OAuth flow.++## Slack App++**App dashboard**: https://api.slack.com/apps/A0B3XEX55GB++## Environment Variables++| Variable | Description |+|---|---|+| `SLACK_MCP_CLIENT_ID` | OAuth client ID from the Slack app's Basic Information page |+| `SLACK_MCP_CLIENT_SECRET` | OAuth client secret (server-side only, never log) |++Both must be set together or both omitted. If only one is set the service will panic on startup.++## Manifest++`manifest.json` in this directory defines the Slack app configuration (scopes, redirect URIs).+It can be used with the [Slack Manifest API](https://api.slack.com/reference/manifests) to create+or update the app programmatically.++## Relevant Docs++- [Slack MCP overview](https://docs.slack.dev/agents-and-apps/mcp-for-slack)+- [Slack OAuth v2 user tokens](https://docs.slack.dev/authentication/installing-with-oauth)+- [Slack scopes reference](https://docs.slack.dev/reference/scopes)+- [Slack app manifests](https://docs.slack.dev/reference/manifests)diff --git a/rust/cloud-storage/mcp_client/src/domain/provider_registry/slack/manifest.json b/rust/cloud-storage/mcp_client/src/domain/provider_registry/slack/manifest.jsonnew file mode 100644index 0000000000..39c5c86fe6--- /dev/null+++ b/rust/cloud-storage/mcp_client/src/domain/provider_registry/slack/manifest.json@@ -0,0 +1,79 @@+{+ "display_information": {+ "name": "Macro",+ "description": "Macro's MCP integration for Slack",+ "background_color": "#000000"+ },+ "features": {},+ "oauth_config": {+ "redirect_urls": [+ "https://document-cognition.macro.com/mcp/servers/auth/callback",+ "https://document-cognition-dev.macro.com/mcp/servers/auth/callback"+ ],+ "scopes": {+ "user": [+ "bookmarks:read",+ "bookmarks:write",+ "calls:read",+ "calls:write",+ "canvases:read",+ "canvases:write",+ "channels:history",+ "channels:read",+ "channels:write",+ "chat:write",+ "dnd:read",+ "dnd:write",+ "emoji:read",+ "files:read",+ "files:write",+ "groups:history",+ "groups:read",+ "groups:write",+ "identify",+ "im:history",+ "im:read",+ "im:write",+ "links:read",+ "links:write",+ "links.embed:write",+ "lists:read",+ "lists:write",+ "mpim:history",+ "mpim:read",+ "mpim:write",+ "pins:read",+ "pins:write",+ "reactions:read",+ "reactions:write",+ "reminders:read",+ "reminders:write",+ "remote_files:read",+ "search:read",+ "search:read.files",+ "search:read.im",+ "search:read.mpim",+ "search:read.private",+ "search:read.public",+ "search:read.users",+ "stars:read",+ "stars:write",+ "team:read",+ "usergroups:read",+ "usergroups:write",+ "users:read",+ "users:read.email",+ "users:write",+ "users.profile:read",+ "users.profile:write"+ ],+ "bot": []+ }+ },+ "settings": {+ "org_deploy_enabled": true,+ "socket_mode_enabled": false,+ "token_rotation_enabled": false,+ "is_mcp_enabled": true+ }+}diff --git a/rust/cloud-storage/mcp_client/src/domain/service/oauth.rs b/rust/cloud-storage/mcp_client/src/domain/service/oauth.rsindex 90807d3606..20bdcd8477 100644--- a/rust/cloud-storage/mcp_client/src/domain/service/oauth.rs+++ b/rust/cloud-storage/mcp_client/src/domain/service/oauth.rs@@ -1,6 +1,8 @@use crate::domain::models::MCP_CLIENT_NAME;use crate::domain::models::{MacroUserIdStr, McpServerRecord, StoredCredentials};use crate::domain::ports::{McpServerStore, OAuthClient, OAuthStateStore, PendingAuth};+#[cfg(feature = "providers")]+use crate::domain::provider_registry::PreRegisteredProviders;use macro_user_id::cowlike::CowLike;use rmcp::transport::auth::{AuthorizationManager, CredentialStore as _, InMemoryCredentialStore, InMemoryStateStore,@@ -13,13 +15,29 @@ pub struct OAuthService<S, R> {server_store: S,state_store: R,redirect_uri: String,+ #[cfg(feature = "providers")]+ pre_registered: PreRegisteredProviders,}impl<S, R> OAuthService<S, R> {- /// Create a new OAuth service.- ///- /// `redirect_uri` is the callback URL registered with OAuth providers- /// (e.g. `https://api.example.com/mcp/auth/callback`).+ /// Create a new OAuth service with pre-registered provider credentials.+ #[cfg(feature = "providers")]+ pub fn new(+ server_store: S,+ state_store: R,+ redirect_uri: String,+ pre_registered: PreRegisteredProviders,+ ) -> Self {+ Self {+ server_store,+ state_store,+ redirect_uri,+ pre_registered,+ }+ }++ /// Create a new OAuth service (DCR only, no pre-registered providers).+ #[cfg(not(feature = "providers"))]pub fn new(server_store: S, state_store: R, redirect_uri: String) -> Self {Self {server_store,@@ -29,6 +47,59 @@ impl<S, R> OAuthService<S, R> {}}+/// Resolved client configuration for an OAuth flow.+struct ResolvedClient {+ client_id: String,+ client_secret: Option<String>,+ scopes: Vec<String>,+}++impl<S, R> OAuthService<S, R> {+ #[cfg(feature = "providers")]+ async fn resolve_client_config(+ &self,+ server_url: &str,+ auth_manager: &mut AuthorizationManager,+ ) -> anyhow::Result<ResolvedClient> {+ if let Some(creds) = self.pre_registered.get(server_url) {+ let mut config =+ OAuthClientConfig::new(creds.client_id.clone(), self.redirect_uri.clone());+ config = config.with_client_secret(creds.client_secret.clone());+ auth_manager.configure_client(config)?;+ Ok(ResolvedClient {+ client_id: creds.client_id.clone(),+ client_secret: Some(creds.client_secret.clone()),+ scopes: creds.scopes.clone(),+ })+ } else {+ let config = auth_manager+ .register_client(MCP_CLIENT_NAME, &self.redirect_uri, &[])+ .await?;+ Ok(ResolvedClient {+ client_id: config.client_id,+ client_secret: config.client_secret,+ scopes: vec![],+ })+ }+ }++ #[cfg(not(feature = "providers"))]+ async fn resolve_client_config(+ &self,+ _server_url: &str,+ auth_manager: &mut AuthorizationManager,+ ) -> anyhow::Result<ResolvedClient> {+ let config = auth_manager+ .register_client(MCP_CLIENT_NAME, &self.redirect_uri, &[])+ .await?;+ Ok(ResolvedClient {+ client_id: config.client_id,+ client_secret: config.client_secret,+ scopes: vec![],+ })+ }+}+impl<S, R> OAuthClient for OAuthService<S, R>whereS: McpServerStore,@@ -50,11 +121,12 @@ whereauth_manager.set_state_store(in_memory_state.clone());auth_manager.set_credential_store(InMemoryCredentialStore::new());- let client_config = auth_manager- .register_client(MCP_CLIENT_NAME, &self.redirect_uri, &[])+ let resolved = self+ .resolve_client_config(server_url, &mut auth_manager).await?;- let auth_url = auth_manager.get_authorization_url(&[]).await?;+ let scope_refs: Vec<&str> = resolved.scopes.iter().map(|s| s.as_str()).collect();+ let auth_url = auth_manager.get_authorization_url(&scope_refs).await?;let csrf_token = extract_state_param(&auth_url)?;let pkce_state = in_memory_state@@ -64,8 +136,8 @@ wherelet pending = PendingAuth {pkce_verifier: pkce_state.pkce_verifier,- client_id: client_config.client_id,- client_secret: client_config.client_secret,+ client_id: resolved.client_id,+ client_secret: resolved.client_secret,user_id: user_id.as_ref().to_string(),server_url: server_url.to_string(),server_name: server_name.to_string(),