Skip to main content
Glama

post_message

Send messages to Slack channels to communicate updates, share information, or coordinate with team members directly from your application.

Instructions

Post a message to a Slack channel.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channel_idYes
textYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • main.py:145-156 (handler)
    The handler function for the 'post_message' tool, which posts a message to a specified Slack channel using the Slack chat.postMessage API. Registered via @mcp.tool() decorator.
    @mcp.tool()
    async def post_message(channel_id: str, text: str) -> str:
        """Post a message to a Slack channel."""
        params = {
            "channel": channel_id,
            "text": text
        }
        data = await make_slack_request("chat.postMessage", params)
        if data and data.get("ok"):
            return "✅ Message posted successfully!"
        return f"❌ Failed to post message. Error: {data.get('error', 'Unknown')}"
  • main.py:19-33 (helper)
    Helper utility function used by post_message to make authenticated HTTP requests to the Slack API.
    async def make_slack_request(method: str, params: dict[str, Any] | None = None) -> dict[str, Any] | None:
        """Make a request to the Slack Web API with proper error handling."""
        headers = {
            "Authorization": f"Bearer {SLACK_TOKEN}",
            "Content-Type": "application/x-www-form-urlencoded"
        }
        async with httpx.AsyncClient() as client:
            try:
                response = await client.post(f"{SLACK_API_BASE}/{method}", data=params, headers=headers, timeout=10.0)
                response.raise_for_status()
                return response.json()
            except Exception as e:
                print(f"Slack API error: {e}")
                return None

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Latest Blog Posts

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/Abu-BakarYasir/my_slack_mcp'

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