A serverless system that connects Slack with MCP (Model Context Protocol) servers to enable AI tool interactions through chat.
This project is an AWS Lambda-based system that allows Slack users to interact with various AI tools supporting the MCP protocol through chat conversations. It uses Claude Sonnet 4 as an intermediary to convert natural language requests into appropriate tool calls and provide results in a user-friendly format.
- Slack Event Processing: Real-time processing of Slack messages and mention events
- MCP Server Connection: Communication with MCP servers via SSE (Server-Sent Events)
- AI Model Integration: Integration with Amazon Bedrock's Claude Sonnet 4 model
- Thread Context Awareness: Maintains conversation history for contextual responses
- Real-time Tool Results Display: Formats tool execution results using Slack Block Kit
- Asynchronous Processing: Optimizes response time through gateway-based async message handling
Slack App → API Gateway → slack-mcp-gateway → slack-mcp-client
↓
MCP Server (SSE)
↓
Various Tools
- Role: Receives Slack events, provides immediate response, then asynchronously invokes client function
- Features:
- Solves Slack's 3-second response timeout limitation
- Event relay and load distribution
- Role: Handles main business logic
- Key Features:
- MCP server and SSE connection management
- Conversation processing with Claude model
- Tool execution and result processing
- Slack message formatting and sending
- Thread history management
The following environment variables must be configured in the AWS Lambda functions:
# Slack related
SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_SIGNING_SECRET=your-signing-secret
# MCP server connection
MCP_SSE_SERVER_URL=https://your-mcp-server-url
# AWS region (optional)
AWS_REGION=us-east-1- Create a new app in the Slack API Console
- Add the following scopes:
app_mentions:readchannels:historychat:writeim:readim:write
- Enable Event Subscriptions:
app_mentionmessage.im
- Set Request URL to your API Gateway endpoint
# Grant permissions
chmod +x update_code.sh
# Deploy Lambda functions
./update_code.shslack_sdk: Slack API communicationrequests: HTTP request handlingmcp: MCP protocol implementation
- AWS Lambda (function execution)
- Amazon Bedrock (Claude model access)
- API Gateway (HTTP endpoint provision)
- Invite the bot to a Slack channel or start a DM conversation
- Mention the bot or send a DM:
@your-bot show me the file list - The bot processes the request using MCP tools and returns results
- Continuing conversations within threads maintains previous context
- The bot analyzes conversation history to use appropriate tools contextually
- Primary support for English
- Automatically adjusts response language to match user query language
When new tools are added to the MCP server, Claude will automatically recognize and use them. No client code modifications are required.
Customize how tool results are displayed in Slack by modifying the _format_tool_result_for_slack function in slack_utils.py.
The system handles the following error scenarios:
- MCP server connection failures
- Slack API call failures
- Claude model response errors
- Tool execution errors
- Detailed execution logs available through AWS CloudWatch Logs
- Tracking of execution time and error status for each step
- Slack message send success/failure logging
Add your project license information here.
How to contribute to the project:
- Fork and create a feature branch
- Commit your changes
- Create a Pull Request
-
Bot not responding
- Check Slack tokens and permissions
- Review Lambda function logs
- Verify MCP server status
-
Tool execution failures
- Verify MCP_SSE_SERVER_URL environment variable
- Check MCP server connection status
-
Permission errors
- Check AWS IAM role permissions
- Verify Bedrock model access permissions