How to integrate Slackbot MCP with Claude Agent SDK

Trusted by
AWS
Glean
Zoom
Airtable

30 min · no commitment · see it on your stack

Slackbot logo
Claude Agent SDK logo
divider

Introduction

This guide walks you through connecting Slackbot to the Claude Agent SDK using the Composio tool router. By the end, you'll have a working Slackbot agent that can send daily standup reminder to #engineering, add a custom emoji for our new logo, archive the #old-projects channel this week through natural language commands.

This guide will help you understand how to give your Claude Agent SDK agent real control over a Slackbot account through Composio's Slackbot MCP server.

Before we dive in, let's take a quick look at the key ideas and tools involved.

Also integrate Slackbot with

TL;DR

Here's what you'll learn:
  • Get and set up your Claude/Anthropic and Composio API keys
  • Install the necessary dependencies
  • Initialize Composio and create a Tool Router session for Slackbot
  • Configure an AI agent that can use Slackbot as a tool
  • Run a live chat session where you can ask the agent to perform Slackbot operations

What is Claude Agent SDK?

The Claude Agent SDK is Anthropic's official framework for building AI agents powered by Claude. It provides a streamlined interface for creating agents with MCP tool support and conversation management.

Key features include:

  • Native MCP Support: Built-in support for Model Context Protocol servers
  • Permission Modes: Control tool execution permissions
  • Streaming Responses: Real-time response streaming for interactive applications
  • Context Manager: Clean async context management for sessions

What is the Slackbot MCP server, and what's possible with it?

The Slackbot MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Slackbot account. It provides structured and secure access to your Slack workspace, so your agent can automate reminders, manage conversations, add emoji reactions, organize channels, and streamline team notifications on your behalf.

  • Automated reminders and notifications: Ask your agent to create timely Slack reminders for you or your team using natural language or custom schedules—never miss a deadline or meeting again.
  • Message reactions and engagement: Let your agent add emoji reactions to messages, star important items, or highlight key conversations to keep team morale up and draw attention where needed.
  • Channel and conversation management: Have your agent archive inactive channels, close direct messages, or organize your workspace by cleaning up conversations—all with just a simple command.
  • Custom emoji and file integration: Direct your agent to add new custom emoji, set emoji aliases, or reference external files (like Google Drive docs) for richer, more expressive communication.
  • Participant and workflow automation: Empower your agent to add call participants, automate onboarding flows, or handle repetitive Slack tasks to keep your team focused and productive.

Supported Tools & Triggers

