slack-patron-mcp

slack-patron-mcp

Enables querying Slack message history via slack-patron API, allowing Claude to list channels, retrieve channel messages with pagination and time range, and fetch thread replies.

Category
Visit Server

README

slack-patron-mcp

slack-patron (https://github.com/tsg-ut/slack-patron) のSlackメッセージ履歴APIをClaudeから利用するためのリモートMCPサーバー。

概要

  • トランスポート: Streamable HTTP (stateless)
  • 認証: Bearer token (MCP_SERVER_AUTH_TOKEN)
  • 上流API: SLACK_PATRON_BASE_URL 環境変数で設定

利用可能なツール

ツール名 説明
list_channels ワークスペースの全チャンネル一覧を取得
get_channel_messages チャンネルのメッセージ履歴を取得 (時刻範囲・ページネーション対応)
get_thread_replies スレッドの返信一覧を取得

get_channel_messages パラメータ

パラメータ 必須 説明
channel string チャンネルID (C01234567) またはチャンネル名 (general, #general)
limit number - 取得件数 (1-200, デフォルト50)
oldest string - 開始タイムスタンプ (例: 1700000000.000000)
latest string - 終了タイムスタンプ
cursor string - ページネーションカーソル (前回レスポンスから取得)

get_thread_replies パラメータ

パラメータ 必須 説明
channel string チャンネルID
thread_ts string 親メッセージのタイムスタンプ
limit number - 取得件数 (1-200, デフォルト50)
cursor string - ページネーションカーソル

セットアップ

必要な環境変数

変数名 説明
MCP_SERVER_AUTH_TOKEN Claudeがこのサーバーに接続する際のBearerトークン
SLACK_PATRON_API_TOKEN slack-patronの上流APIへのBearerトークン
SLACK_PATRON_BASE_URL slack-patron上流APIのベースURL (末尾スラッシュなし)
PORT サーバーポート (デフォルト: 29112)

ローカル開発

# 依存関係インストール
npm install

# 環境変数設定
cp .env.example .env
# .env を編集して実際の値を設定

# 開発サーバー起動 (ホットリロード付き)
npm run dev

# ビルド
npm run build

# テスト
npm test

Nginx設定

# 設定ファイルをコピー (nginx/ ディレクトリは .gitignore 対象のため各自作成)
sudo cp nginx/your-vhost-config /etc/nginx/sites-available/

# シンボリックリンク作成
sudo ln -s /etc/nginx/sites-available/your-vhost-config \
           /etc/nginx/sites-enabled/your-vhost-config

# 設定確認と再読み込み
sudo nginx -t && sudo systemctl reload nginx

Claude カスタムコネクタ登録方法

Claude.ai または Claude Code で以下のように設定する:

  1. MCP サーバーの設定を開く
  2. 「カスタムコネクタを追加」を選択
  3. 以下を入力:
    • URL: https://your-server.example.com/mcp
    • 認証タイプ: Bearer Token
    • トークン: .envMCP_SERVER_AUTH_TOKEN の値

Claude Code の場合 (~/.claude/settings.json):

{
  "mcpServers": {
    "slack-patron": {
      "type": "http",
      "url": "https://your-server.example.com/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_MCP_SERVER_AUTH_TOKEN"
      }
    }
  }
}

動作確認 curl コマンド

MCP の Streamable HTTP トランスポートでは Accept: application/json, text/event-stream ヘッダーが必須です (Claude クライアントは自動付与するが、curl では明示指定が必要)。

export TOKEN="your-mcp-server-auth-token"
export BASE="https://your-server.example.com"
# MCP リクエスト共通ヘッダー
MCP_HEADERS=('-H' 'Content-Type: application/json' '-H' 'Accept: application/json, text/event-stream')

# ヘルスチェック (認証不要)
curl "${BASE}/health"

# 認証失敗の確認
curl -X POST "${BASE}/mcp" \
  "${MCP_HEADERS[@]}" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
# → 401 Unauthorized

# ツール一覧
curl -X POST "${BASE}/mcp" \
  -H "Authorization: Bearer ${TOKEN}" \
  "${MCP_HEADERS[@]}" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

# チャンネル一覧取得
curl -X POST "${BASE}/mcp" \
  -H "Authorization: Bearer ${TOKEN}" \
  "${MCP_HEADERS[@]}" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"list_channels","arguments":{}}}'

# メッセージ取得 (チャンネル名指定)
curl -X POST "${BASE}/mcp" \
  -H "Authorization: Bearer ${TOKEN}" \
  "${MCP_HEADERS[@]}" \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"get_channel_messages","arguments":{"channel":"general","limit":10}}}'

# スレッド返信取得
curl -X POST "${BASE}/mcp" \
  -H "Authorization: Bearer ${TOKEN}" \
  "${MCP_HEADERS[@]}" \
  -d '{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"get_thread_replies","arguments":{"channel":"C01234567","thread_ts":"1700000000.123456"}}}'

セキュリティ

  • 全シークレットは環境変数経由で管理 (コードにハードコードしない)
  • MCP認証はBearerトークン + タイミング安全比較 (crypto.timingSafeEqual)
  • ログにトークンやメッセージ内容を出力しない
  • 上流APIエラー時はHTTPステータスコードのみ通知 (スタックトレース非公開)
  • slack-patronへのリクエストは常に limit を指定し大量取得を防止
  • 書き込み系操作は一切実装しない (読み取り専用)

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured