How korotovsky/slack-mcp-server works
Project Type and Purpose
• This is a standalone backend service written in Go (with helper scripts in Node/NPM for CLI packaging) that implements a Model Context Protocol (MCP) server for Slack.
• It exposes an MCP-compatible endpoint over STDIO or Server-Sent Events (SSE), translates MCP “tool” calls into Slack API calls, caches workspace metadata, and returns structured responses to any MCP client.
File Structure Analysis
• Top-level:
• cmd/slack-mcp-server: the entry point (main.go).
• pkg/: the core libraries organized by concern—handler, transport, provider, limiter, text, server, version, test utilities.
• Dockerfile & docker-compose*.yml: containerization and orchestration for dev, test, production, and toolkit debugging.
• npm/: cross-platform CLI wrappers for distributing the Go binary via NPM.
• build/: prebuilt extension artifacts (DXT), CI/CD packaging.
• Patterns & Config:
• MVC-style separation: transport → server core → handler → provider → external Slack.
• Rate limiting (pkg/limiter) inserted before Slack calls.
• Caching layers on local filesystem for users / channels (configurable via ENV).
• CI pipelines (.github/workflows) for unit tests, integration tests, and container releases.
README Insights
• Describes supported transports (Stdio, SSE), authentication modes (stealth vs OAuth), features (history fetch, search, posting, caching).
• Environment variables govern ports, host binding, TLS, proxy, caching paths, log levels, and feature toggles.
• Two special “slack://” directory endpoints for channels and users.
a. Main Components
1. MCP Client(s): any tool speaking MCP (via STDIO or SSE)
2. Transport Layer:
• STDIO transport adapter
• SSE transport adapter
3. Server Core (pkg/server):
• Authentication (pkg/server/auth)
• Request dispatcher
4. Rate Limiter (pkg/limiter)
5. Handler Layer (pkg/handler): maps MCP tools to application logic
6. Text Processor (pkg/text): formatting, parsing
7. Provider Layer (pkg/provider/edge + api.go): Slack edge client
8. Cache Store (local JSON files): users cache, channels cache
9. External Service: Slack Web API
10. CLI / Packaging: Docker container, NPM published binaries
b. Relationships & Data Flow
• Slack API responses flow back through Provider → Handler → Server Core → Transport → MCP Client.
• Caching: read-before-API-call from local JSON caches, write-after-API-call to caches.
c. Architectural Patterns
• Layered architecture: separation of transport, business logic, and external integration.
• Adapter pattern for transports and provider.
• Optional feature toggles via ENV variables (Strategy/Feature Toggle).
• Rate-limiting middleware integrated as a cross-cutting concern.
d. Key Technologies
• Go modules (go.mod)
• Docker, docker-compose
• NPM + cross-platform binaries
• GitHub Actions for CI/CD
• SSE & STDIO protocols for real-time and CLI use
• Local JSON files for O(1) cache lookups