- Explore MCP Servers
- slack-mcp-agent
Slack Mcp Agent
What is Slack Mcp Agent
Slack-MCP-Agent is an agent that dynamically invokes Model Context Protocol (MCP) Servers using Slack as a front-end bot. It processes user requests sent via Slack mentions and integrates multiple MCP Servers and custom Function Tools to execute natural language commands flexibly.
Use cases
Use cases include retrieving data such as stock prices from external sources, logging information into Notion databases, and providing real-time updates on task progress within Slack threads.
How to use
To use Slack-MCP-Agent, mention the agent in a Slack message with your request. The agent will process the message, potentially invoke different MCP Servers, and return the results back to Slack. Ensure that you have a Slack app with the appropriate tokens and that the MCP Servers are operational.
Key features
Key features include integration with Slack for triggering the agent via mentions, seamless integration with various MCP Servers (like Slack MCP Server, Perplexity MCP Server, and Notion MCP Server), a set of Function Tools for specific tasks, and real-time progress updates posted to Slack threads.
Where to use
Slack-MCP-Agent can be used in collaborative environments where teams utilize Slack for communication and need to access information from various sources like databases, AI search engines, and documentation tools.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Slack Mcp Agent
Slack-MCP-Agent is an agent that dynamically invokes Model Context Protocol (MCP) Servers using Slack as a front-end bot. It processes user requests sent via Slack mentions and integrates multiple MCP Servers and custom Function Tools to execute natural language commands flexibly.
Use cases
Use cases include retrieving data such as stock prices from external sources, logging information into Notion databases, and providing real-time updates on task progress within Slack threads.
How to use
To use Slack-MCP-Agent, mention the agent in a Slack message with your request. The agent will process the message, potentially invoke different MCP Servers, and return the results back to Slack. Ensure that you have a Slack app with the appropriate tokens and that the MCP Servers are operational.
Key features
Key features include integration with Slack for triggering the agent via mentions, seamless integration with various MCP Servers (like Slack MCP Server, Perplexity MCP Server, and Notion MCP Server), a set of Function Tools for specific tasks, and real-time progress updates posted to Slack threads.
Where to use
Slack-MCP-Agent can be used in collaborative environments where teams utilize Slack for communication and need to access information from various sources like databases, AI search engines, and documentation tools.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
Slack-MCP-Agent
概要
Slack の Bot をフロントエンドとして、Model Context Protocol (MCP) Server をツールとして動的に呼び出す Agent です。
ユーザーが Slack のメンションでリクエストを送信すると、OpenAI Agent SDK の Agent Loop によって複数の MCP Server(Slack, Notion, Perplexity など)および独自の Function Tool を連携させ、自然言語のままの指示を柔軟に実行します。
動作例
Slackでメッセージ付きでAgentをメンションすると、Agentが起動し、メッセージを処理します。
LLMにはGPT-4.1-miniを利用しているため、モデル単体では先週のダウ平均株価を知る方法はありません。
Agentは一度ユーザーに時間がかかることを伝え、Perplexity MCP Serverを呼び出し、先週のダウ平均株価を取得します。
Agentは取得した内容をまとめ、再度Slackに投稿します。

再びユーザーからメンションされたAgentは、Slack MCP Serverを呼び出し、スレッド内の過去のメッセージを把握し、Notion MCP Serverを呼び出し、Notionのデータベースに先週のダウ平均株価を記録します。

主な特徴
- Slack 連携:
app_mention
イベントをトリガーに Agent を起動 - MCP Server 統合:
- Slack MCP Server:スレッド返信・進捗共有
- Perplexity-Ask MCP Server: AI 検索エンジン
- Notion MCP Server: ドキュメント参照
- Function Tool:
- 現在時刻取得 (
clock
) - 文字列長取得 (
get_str_lenth
) - 標準出力/標準エラー読み込み (
read_stdout
,read_stderr
)
- 現在時刻取得 (
- リアルタイム進捗:Agent Loop の各ステップ結果を Slack スレッドに都度投稿
アーキテクチャ
graph LR Slack -->|app_mention| Agent["Agent(app.py)"] Agent --> FunctionTools["Function Tools (tools.py)"] Agent --> MCPServers["MCP Servers (config.jsonで定義)"] MCPServers --> SlackMCP["Slack-MCP-Server (stdio)"] MCPServers --> PerplexityMCP["Perplexity-Ask MCP-Server"] MCPServers --> NotionMCP["Notion MCP-Server"]
- app.py:Slack Bolt + Socket Mode で Bot サーバーを起動
- agents:OpenAI Agent SDK ベースの Agent 定義
- tools.py:
@function_tool
デコレータで関数をツール化 - utils.py:Slack イベント整形・プロンプト生成ロジック
- config.json:MCP Server 情報・環境変数を定義
前提条件
- Python 3.13 環境
- Slack アプリ(Bot Token, App Token)を取得済み
- MCP Server(Slack, Perplexity, Notion など)が起動可能
- 以下のディレクトリ/ファイルを用意
config.json
(下記例を参照)
起動方法
config.jsonの作成とSlack Botのインストール
config.jsonのサンプルをコピーして、config.json
を作成してください。
最低限SlackのMCP Serverを入れれば動作するので、好みに応じて追加・削除してください
Slack BotをSlack Workspaceにインストールする方法はBolt入門ガイドを参考にすること。
またSlack MCP Server用にも追加で権限が必要なので以下のようにまとめて列挙する(抜けがあったらごめんなさい)。
Slack Botが反応しないことがあれば、Bolt入門ガイドを丁寧に見直すことをお勧めします(実体験)。
- OAuth & Permission -> Bot Token Scopes -> Add an Oauth Scope で以下の権限を付与する
chat:write
’channels:history
channels:read
reactions:write
users:read
users.profile:read
- OAtuh & Permission -> Install App to Workspace -> WorkspaceにBotをインストールする
- インストール後に OAuth & Permissions -> Bot User OAuth Access Token ->
SLACK_BOT_TOKEN
を入手 - Socket Mode -> ON
- Basic Information -> App Level Token -> Token & Scope Generation ->
SLACK_APP_TOKEN
を入手connections:write
- Event Subscription -> ON
message.channels
app_mention
スクリプトの実行
初期化
$ git clone https://github.com/yutashx/slack-mcp-agent
$ cd slack-mcp-agent
$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip install -r requirements.txt
Slack BotとAgentの起動
$ CONFIG_PATH=./config.json python3 ./src/app.py
DBの初期化
SQLiteを使います
以下のschemaを利用して、DBを初期化します
$ mkdir db
$ sqlite3 db/app.db < schema.sql
-- Slackの会話データを保存するテーブル
CREATE TABLE conversation (
id INTEGER PRIMARY KEY AUTOINCREMENT,
thread_id TEXT NOT NULL,
user_id TEXT NOT NULL,
slack_channel_id TEXT NOT NULL,
messages TEXT NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
-- ユーザー情報を保存するテーブル
CREATE TABLE user (
id INTEGER PRIMARY KEY AUTOINCREMENT,
slack_user_id TEXT NOT NULL,
conversation_count INTEGER NOT NULL DEFAULT 0,
user_name TEXT NOT NULL,
user_email TEXT NOT NULL,
user_role TEXT NOT NULL,
user_department TEXT NOT NULL,
user_position TEXT NOT NULL,
user_birthday TEXT NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
-- Agentが自由に利用できるメモリー
CREATE TABLE agent_memory (
id INTEGER PRIMARY KEY AUTOINCREMENT,
memory_id TEXT NOT NULL,
memory_name TEXT NOT NULL,
memory_description TEXT NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.