Skip to main content
Glama

post_message

Send messages to Slack channels to communicate updates, share information, or coordinate team activities directly from the MCP server.

Instructions

Post a message to a Slack channel.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channel_idYes
textYes

Implementation Reference

  • main.py:145-156 (handler)
    The handler function for the 'post_message' tool. It is registered via @mcp.tool() decorator and implements posting a message to a Slack channel by calling the Slack chat.postMessage API using the make_slack_request helper. Input schema derived from type hints: channel_id (str), text (str).
    @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 function used by post_message (and other tools) to make authenticated HTTP requests to the Slack Web 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

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