Tools
Triggers
Add call participantsRegisters new participants added to a Slack call.
Add reaction to messageAdds a specified emoji reaction to an existing message in a Slack channel, identified by its timestamp; does not remove or retrieve reactions.
Add a remote fileAdds a reference to an external file (e.
Archive a Slack conversationArchives a Slack conversation by its ID, rendering it read-only and hidden while retaining history, ideal for cleaning up inactive channels; be aware that some channels (like #general or certain DMs) cannot be archived and this may impact connected integrations.
Close conversation channelCloses a Slack direct message (DM) or multi-person direct message (MPDM) channel, removing it from the user's sidebar without deleting history; this action affects only the calling user's view.
Create a reminderCreates a Slack reminder with specified text and time; time accepts Unix timestamps, seconds from now, or natural language (e.
Create Slack CanvasCreates a new Slack Canvas with the specified title and optional content.
Create channelInitiates a public or private channel-based conversation in a Slack workspace.
Create a Slack user groupCreates a new User Group (often referred to as a subteam) in a Slack workspace.
Customize URL unfurlCustomizes URL previews (unfurling) in a specific Slack message using a URL-encoded JSON in `unfurls` to define custom content or remove existing previews.
Delete Slack CanvasDeletes a Slack Canvas permanently and irreversibly.
Delete a file by IDPermanently deletes an existing file from a Slack workspace using its unique file ID; this action is irreversible and also removes any associated comments or shares.
Delete file commentDeletes a specific comment from a file in Slack; this action is irreversible.
Delete a Slack reminderDeletes an existing Slack reminder, typically when it is no longer relevant or a task is completed; this operation is irreversible.
Delete a message from a chatDeletes a message, identified by its channel ID and timestamp, from a Slack channel, private group, or direct message conversation; the authenticated user or bot must be the original poster.
Delete scheduled chat messageDeletes a pending, unsent scheduled message from the specified Slack channel, identified by its `scheduled_message_id`.
Disable a Slack user groupDisables a specified, currently enabled Slack User Group by its unique ID, effectively archiving it by setting its 'date_delete' timestamp; the group is not permanently deleted and can be re-enabled.
Download Slack fileTool to download Slack file content and convert it to a publicly accessible URL.
Edit Slack CanvasEdits a Slack Canvas with granular control over content placement.
Share file public urlEnables public sharing for an existing Slack file by generating a publicly accessible URL; this action does not create new files.
Enable a user groupEnables a disabled User Group in Slack using its ID, reactivating it for mentions and permissions; this action only changes the enabled status and cannot create new groups or modify other properties.
End a callEnds an ongoing Slack call, identified by its ID (obtained from `calls.
Fetch conversation historyFetches a chronological list of messages and events from a specified Slack conversation, accessible by the authenticated user/bot, with options for pagination and time range filtering.
Fetch item reactionsFetches reactions for a Slack message, file, or file comment.
Retrieve conversation repliesRetrieves replies to a specific parent message in a Slack conversation, using the channel ID and the parent message's timestamp (`ts`).
Fetch team infoFetches comprehensive metadata about the current Slack team, or a specified team if the provided ID is accessible.
Find channelsFind channels in a Slack workspace by any criteria - name, topic, purpose, or description.
Lookup users by emailRetrieves the Slack user object for an active user by their registered email address; requires the users:read.
Find usersFind users in a Slack workspace by any criteria - email, name, display name, or other text.
Fetch bot user informationFetches information for a specified, existing Slack bot user; will not work for regular user accounts or other integration types.
Retrieve call informationRetrieves a point-in-time snapshot of a specific Slack call's information.
Get reminder informationRetrieves detailed information for an existing Slack reminder specified by its ID; this is a read-only operation.
Get remote fileRetrieve information about a remote file added to Slack via the files.
Retrieve team profile detailsRetrieves all profile field definitions for a Slack team, optionally filtered by visibility, to understand the team's profile structure.
Get team DND statusRetrieves a user's current Do Not Disturb status.
Retrieve user presenceRetrieves a Slack user's current real-time presence (e.
Invite users to a Slack channelInvites users to an existing Slack channel using their valid Slack User IDs.
Join conversation by channel idJoins an existing Slack conversation (public channel, private channel, or multi-person direct message) by its ID, if the authenticated user has permission.
Leave conversation channelLeaves a Slack conversation given its channel ID; fails if leaving as the last member of a private channel or if used on a Slack Connect channel.
List all channelsLists conversations available to the user with various filters and search options.
List all usersRetrieves a paginated list of all users with profile details, status, and team memberships in a Slack workspace; data may not be real-time.
List conversationsList conversations (channels/DMs) accessible to a specified user (or the authenticated user if no user ID is provided), respecting shared membership for non-public channels.
List team custom emojisRetrieves all custom emojis for the Slack workspace (image URLs or aliases), not standard Unicode emojis; does not include usage statistics or creation dates.
List Slack filesLists files and their metadata within a Slack workspace, filterable by user, channel, timestamp, or type; returns metadata only, not file content.
List pinned items in a channelRetrieves all messages and files pinned to a specified channel; the caller must have access to this channel.
List remindersLists all reminders with their details for the authenticated Slack user; returns an empty array if no reminders exist (valid state, not an error).
List remote filesRetrieve information about a team's remote files.
List all users in a user groupRetrieves a list of all user IDs within a specified Slack user group, with an option to include users from disabled groups.
List user groupsLists user groups in a Slack workspace, including user-created and default groups; results for large workspaces may be paginated.
List user reactionsLists all reactions added by a specific user to messages, files, or file comments in Slack, useful for engagement analysis when the item content itself is not required.
Lookup Canvas SectionsLooks up section IDs in a Slack Canvas for use with targeted edit operations.
Open DMOpens or resumes a Slack direct message (DM) or multi-person direct message (MPIM) by providing either user IDs or an existing channel ID.
Pin an item to a channelPins a message to a specified Slack channel; the message must not already be pinned.
Remove call participantsRegisters participants removed from a Slack call.
Remove reaction from itemRemoves an emoji reaction from a message, file, or file comment in Slack.
Remove remote fileRemoves the Slack reference to an external file (which must have been previously added via the remote files API), specified by either its `external_id` or `file` ID (one of which is required), without deleting the actual external file.
Remove user from conversationRemoves a specified user from a Slack conversation (channel); the caller must have permissions to remove users and cannot remove themselves using this action.
Rename a conversationRenames a Slack channel, automatically adjusting the new name to meet naming conventions (e.
Retrieve conversation informationRetrieves metadata for a Slack conversation by ID (e.
Get conversation membersRetrieves a paginated list of active member IDs (not names, emails, or presence) for a specified Slack public channel, private channel, DM, or MPIM.
Retrieve user DND statusRetrieves a Slack user's current Do Not Disturb (DND) status to determine their availability before interaction; any specified user ID must be a valid Slack user ID.
Retrieve detailed file informationRetrieves detailed metadata and paginated comments for a specific Slack file ID; does not download file content.
Retrieve detailed user informationRetrieves comprehensive information for a valid Slack user ID, excluding message history and channel memberships.
Retrieve user profile informationRetrieves profile information for a specified Slack user (defaults to the authenticated user if `user` ID is omitted); a provided `user` ID must be valid.
Revoke a file's public urlRevokes a Slack file's public URL, making it private; this is a no-op if not already public and is irreversible.
Schedule messageSchedules a message to a Slack channel, DM, or private group for a future time (`post_at`), requiring `text`, `blocks`, or `attachments` for content; scheduling is limited to 120 days in advance.
Search all contentTool to search all messages and files.
Search messagesWorkspace‑wide Slack message search with date ranges and filters.
Send ephemeral messageSends an ephemeral message visible only to the specified `user` in a channel; other channel members cannot see it.
Share a me message in a channelSends a 'me message' (e.
Send messagePosts a message to a Slack channel, DM, or private group; requires at least one content field (`markdown_text`, `text`, `blocks`, or `attachments`) — omitting all causes a `no_text` error.
Set a conversation's purposeSets the purpose (a short description of its topic/goal, displayed in the header) for a Slack conversation; the calling user must be a member.
Set conversation read cursorMarks a message, specified by its timestamp (`ts`), as the most recently read for the authenticated user in the given `channel`, provided the user is a member of the channel and the message exists within it.
Set conversation topicSets or updates the topic for a specified Slack conversation.
Set user presenceManually sets a user's Slack presence, overriding automatic detection; this setting persists across connections but can be overridden by user actions or Slack's auto-away (e.
Share a remote file in channelsShares a remote file, which must already be registered with Slack, into specified Slack channels or direct message conversations.
Start callRegisters a new call in Slack using `calls.
Unarchive channelReverses conversation archival.
Unpin message from channelUnpins a message, identified by its timestamp, from a specified channel if the message is currently pinned there; this operation is destructive.
Update call informationUpdates the title, join URL, or desktop app join URL for an existing Slack call identified by its ID.
Update an existing remote fileUpdates metadata or content details for an existing remote file in Slack; this action cannot upload new files or change the fundamental file type.
Update a Slack messageUpdates a Slack message, identified by `channel` ID and `ts` timestamp, by modifying its `text`, `attachments`, or `blocks`; provide at least one content field, noting `attachments`/`blocks` are replaced if included (`[]` clears them).
Update Slack user groupUpdates an existing Slack User Group, which must be specified by an existing `usergroup` ID, with new optional details such as its name, description, handle, or default channels.
Update user group membersReplaces all members of an existing Slack User Group with a new list of valid user IDs.
Upload or create a file in SlackUpload files, images, screenshots, documents, or any media to Slack channels or threads.

What is the Composio tool router, and how does it fit here?

What is Composio SDK?

Composio's Composio SDK helps agents find the right tools for a task at runtime. You can plug in multiple toolkits (like Gmail, HubSpot, and GitHub), and the agent will identify the relevant app and action to complete multi-step workflows. This can reduce token usage and improve the reliability of tool calls. Read more here: Getting started with Composio SDK

The tool router generates a secure MCP URL that your agents can access to perform actions.

How the Composio SDK works

The Composio SDK follows a three-phase workflow:

  1. Discovery: Searches for tools matching your task and returns relevant toolkits with their details.
  2. Authentication: Checks for active connections. If missing, creates an auth config and returns a connection URL via Auth Link.
  3. Execution: Executes the action using the authenticated connection.

Step-by-step Guide

Prerequisites

Before starting, make sure you have:
  • Composio API Key and Claude/Anthropic API Key
  • Primary know-how of Claude Agents SDK
  • A Slackbot account
  • Some knowledge of Python

Getting API Keys for Claude/Anthropic and Composio

Claude/Anthropic API Key
  • Go to the Anthropic Console and create an API key. You'll need credits to use the models.
  • Keep the API key safe.
Composio API Key
  • Log in to the Composio dashboard.
  • Navigate to your API settings and generate a new API key.
  • Store this key securely as you'll need it for authentication.

Install dependencies

pip install composio-anthropic claude-agent-sdk python-dotenv

Install the Composio SDK and the Claude Agents SDK.

What's happening:

  • composio-anthropic provides Composio integration for Anthropic
  • claude-agent-sdk is the core agent framework
  • python-dotenv loads environment variables

Set up environment variables

bash
COMPOSIO_API_KEY=your_composio_api_key_here
USER_ID=your_user_id_here
ANTHROPIC_API_KEY=your_anthropic_api_key_here

Create a .env file in your project root.

What's happening:

  • COMPOSIO_API_KEY authenticates with Composio
  • USER_ID identifies the user for session management
  • ANTHROPIC_API_KEY authenticates with Anthropic/Claude

Import dependencies

import asyncio
from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions
import os
from composio import Composio
from dotenv import load_dotenv

load_dotenv()
What's happening:
  • We're importing all necessary libraries including the Claude Agent SDK and Composio
  • The load_dotenv() function loads environment variables from your .env file
  • This setup prepares the foundation for connecting Claude with Slackbot functionality

Create a Composio instance and Tool Router session

async def chat_with_remote_mcp():
    api_key = os.getenv("COMPOSIO_API_KEY")
    if not api_key:
        raise RuntimeError("COMPOSIO_API_KEY is not set")

    composio = Composio(api_key=api_key)

    # Create Tool Router session for Slackbot
    mcp_server = composio.create(
        user_id=os.getenv("USER_ID"),
        toolkits=["slackbot"]
    )

    url = mcp_server.mcp.url

    if not url:
        raise ValueError("Session URL not found")
What's happening:
  • The function checks for the required COMPOSIO_API_KEY environment variable
  • We're creating a Composio instance using our API key
  • The create method creates a Tool Router session for Slackbot
  • The returned url is the MCP server URL that your agent will use

Configure Claude Agent with MCP

# Configure remote MCP server for Claude
options = ClaudeAgentOptions(
    permission_mode="bypassPermissions",
    mcp_servers={
        "composio": {
            "type": "http",
            "url": url,
            "headers": {
                "x-api-key": os.getenv("COMPOSIO_API_KEY")
            }
        }
    },
    system_prompt="You are a helpful assistant with access to Slackbot tools via Composio.",
    max_turns=10
)
What's happening:
  • We're configuring the Claude Agent options with the MCP server URL
  • permission_mode="bypassPermissions" allows the agent to execute operations without asking for permission each time
  • The system prompt instructs the agent that it has access to Slackbot
  • max_turns=10 limits the conversation length to prevent excessive API usage

Create client and start chat loop

# Create client with context manager
async with ClaudeSDKClient(options=options) as client:
    print("\nChat started. Type 'exit' or 'quit' to end.\n")

    # Main chat loop
    while True:
        user_input = input("You: ").strip()
        if user_input.lower() in {"exit", "quit"}:
            print("Goodbye!")
            break

        # Send query
        await client.query(user_input)

        # Receive and print response
        print("Claude: ", end="", flush=True)
        async for message in client.receive_response():
            if hasattr(message, "content"):
                for block in message.content:
                    if hasattr(block, "text"):
                        print(block.text, end="", flush=True)
        print()
What's happening:
  • The Claude SDK client is created using the async context manager pattern
  • The agent processes each query and streams the response back in real-time
  • The chat loop continues until the user types 'exit' or 'quit'

Run the application

if __name__ == "__main__":
    asyncio.run(chat_with_remote_mcp())
What's happening:
  • This entry point runs the async chat_with_remote_mcp() function using asyncio.run()
  • The application will start, create the MCP connection, and begin the interactive chat session

Complete Code

Here's the complete code to get you started with Slackbot and Claude Agent SDK:

import asyncio
from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions
import os
from composio import Composio
from dotenv import load_dotenv

load_dotenv()

async def chat_with_remote_mcp():
    api_key = os.getenv("COMPOSIO_API_KEY")
    if not api_key:
        raise RuntimeError("COMPOSIO_API_KEY is not set")

    composio = Composio(api_key=api_key)

    # Create Tool Router session for Slackbot
    mcp_server = composio.create(
        user_id=os.getenv("USER_ID"),
        toolkits=["slackbot"]
    )

    url = mcp_server.mcp.url

    if not url:
        raise ValueError("Session URL not found")

    # Configure remote MCP server for Claude
    options = ClaudeAgentOptions(
        permission_mode="bypassPermissions",
        mcp_servers={
            "composio": {
                "type": "http",
                "url": url,
                "headers": {
                    "x-api-key": os.getenv("COMPOSIO_API_KEY")
                }
            }
        },
        system_prompt="You are a helpful assistant with access to Slackbot tools via Composio.",
        max_turns=10
    )

    # Create client with context manager
    async with ClaudeSDKClient(options=options) as client:
        print("\nChat started. Type 'exit' or 'quit' to end.\n")

        # Main chat loop
        while True:
            user_input = input("You: ").strip()
            if user_input.lower() in {"exit", "quit"}:
                print("Goodbye!")
                break

            # Send query
            await client.query(user_input)

            # Receive and print response
            print("Claude: ", end="", flush=True)
            async for message in client.receive_response():
                if hasattr(message, "content"):
                    for block in message.content:
                        if hasattr(block, "text"):
                            print(block.text, end="", flush=True)
            print()

if __name__ == "__main__":
    asyncio.run(chat_with_remote_mcp())

Conclusion

You've successfully built a Claude Agent SDK agent that can interact with Slackbot through Composio's Tool Router.

Key features:

  • Native MCP support through Claude's agent framework
  • Streaming responses for real-time interaction
  • Permission bypass for smooth automated workflows
You can extend this by adding more toolkits, implementing custom business logic, or building a web interface around the agent.

How to build Slackbot MCP Agent with another framework

FAQ

What are the differences in Tool Router MCP and Slackbot MCP?

With a standalone Slackbot MCP server, the agents and LLMs can only access a fixed set of Slackbot tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Slackbot and many other apps based on the task at hand, all through a single MCP endpoint.

Can I use Tool Router MCP with Claude Agent SDK?

Yes, you can. Claude Agent SDK fully supports MCP integration. You get structured tool calling, message history handling, and model orchestration while Tool Router takes care of discovering and serving the right Slackbot tools.

Can I manage the permissions and scopes for Slackbot while using Tool Router?

Yes, absolutely. You can configure which Slackbot scopes and actions are allowed when connecting your account to Composio. You can also bring your own OAuth credentials or API configuration so you keep full control over what the agent can do.

How safe is my data with Composio Tool Router?

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Slackbot data and credentials are handled as safely as possible.

Used by agents from

Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai

Never worry about agent reliability

We handle tool reliability, observability, and security so you never have to second-guess an agent action.