27 Commits

Author SHA1 Message Date
Paymahn Moghadasian 6a972a1f05 feat: add slack-cli, a no-daemon CLI over the slack-mcp-server engine
Turn the forked slack-mcp-server into a CLI so running many agents no
longer means one resident MCP process each. Every command is a
short-lived process that reads the shared on-disk cache.

- rename module to github.com/paymog/slack-cli (go install/homebrew/ldflags)
- internal/toolcall: invoke the upstream tool handlers in-process; the only
  mcp-go coupling lives here, so pkg/handler and pkg/provider are reused
  byte-for-byte (clean upstream merges, fork-and-extend)
- internal/{cli,cmds,config,credstore,runtime,output}: cobra command tree,
  keyring-backed credential profiles, provider bootstrap, result printing
- 21 tools as subcommands (channels, conversations, users, usergroups,
  saved, reactions, attachments, cache); write tools keep their env gating
- goreleaser + homebrew release workflow; ships a skills/slack-cli skill
- unit tests for config/credstore/toolcall; MCP server still builds

The MCP server (cmd/slack-mcp-server) is kept intact.
2026-06-26 11:04:05 -05:00
Francis J. Lacoste 6e93a40174 fix: address PR #225 review feedback for SWR cache
- Restore IsReady() polling loop before ServeStdio() to fix cold-start
  regression where tool calls fail for 60-90s on first run (no cache)
- Add fetchUsersMu/fetchChannelsMu mutexes to serialize fetchAndStore*
  calls, preventing race between ForceRefresh and background refresh
- Use atomic file writes (temp + os.Rename) to prevent corrupt cache
  files on crash
- Guard against empty API results overwriting valid cache
- Guard against empty cache files being treated as valid data
- Fix typo: TestRefreshingFlagPreventsConucrrentRefreshes → Concurrent

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-14 21:44:44 +02:00
Francis J. Lacoste f16fb0fe2b feat: stale-while-revalidate cache for large Slack workspaces
On large workspaces (41K+ users), the server blocks for ~90 seconds
during startup while fetching all users/channels from the Slack API,
exceeding MCP client connection timeouts.

Changes:
- Load expired cache files immediately, mark server ready, then refresh
  in background via goroutine (stale-while-revalidate pattern)
- Convert usersReady/channelsReady to atomic.Bool for race-free reads
- Add refreshingUsers/refreshingChannels atomic.Bool to coalesce
  concurrent background refreshes via CompareAndSwap
- Remove stdio IsReady() polling loop (no longer needed)
- Increase default cache TTL from 1h to 24h
- Document SLACK_MCP_CACHE_TTL and SLACK_MCP_MIN_REFRESH_INTERVAL
  env vars in docs/03-configuration-and-usage.md

Fixes startup timeout on large workspaces. Server now starts in under
1 second regardless of workspace size when a cache file exists.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-14 21:44:44 +02:00
Mustafa Mujahid 8256b2f343 fix: non-blocking stdio startup and --no-cache flag
Remove the busy-wait loop that blocks the stdio transport from
responding to MCP initialize until users/channels caches are fully
loaded. On large workspaces this causes MCP clients with connection
timeouts (e.g. 30-60s) to drop the server.

Changes:
- stdio transport now starts the MCP server immediately, matching the
  existing SSE/HTTP behavior. Caches continue loading in a background
  goroutine. Tool calls made before caches are ready return a graceful
  "not ready" error (already handled by the error recovery middleware).
- Add --no-cache CLI flag to skip cache loading entirely for
  environments that only use channel/user IDs (never #name or @name
  lookups). This makes startup instant regardless of workspace size.
- Add SkipCache() method on ApiProvider that marks both caches as
  ready without loading data.

Fixes #271
2026-04-10 15:39:36 +02:00
sspiridonov d17eb94fb7 chore: remove redundant comments
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 15:22:45 +01:00
sspiridonov d06ce63995 feat: add tool name constants and validation for --enabled-tools
- Add Tool* constants to avoid magic strings in tool registration
- Add ValidToolNames slice and ValidateEnabledTools function
- Validate tool names at startup, fail with helpful error message
- Update tests to use constants

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 15:19:45 +01:00
sspiridonov cc489e8379 refactor: simplify --enabled-tools to only control registration
Simplify the logic so that:
- ENABLED_TOOLS only controls which tools are registered/exposed via MCP
- Empty ENABLED_TOOLS = all tools registered (no filtering)
- Runtime permissions (ADD_MESSAGE_TOOL, REACTION_TOOL, ATTACHMENT_TOOL)
  are always enforced in handlers regardless of ENABLED_TOOLS

This keeps the two concerns separate:
1. Registration/visibility (ENABLED_TOOLS)
2. Runtime permissions (individual tool env vars)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 14:50:54 +01:00
sspiridonov 274a156282 feat: add --enabled-tools flag to filter available MCP tools
Add a new CLI flag `--enabled-tools` (alias `-e`) and environment variable
`SLACK_MCP_ENABLED_TOOLS` to allow users to specify which MCP tools should
be loaded. This provides flexibility to limit tool exposure based on
security requirements or use case.

