Skip to main content
Glama

Slack MCP Server

by hyunol7
slack_mcp_server.py3.19 kB
""" FastMCP Slack 서버 구현 """ from typing import Any, Dict from fastmcp import FastMCP from slack_api import SlackClient # FastMCP 서버 초기화 mcp = FastMCP("Slack MCP Server") # Slack 클라이언트 초기화 (전역 인스턴스) slack_client = SlackClient() @mcp.tool() def send_slack_message(channel: str, text: str) -> Dict[str, Any]: """ 지정된 Slack 채널에 메시지를 전송합니다. Args: channel: 채널 ID text: 테스트 test Returns: Dict containing success status and message details """ return slack_client.send_message(channel, text) @mcp.tool() def get_slack_channels() -> Dict[str, Any]: """ 접근 가능한 모든 Slack 채널 목록을 조회합니다. Returns: Dict containing list of channels with their details - id: 채널 ID - name: 채널 이름름 - is_private: 공개/비공개 여부 - is_member: 멤버십 상태 - member_count: 멤버 수 - purpose: 채널 목적 - topic: 채널 주제 """ return slack_client.get_channels() @mcp.tool() def get_slack_channel_history(channel_id: str, limit: int = 10) -> Dict[str, Any]: """ 지정된 채널의 최근 메시지 히스토리를 조회합니다. Args: channel_id: 채널 ID limit: 10 Returns: Dict containing message history - messages: 메시지 목록 (내용, 작성자, 타임스탬프 포함) - channel_id: 채널 ID - message_count: 10 """ return slack_client.get_channel_history(channel_id, limit) @mcp.tool() def send_slack_direct_message(user_id: str, text: str) -> Dict[str, Any]: """ 특정 사용자에게 1:1 다이렉트 메시지를 전송합니다. Args: user_id: 메시지를 받을 사용자의 ID text: 전송할 메시지 내용 (UTF-8 한글 지원) Returns: Dict containing success status and message details """ return slack_client.send_direct_message(user_id, text) @mcp.tool() def get_slack_users() -> Dict[str, Any]: """ 워크스페이스의 사용자 목록을 조회합니다. (다이렉트 메시지 전송 시 참고용) Returns: Dict containing list of users - id: 사용자 ID - name: 사용자 이름 - real_name: 실제 이름 - display_name: 표시 이름 - email: 이메일 주소 - is_admin: 관리자 여부 - is_owner: 소유자 여부 """ return slack_client.get_users() def main(): """MCP 서버 실행""" print("Slack MCP 서버를 시작합니다...") print("사용 가능한 도구:") print(" 1. send_slack_message - 채널에 메시지 전송") print(" 2. get_slack_channels - 채널 목록 조회") print(" 3. get_slack_channel_history - 채널 메시지 히스토리 조회") print(" 4. send_slack_direct_message - 다이렉트 메시지 전송") print(" 5. get_slack_users - 사용자 목록 조회") print("서버가 준비되었습니다!") mcp.run() if __name__ == "__main__": main()

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hyunol7/slack-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server