### Example Initialization of Channel Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/types.md Shows how to create and initialize a Channel struct with basic information. This is a simplified example for demonstration purposes. ```go ch := Channel{ ID: "C1234567890", Name: "general", Purpose: "General team discussion", MemberCount: 150, IsPrivate: false, } ``` -------------------------------- ### Development Setup with HTTPToolkit Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/transport.md Configure the client for development with HTTPToolkit for MITM inspection. This setup uses UserAgentTransport, trusts the HTTPToolkit CA, and enables debug logging. ```bash export SLACK_MCP_XOXC_TOKEN=xoxc-... export SLACK_MCP_XOXD_TOKEN=xoxd-... export SLACK_MCP_SERVER_CA_TOOLKIT=true export SLACK_MCP_LOG_LEVEL=debug ``` -------------------------------- ### Example Usage of UsersCache Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/types.md Demonstrates how to retrieve user information and user IDs from the UsersCache. Assumes the cache is populated by provider.ProvideUsersMap(). ```go cache := provider.ProvideUsersMap() user, found := cache.Users["U1234567890"] if found { fmt.Println(user.RealName) } userID, found := cache.UsersInv["john"] if found { fmt.Println("ID for 'john':", userID) } ``` -------------------------------- ### Configure slack-mcp-server with XOXP Token using npx Source: https://github.com/korotovsky/slack-mcp-server/blob/master/docs/03-configuration-and-usage.md Use this configuration to start the slack-mcp-server with an XOXP token via npx and stdio transport. Ensure npm is installed. ```json { "mcpServers": { "slack": { "command": "npx", "args": [ "-y", "slack-mcp-server@latest", "--transport", "stdio" ], "env": { "SLACK_MCP_XOXP_TOKEN": "xoxp-..." } } } } ``` -------------------------------- ### Configure slack-mcp-server with XOXC/XOXD Tokens using Docker Source: https://github.com/korotovsky/slack-mcp-server/blob/master/docs/03-configuration-and-usage.md This Docker configuration starts the slack-mcp-server using XOXC and XOXD tokens with stdio transport. Ensure Docker is installed. ```json { "mcpServers": { "slack": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "SLACK_MCP_XOXC_TOKEN", "-e", "SLACK_MCP_XOXD_TOKEN", "ghcr.io/korotovsky/slack-mcp-server", "--transport", "stdio" ], "env": { "SLACK_MCP_XOXC_TOKEN": "xoxc-ինչ", "SLACK_MCP_XOXD_TOKEN": "xoxd-ինչ" } } } } ``` -------------------------------- ### Standard Setup with Browser Token Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/transport.md Configure the client to use UserAgentTransport with cookies and a standard Mozilla User-Agent when using browser tokens (xoxc/xoxd). No proxy or custom TLS is used in this setup. ```bash export SLACK_MCP_XOXC_TOKEN=xoxc-... export SLACK_MCP_XOXD_TOKEN=xoxd-... ``` -------------------------------- ### Serve MCP Server via SSE Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/server.md Starts the MCP server with Server-Sent Events (SSE) over HTTP. Returns an HTTP server instance that needs to be explicitly started. ```go httpServer := server.ServeSSE(":13080") if err := httpServer.Start("127.0.0.1:13080"); err != nil { log.Fatal(err) } ``` -------------------------------- ### Minimal Read-only Setup with Specific Tools Source: https://github.com/korotovsky/slack-mcp-server/blob/master/docs/03-configuration-and-usage.md Configure `SLACK_MCP_ENABLED_TOOLS` to expose only a specific subset of read-only tools, such as `channels_list` and `conversations_history`, for a minimal setup. ```json { "env": { "SLACK_MCP_XOXP_TOKEN": "xoxp- மரு", "SLACK_MCP_ENABLED_TOOLS": "channels_list,conversations_history" } } ``` -------------------------------- ### Serve MCP Server via HTTP Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/server.md Starts the MCP server with standard HTTP request/response transport. Returns an HTTP server instance. ```go httpServer := server.ServeHTTP(":13080") if err := httpServer.Start("0.0.0.0:13080"); err != nil { log.Fatal(err) } ``` -------------------------------- ### Start Slack MCP Server with Stdio Transport Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/server.md Use this command to start the server with the default Stdio transport. This is suitable for local or desktop application integrations. ```bash # From Claude Code slack-mcp-server ``` ```bash # Manually slack-mcp-server --transport stdio ``` -------------------------------- ### Production Setup Configuration Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/configuration.md Configure for production using an OAuth token and read-only access. Set authentication token, server host/port, API key, logging, caching, and security settings. ```bash # Authentication export SLACK_MCP_XOXP_TOKEN=xoxp-123456789... # Server export SLACK_MCP_HOST=0.0.0.0 export SLACK_MCP_PORT=13080 export SLACK_MCP_API_KEY=production-secret-key-12345 # Logging export SLACK_MCP_LOG_LEVEL=info export SLACK_MCP_LOG_FORMAT=json # Caching export SLACK_MCP_CACHE_TTL=24h export SLACK_MCP_MIN_REFRESH_INTERVAL=5m # Security export SLACK_MCP_SERVER_CA=/etc/ssl/certs/ca-bundle.crt # Tools (read-only only) export SLACK_MCP_ENABLED_TOOLS=conversations_history,channels_list,users_search ``` -------------------------------- ### Development Setup Configuration Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/configuration.md Configure for development using a browser token and enabling all features. Ensure to set authentication tokens, server host/port, logging level/format, cache TTL, and specific tools. ```bash # Authentication export SLACK_MCP_XOXC_TOKEN=xoxc-123456789... export SLACK_MCP_XOXD_TOKEN=xoxd-abcdefgh... # Server export SLACK_MCP_HOST=127.0.0.1 export SLACK_MCP_PORT=13080 # Logging export SLACK_MCP_LOG_LEVEL=debug export SLACK_MCP_LOG_FORMAT=console # Caching export SLACK_MCP_CACHE_TTL=1h # Tools (enable all, but message posting with safeguards) export SLACK_MCP_ADD_MESSAGE_TOOL="C1234567890,C0987654321" # Only #general, #testing export SLACK_MCP_REACTION_TOOL=true export SLACK_MCP_MARK_TOOL=true export SLACK_MCP_ATTACHMENT_TOOL=true ``` -------------------------------- ### Configure SSE Transport and Tools Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/configuration.md Run the slack-mcp-server with the SSE transport and specify enabled tools using command-line flags. This example enables the conversations_history and channels_list tools. ```bash slack-mcp-server --transport sse --enabled-tools conversations_history,channels_list ``` -------------------------------- ### Start Slack MCP Server with SSE Transport Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/server.md Configure and start the server using the Server-Sent Events (SSE) transport. This is ideal for managed servers requiring a stream-based connection. Ensure SLACK_MCP_HOST and SLACK_MCP_PORT are set. ```bash export SLACK_MCP_HOST=0.0.0.0 export SLACK_MCP_PORT=13080 slack-mcp-server --transport sse ``` -------------------------------- ### Example Conversations History Handler Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/server.md An example implementation of a tool handler for retrieving conversation history. It parses the 'channel_id' argument and includes placeholder logic for processing the tool. ```go func (ch *ConversationsHandler) ConversationsHistoryHandler( ctx context.Context, request mcp.CallToolRequest, ) (*mcp.CallToolResult, error) { // Parse arguments channelID, ok := request.Arguments["channel_id"].(string) if !ok { return &mcp.CallToolResult{ IsError: true, Content: []interface{}{"missing required argument: channel_id"}, }, nil } // Process tool // ... // Return result return &mcp.CallToolResult{ Content: []interface{}{textContent}, }, nil } ``` -------------------------------- ### Enterprise Grid Setup Configuration Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/configuration.md Configure for Enterprise Grid with a custom user-agent and GovSlack support. Set authentication tokens, user-agent, custom TLS, GovSlack flag, and logging level. ```bash export SLACK_MCP_XOXC_TOKEN=xoxc-... export SLACK_MCP_XOXD_TOKEN=xoxd-... export SLACK_MCP_USER_AGENT="Enterprise Grid Client" export SLACK_MCP_CUSTOM_TLS=true export SLACK_MCP_GOVSLACK=true export SLACK_MCP_LOG_LEVEL=debug ``` -------------------------------- ### Deploy slack-mcp-server using docker-compose Source: https://github.com/korotovsky/slack-mcp-server/blob/master/docs/03-configuration-and-usage.md This sequence of commands sets up slack-mcp-server using docker-compose. It involves downloading configuration files, setting environment variables, creating a Docker network, and starting the service in detached mode. ```bash wget -O docker-compose.yml https://github.com/korotovsky/slack-mcp-server/releases/latest/download/docker-compose.yml wget -O .env https://github.com/korotovsky/slack-mcp-server/releases/latest/download/default.env.dist nano .env # Edit .env file with your tokens from step 1 of the setup guide docker network create app-tier docker-compose up -d ``` -------------------------------- ### Configure slack-mcp-server with XOXB Token using npx Source: https://github.com/korotovsky/slack-mcp-server/blob/master/docs/03-configuration-and-usage.md This setup uses npx to run the slack-mcp-server with a bot token (XOXB) and stdio transport. Requires npm. ```json { "mcpServers": { "slack": { "command": "npx", "args": [ "-y", "slack-mcp-server@latest", "--transport", "stdio" ], "env": { "SLACK_MCP_XOXB_TOKEN": "xoxb-..." } } } } ``` -------------------------------- ### Configure slack-mcp-server with XOXC/XOXD Tokens using npx Source: https://github.com/korotovsky/slack-mcp-server/blob/master/docs/03-configuration-and-usage.md Configure the slack-mcp-server to use XOXC and XOXD tokens with npx and stdio transport. Ensure npm is installed. ```json { "mcpServers": { "slack": { "command": "npx", "args": [ "-y", "slack-mcp-server@latest", "--transport", "stdio" ], "env": { "SLACK_MCP_XOXC_TOKEN": "xoxc-ինչ", "SLACK_MCP_XOXD_TOKEN": "xoxd-ինչ" } } } } ``` -------------------------------- ### Start Slack MCP Server with HTTP Transport Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/server.md Launch the server with the HTTP transport for public API integrations. Requires setting host, port, and an API key for authentication. Ensure SLACK_MCP_HOST, SLACK_MCP_PORT, and SLACK_MCP_API_KEY are set. ```bash export SLACK_MCP_HOST=0.0.0.0 export SLACK_MCP_PORT=13080 export SLACK_MCP_API_KEY=secret-key slack-mcp-server --transport http ``` -------------------------------- ### Change User Group Handle and Channels Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/usergroups.md This example demonstrates how to simultaneously update a user group's mention handle and its default channels. Provide the `usergroup_id`, the new `handle` (without '@'), and a comma-separated string of channel IDs for `channels`. ```go result, err := handler.UsergroupsUpdateHandler(ctx, mcp.CallToolRequest{ Arguments: map[string]interface{}{ "usergroup_id": "S1234567890", "handle": "new-handle", "channels": "C1111111111,C2222222222", }, }) ``` -------------------------------- ### Configure Channel Whitelist for Tools Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/errors.md Restricts tool usage to specific channels by providing a comma-separated list of channel IDs in the environment variable. This example allows message posting only in #general and #testing. ```bash # Only allow message posting in #general and #testing export SLACK_MCP_ADD_MESSAGE_TOOL=C1234567890,C0987654321 ``` -------------------------------- ### Enterprise Configuration (Custom TLS, GovSlack) Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/README.md Configure for enterprise use with custom TLS and GovSlack support. This setup uses browser tokens and enables custom TLS and GovSlack features. ```bash export SLACK_MCP_XOXC_TOKEN=xoxc-... export SLACK_MCP_XOXD_TOKEN=xoxd-... export SLACK_MCP_CUSTOM_TLS=true export SLACK_MCP_GOVSLACK=true ``` -------------------------------- ### Workflow Example: Mark and Clear Multiple Saved Items Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/saved.md This Go code demonstrates a workflow to mark multiple saved items as completed and then clear them. It involves listing items, updating their status, and finally clearing completed ones. ```go // 1. List all saved items listResult, _ := handler.SavedListHandler(ctx, mcp.CallToolRequest{ Arguments: map[string]interface{}{}, }) // Parse CSV output to get item_id and ts for items to mark // 2. Update each item for _, item := range itemsToMark { _, _ := handler.SavedUpdateHandler(ctx, mcp.CallToolRequest{ Arguments: map[string]interface{}{}, }) } // 3. Optionally clear all completed items _, _ := handler.SavedClearCompletedHandler(ctx, mcp.CallToolRequest{ Arguments: map[string]interface{}{}, }) ``` -------------------------------- ### Initialize MCP Server Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/server.md Creates and initializes a new MCP server instance. Requires an API provider, a logger, and an optional list of enabled tools. ```go provider := provider.New("stdio", logger) server := NewMCPServer(provider, logger, []string{ "conversations_history", "channels_list", }) ``` -------------------------------- ### Create Basic User Group Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/usergroups.md Use this to create a new user group with a name and description. The handle will be auto-generated if not provided. ```go result, err := handler.UsergroupsCreateHandler(ctx, mcp.CallToolRequest{ Arguments: map[string]interface{}{ "name": "Backend Team", "description": "Backend developers", }, }) ``` -------------------------------- ### Configure HTTP Proxy with Authentication Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/transport.md Set up an HTTP proxy with authentication credentials by including the username and password in the SLACK_MCP_PROXY environment variable. ```bash export SLACK_MCP_PROXY=http://user:password@proxy.example.com:8080 ``` -------------------------------- ### Provide HTTP Client Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/transport.md Create a configured HTTP client with TLS, proxy, and authentication. Supports custom TLS, proxy detection, CA injection, and custom User-Agents. ```go cookies := []*http.Cookie{ {Name: "d", Value: "xoxd-..."}, } client := ProvideHTTPClient(cookies, logger) resp, err := client.Get("https://slack.com/api/auth.test") ``` -------------------------------- ### Get Server Transport Type Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/provider.md Returns the current server transport mechanism. This can be 'stdio', 'sse', or 'http'. ```go func (ap *ApiProvider) ServerTransport() string ``` -------------------------------- ### IsBotToken Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/provider.md Checks if the current token being used is a bot token. This is determined by checking if the token starts with the prefix 'xoxb-'. ```APIDOC ## IsBotToken ### Description Check if using a bot token. ### Method Signature ```go func (ap *ApiProvider) IsBotToken() bool ``` ### Parameters - None ### Returns - **bool** - true if token starts with `xoxb-` ``` -------------------------------- ### Get Slack Connect Channels Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/provider.md Retrieves information about users participating in Slack Connect channels, which are shared with external organizations. ```go func (ap *ApiProvider) GetSlackConnect(ctx context.Context) ([]slack.User, error) ``` -------------------------------- ### Clear All Completed Saved Items Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/saved.md Example of how to call SavedClearCompletedHandler to clear all completed items. The result object provides a summary of the deletion. ```go // Clear all completed items result, err := handler.SavedClearCompletedHandler(ctx, mcp.CallToolRequest{ Arguments: map[string]interface{}{}, }) // Result tells you how many items were deleted // Output: {"ok": true, "cleared_count": 42} ``` -------------------------------- ### NewMCPServer Constructor Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/server.md Initializes a new MCPServer instance. It requires an API provider and a logger, and optionally accepts a list of enabled tools. ```APIDOC ## NewMCPServer ### Description Initializes a new MCPServer instance. It requires an API provider and a logger, and optionally accepts a list of enabled tools. ### Signature ```go func NewMCPServer(provider *provider.ApiProvider, logger *zap.Logger, enabledTools []string) *MCPServer ``` ### Parameters #### Path Parameters - **provider** (*provider.ApiProvider) - Required - API provider for Slack communication - **logger** (*zap.Logger) - Required - Structured logger for debug/error logging - **enabledTools** ([]string) - Optional - List of tools to register; empty = all tools ### Returns - ***MCPServer** - Initialized server instance ### Example ```go provider := provider.New("stdio", logger) server := NewMCPServer(provider, logger, []string{ "conversations_history", "channels_list", }) ``` ``` -------------------------------- ### SavedClearCompletedHandler Return Type Example Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/saved.md This JSON object illustrates the expected return format from SavedClearCompletedHandler, indicating success and the count of cleared items. ```json { "ok": true, "cleared_count": 42 } ``` -------------------------------- ### Check Cache Readiness Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/errors.md Before proceeding, verify if the cache is ready. If not, return an error indicating that the cache is still initializing. ```go if ready, err := provider.IsReady(); !ready { return fmt.Errorf("waiting for cache: %w", err) } ``` -------------------------------- ### Get Slack API Client Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/provider.md Provides access to the underlying Slack API client interface. Use this for direct interactions with the Slack API. ```go func (ap *ApiProvider) Slack() SlackAPI ``` -------------------------------- ### All Tools Enabled for Development Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/server.md Use an empty `enabledTools` slice to enable all tools. This is typically used for development environments. ```go enabledTools := []string{} // empty = all tools ``` -------------------------------- ### Get Channels of a Single Type Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/provider.md Fetches all channels that belong to a specific channel type. This is useful when you need to filter for only one category of channels. ```go func (ap *ApiProvider) GetChannelsType(ctx context.Context, channelType string) []Channel ``` -------------------------------- ### Get Channels by Type Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/provider.md Retrieves channels from the cache based on specified types. Use this to fetch lists of public, private, IM, or MPIM channels. ```go func (ap *ApiProvider) GetChannels(ctx context.Context, channelTypes []string) []Channel ``` ```go channels := provider.GetChannels(ctx, []string{"public_channel", "private_channel"}) for _, ch := range channels { fmt.Printf("#%s (%d members)\n", ch.Name, ch.MemberCount) } ``` -------------------------------- ### Get Users Cache Snapshot Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/provider.md Retrieves an immutable snapshot of the users cache. Use this to access user data by ID or for reverse lookups by username. ```go func (ap *ApiProvider) ProvideUsersMap() *UsersCache ``` ```go type UsersCache struct { Users map[string]slack.User // key: user ID UsersInv map[string]string // key: username -> user ID (inverse lookup) } ``` ```go cache := provider.ProvideUsersMap() if user, found := cache.Users["U1234567890"]; found { fmt.Println(user.RealName) } // Reverse lookup by username if userID, found := cache.UsersInv["john"]; found { fmt.Println("User john has ID:", userID) } ``` -------------------------------- ### Initialize and Wait for Cache Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/README.md Initializes the provider and waits until the cache is ready before proceeding. This ensures that name-based lookups can be used safely. ```go provider := provider.New("stdio", logger) // Wait for both caches for { if ready, _ := provider.IsReady(); ready { break } time.Sleep(1 * time.Second) } // Now can use name-based lookups ``` -------------------------------- ### Get Channels Cache Snapshot Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/provider.md Retrieves an immutable snapshot of the channels cache. Use this to access channel data by ID or for reverse lookups by channel name. ```go func (ap *ApiProvider) ProvideChannelsMaps() *ChannelsCache ``` ```go type ChannelsCache struct { Channels map[string]Channel // key: channel ID ChannelsInv map[string]string // key: name -> channel ID (inverse lookup) } type Channel struct { ID string // Channel ID (e.g., "C1234567890") Name string // Channel name (e.g., "general") Topic string // Topic description Purpose string // Purpose description MemberCount int // Number of members IsMpIM bool // Is group DM IsIM bool // Is direct message IsPrivate bool // Is private channel IsExtShared bool // Shared with external orgs User string // User ID (for IM channels) Members []string // Member IDs } ``` ```go cache := provider.ProvideChannelsMaps() // Forward lookup by ID if channel, found := cache.Channels["C1234567890"]; found { fmt.Println("Channel members:", channel.MemberCount) } // Reverse lookup by name if channelID, found := cache.ChannelsInv["general"]; found { fmt.Println("general channel ID:", channelID) } ``` -------------------------------- ### Development Configuration (Browser Token) Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/README.md Use this configuration for development environments with a browser token, enabling all features. Ensure SLACK_MCP_ADD_MESSAGE_TOOL is set to whitelist specific channels if needed. ```bash export SLACK_MCP_XOXC_TOKEN=xoxc-... export SLACK_MCP_XOXD_TOKEN=xoxd-... export SLACK_MCP_LOG_LEVEL=debug export SLACK_MCP_ADD_MESSAGE_TOOL=C123,C456 # whitelist channels export SLACK_MCP_REACTION_TOOL=true ``` -------------------------------- ### Configure Logging Middleware Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/server.md Add the logging middleware to log all tool requests and responses, including details like arguments, status, and execution time. ```go server.WithToolHandlerMiddleware(buildLoggerMiddleware(logger)) ``` -------------------------------- ### IsOAuth Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/provider.md Determines if the current token is an OAuth token (either user or bot). This function returns true if the token starts with 'xoxp-' or 'xoxb-', indicating it's not a browser token. ```APIDOC ## IsOAuth ### Description Check if using OAuth token (user or bot). ### Method Signature ```go func (ap *ApiProvider) IsOAuth() bool ``` ### Parameters - None ### Returns - **bool** - true if using `xoxp-` or `xoxb-` token (not browser token) ``` -------------------------------- ### Lightweight Saved Items Query Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/saved.md Performs a query for saved items without fetching message content, setting a limit of 200 items. This is efficient for getting a quick overview. ```go // Lightweight query without message content result, err := handler.SavedListHandler(ctx, mcp.CallToolRequest{ Arguments: map[string]interface{}{ "include_messages": false, "limit": 200, }, }) ``` -------------------------------- ### Initialize Provider Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/provider.md Creates a new ApiProvider instance. Specify the transport type and a logger. The transport can be 'stdio', 'sse', or 'http'. ```go provider := provider.New("stdio", logger) defer provider.SkipCache() // optional: skip cache loading for speed ``` -------------------------------- ### Documentation Navigation Structure Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/STRUCTURE.md Illustrates the directory structure and file organization for the Slack MCP Server documentation. ```text output/ ├── README.md # Quick start and navigation ├── STRUCTURE.md # This file ├── types.md # Type definitions ├── configuration.md # Configuration reference ├── errors.md # Error handling guide └── api-reference/ ├── conversations.md # Conversation operations ├── channels.md # Channel discovery ├── usergroups.md # User group management ├── saved.md # Saved items ├── provider.md # Core provider API ├── server.md # MCP server └── transport.md # HTTP transport ``` -------------------------------- ### Get User's Direct Messages Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/channels.md Use ChannelsMeHandler to specifically retrieve only the direct messages (IMs) the current user is a member of. This is useful for filtering conversations to only include direct messages. ```go result, err := channelsHandler.ChannelsMeHandler(ctx, mcp.CallToolRequest{ Arguments: map[string]interface{}{ "channel_types": "im", }, }) ``` -------------------------------- ### Configure slack-mcp-server with XOXP Token using Docker Source: https://github.com/korotovsky/slack-mcp-server/blob/master/docs/03-configuration-and-usage.md Run the slack-mcp-server using Docker with an XOXP token and stdio transport. This method is suitable for environments where Docker is available. ```json { "mcpServers": { "slack": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "SLACK_MCP_XOXP_TOKEN", "ghcr.io/korotovsky/slack-mcp-server", "--transport", "stdio" ], "env": { "SLACK_MCP_XOXP_TOKEN": "xoxp-..." } } } } ``` -------------------------------- ### Enable File Access Tool Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/configuration.md Enable the `attachment_get_data` tool for file downloads by setting `SLACK_MCP_ATTACHMENT_TOOL` to `true`, `1`, or `yes`. ```bash # Enable file access tool export SLACK_MCP_ATTACHMENT_TOOL=true ``` -------------------------------- ### Configure Server Transport and Network Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/configuration.md Set the server transport protocol (stdio, sse, http), hostname, and port. SSE/HTTP require host and port configuration. ```bash # Stdio transport (default, for local use) export SLACK_MCP_TRANSPORT=stdio ``` ```bash # SSE transport on all interfaces export SLACK_MCP_HOST=0.0.0.0 export SLACK_MCP_PORT=13080 ``` ```bash # HTTP transport with API key protection export SLACK_MCP_TRANSPORT=http export SLACK_MCP_API_KEY=secret-key-12345 ``` -------------------------------- ### Update Saved Item: Set Reminder Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/saved.md Use this snippet to set a reminder for a saved item. Provide the item_id, ts, and the Unix timestamp for the due date. The example uses a timestamp for January 15, 2024. ```go result, err := handler.SavedUpdateHandler(ctx, mcp.CallToolRequest{ Arguments: map[string]interface{}{ "item_id": "D0987654321", "ts": "1234567890.123456", "date_due": 1705276800, }, }) ``` -------------------------------- ### New ApiProvider Constructor Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/provider.md Initializes a new ApiProvider instance. This provider abstracts communication with Slack, managing authentication, caching, and rate limiting. ```APIDOC ## New ApiProvider Constructor ### Description Initializes a new ApiProvider instance. This provider abstracts communication with Slack, managing authentication, caching, and rate limiting. ### Constructor Signature ```go func New(transport string, logger *zap.Logger) *ApiProvider ``` ### Parameters #### Path Parameters - **transport** (string) - Required - Transport type: `stdio`, `sse`, or `http` - **logger** (*zap.Logger) - Required - Structured logger for debug/error logging ### Returns - **ApiProvider** (*ApiProvider) - Initialized provider instance ### Throws - Panic if authentication fails (invalid token) - Error if cache initialization fails ### Example ```go provider := provider.New("stdio", logger) deffer provider.SkipCache() // optional: skip cache loading for speed ``` ``` -------------------------------- ### Create User Group with Custom Handle and Channels Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/usergroups.md Create a user group specifying a custom handle and a comma-separated list of channel IDs for default highlighted channels. Requires `usergroups:write` scope. ```go result, err := handler.UsergroupsCreateHandler(ctx, mcp.CallToolRequest{ Arguments: map[string]interface{}{ "name": "DevOps Team", "handle": "devops-eng", "description": "DevOps and infrastructure", "channels": "C1234567890,C0987654321", }, }) ``` -------------------------------- ### Get User's Channels and DMs Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/channels.md Use ChannelsMeHandler to retrieve public channels, private channels, direct messages (IMs), and multi-party direct messages (MPIMs) the current user is a member of. Specify channel types and an optional limit for the number of results. ```go result, err := channelsHandler.ChannelsMeHandler(ctx, mcp.CallToolRequest{ Arguments: map[string]interface{}{ "channel_types": "public_channel,private_channel,im,mpim", "limit": 100, }, }) ``` -------------------------------- ### Configure xoxc and xoxd Tokens Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/configuration.md Use these environment variables for browser session authentication. Tokens are extracted from Slack web client cookies. ```bash SLACK_MCP_XOXC_TOKEN=xoxc-12345... SLACK_MCP_XOXD_TOKEN=xoxd-abcde... ``` -------------------------------- ### Verify Tool Enablement Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/errors.md Ensure that a specific tool is enabled before attempting to use it. If disabled, return an error suggesting how to enable it via environment variables. ```go if !isToolEnabled("conversations_add_message") { return fmt.Errorf("tool disabled; set SLACK_MCP_ADD_MESSAGE_TOOL environment variable") } ``` -------------------------------- ### Initialize UsergroupsHandler Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/usergroups.md Instantiate the UsergroupsHandler with an API provider and a logger. ```go provider := provider.New("stdio", logger) handler := handler.NewUsergroupsHandler(provider, logger) ``` -------------------------------- ### ProvideHTTPClient Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/transport.md Creates a pre-configured HTTP client with support for custom TLS, proxy settings, authentication, and user-agent customization. ```APIDOC ## ProvideHTTPClient Creates a pre-configured HTTP client with support for custom TLS, proxy settings, authentication, and user-agent customization. ### Function Signature ```go func ProvideHTTPClient(cookies []*http.Cookie, logger *zap.Logger) *http.Client ``` ### Parameters #### Path Parameters - **cookies** (`[]*http.Cookie`) - Optional - A slice of HTTP cookies, typically used for authentication tokens like `xoxc` or `xoxd`. - **logger** (`*zap.Logger`) - Required - A structured logger for capturing client-related events. ### Returns - `*http.Client` - A configured HTTP client instance. ### Behavior - Automatically detects authentication methods from the environment. - Applies custom TLS settings if the `SLACK_MCP_CUSTOM_TLS` environment variable is set to `true`. - Configures proxy settings if the `SLACK_MCP_PROXY` environment variable is set. - Injects a custom CA certificate if `SLACK_MCP_SERVER_CA` is set. - Sets the `User-Agent` header based on the `SLACK_MCP_USER_AGENT` environment variable or a default value. - Supports HTTPToolkit integration when `SLACK_MCP_SERVER_CA_TOOLKIT` is set. ### Usage Example ```go cookies := []*http.Cookie{ {Name: "d", Value: "xoxd-example-token"}, } client := ProvideHTTPClient(cookies, logger) resp, err := client.Get("https://slack.com/api/auth.test") ``` ``` -------------------------------- ### Enable Reactions Tool Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/configuration.md Enable the `reactions_add` and `reactions_remove` tools by setting `SLACK_MCP_REACTION_TOOL`. The configuration syntax for channel access is the same as for message posting tools. ```bash # Enable reactions tool globally export SLACK_MCP_REACTION_TOOL=true ``` -------------------------------- ### Access Channels as a Resource Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/channels.md Use ChannelsResource to fetch the channels directory as a resource, suitable for resource-based access patterns. The URI must be in the format `slack:///channels`. ```go result, err := channelsHandler.ChannelsResource(ctx, mcp.ReadResourceRequest{ URI: "slack://my-workspace/channels", }) ``` -------------------------------- ### IsReady Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/provider.md Checks if both the users and channels caches have been successfully loaded. ```APIDOC ## IsReady ### Description Checks if both the users and channels caches have been successfully loaded. ### Method Signature ```go func (ap *ApiProvider) IsReady() (bool, error) ``` ### Returns - **bool** - true if both caches are ready, false if still loading - **error** - any initialization error encountered ### Usage ```go if ready, err := provider.IsReady(); ready { // Both caches loaded, can use name-based lookups } ``` ``` -------------------------------- ### Configure slack-mcp-server with SSE transport for Windows using npx Source: https://github.com/korotovsky/slack-mcp-server/blob/master/docs/03-configuration-and-usage.md This configuration is for running the slack-mcp-server with SSE transport on Windows using npx. It specifies the full path to npx.cmd. ```json { "mcpServers": { "slack": { "command": "C:\\Progra~1\\nodejs\\npx.cmd", "args": [ "-y", "mcp-remote", "https://x.y.z.q:3001/sse", "--header", "Authorization: Bearer ${SLACK_MCP_API_KEY}" ], "env": { "SLACK_MCP_API_KEY": "my-$$e-$ecret" } } } } ``` -------------------------------- ### Skip Cache Loading on Startup Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/configuration.md Use the --no-cache flag to prevent the server from loading cached data on startup. This can speed up initialization, especially in development or testing scenarios. ```bash slack-mcp-server --no-cache ``` -------------------------------- ### ServeHTTP Source: https://github.com/korotovsky/slack-mcp-server/blob/master/_autodocs/api-reference/server.md Runs the MCP server with a standard HTTP transport for request/response interactions. It listens on the specified address and returns an HTTP server instance. ```APIDOC ## ServeHTTP ### Description Runs the MCP server with a standard HTTP transport for request/response interactions. It listens on the specified address and returns an HTTP server instance. ### Signature ```go func (mcp *MCPServer) ServeHTTP(addr string) *http.Server ``` ### Parameters #### Path Parameters - **addr** (string) - Listen address (e.g., `:13080`) ### Returns - ***http.Server** - HTTP server instance ### Usage ```go httpServer := server.ServeHTTP(":13080") if err := httpServer.Start("0.0.0.0:13080"); err != nil { log.Fatal(err) } ``` ### MCP Client Configuration ```json { "transport": "http", "url": "http://127.0.0.1:13080" } ``` ``` -------------------------------- ### Run slack-mcp-server with Docker and stdio transport Source: https://github.com/korotovsky/slack-mcp-server/blob/master/docs/03-configuration-and-usage.md This command pulls the latest slack-mcp-server Docker image and runs it with XOXC and XOXD tokens using stdio transport. Environment variables for tokens must be set. ```bash export SLACK_MCP_XOXC_TOKEN=xoxc-ինչ export SLACK_MCP_XOXD_TOKEN=xoxd-ինչ docker pull ghcr.io/korotovsky/slack-mcp-server:latest docker run -i --rm \ -e SLACK_MCP_XOXC_TOKEN \ -e SLACK_MCP_XOXD_TOKEN \ ghcr.io/korotovsky/slack-mcp-server:latest --transport stdio ```