- If not set, all tools are enabled (backward compatible)
- Accepts comma-separated tool names
- CLI flag takes precedence over environment variable

Available tools: conversations_history, conversations_replies,
conversations_add_message, reactions_add, reactions_remove,
attachment_get_data, conversations_search_messages, channels_list

Example usage:
  slack-mcp-server --enabled-tools=conversations_history,channels_list
  SLACK_MCP_ENABLED_TOOLS=channels_list slack-mcp-server

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 23:09:35 +01:00
Bhaskoro Muthohar cd36f5edff fix: wait for cache to be ready before serving stdio requests
Fixes #135
2026-01-20 15:18:33 +07:00
graf2242 ae31b32be7 Implement Streamable HTTP MCP transport 2025-09-24 11:47:00 +03:00
clement-izard 84ee919833 Removed self-explaining comments 2025-07-25 15:06:36 +02:00
clement-izard ad0ad59152 Improve fix: Make logging transport-aware for better SSE compatibility
Based on maintainer feedback, updated the logging fix to be transport-aware:

- stdio transport: Logs to stderr (fixes JSON-RPC protocol conflicts)
- sse transport: Logs to stdout (preserves existing behavior)

This approach addresses the original stdio compatibility issue while
maintaining backward compatibility for SSE users who may rely on
stdout logging for debugging and monitoring.

Changes:
- Modified newLogger() to accept transport parameter
- Added conditional outputPath logic based on transport type
- Updated main() to pass transport to newLogger()

Tested both transport modes successfully.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-25 15:06:36 +02:00
clement-izard 857bde4689 Fix: Redirect console logs to stderr for stdio transport compatibility
The server was outputting structured JSON logs to stdout when using stdio
transport, breaking JSON-RPC 2.0 protocol compliance with MCP clients like
Claude Code.

Root cause: zap logger configured with OutputPaths: ["stdout"] was sending
all diagnostic logs to stdout, interfering with JSON-RPC messages that MCP
clients expect exclusively on stdout.

Solution: Redirect all console logs to stderr while preserving stdout
exclusively for JSON-RPC protocol communication.

Fixes compatibility with all MCP clients using stdio transport including
Claude Code CLI, MCP Inspector, and other implementations.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-25 15:06:36 +02:00
Dmitrii Korotovskii 98214bdd84 fixes log output 2025-07-20 13:54:11 +02:00
Dmitrii Korotovskii 74ec20e202 reduce logs 2025-07-20 13:46:30 +02:00
Dmitrii Korotovskii a9fbd54fa9 Improve logging 2025-07-20 09:46:30 +02:00
Dmitrii Korotovskii 4ed6f91f0a Added zap logger 2025-07-20 00:52:03 +02:00
Dmitrii Korotovskii d306814577 added authentication for resources 2025-07-16 10:42:07 +02:00
Dmitrii Korotovskii 4acad7ff06 added authentication for resources 2025-07-16 10:40:42 +02:00
Dmitrii Korotovskii e6f17b5e60 Improved date parsing, adding tests 2025-07-14 13:34:34 +02:00
Dmitrii Korotovskii 7a07c425f0 Update docs 2025-07-12 17:09:26 +02:00
Dmitrii Korotovskii b5ea15ee30 Added logic to specify negated channels to enable all and exclude some 2025-07-09 09:52:20 +02:00
Dmitrii Korotovskii 4983e1098b add logic to improve fetching channels list on slack workspaces with enterprise setting 2025-06-29 22:45:50 +02:00
HeroSizy e2ab87fdf1 feat: add SLACK_MCP_XOXP_TOKEN user OAuth authentication support
- Add support for User OAuth tokens (xoxp-) as alternative to session-based auth
- Maintain backward compatibility with existing XOXC/XOXD token authentication
- XOXP tokens take priority when both authentication methods are available
- Update demo mode detection to support both authentication methods
- Add comprehensive documentation for User OAuth token setup and configuration
- Include configuration examples for both npx and Docker deployments

This enhancement provides a more secure authentication option that doesn't
require browser session extraction while preserving all existing functionality.
2025-06-24 16:20:02 +08:00
Dmitrii Korotovskii 0ce5a61ba0 channels maps to resolve conversations.list by channel name instead of id 2025-06-16 20:27:52 +02:00
Dmitrii Korotovskii 0958f563f0 channels_list tool accepts channel_types now as a plain comma-separated string to simplify interface and tool discovery instead of complex array struct, added extra validations 2025-06-06 10:24:33 +02:00
Dmitrii Korotovskii 6bfa56fccf changed project layout, prepare for npm releases 2025-04-23 14:18:18 +02:00