Skip to main content
This lesson demonstrates a two-way integration between Slack and KAgent:
  • Slack -> KAgent: a user invokes a Slack slash command; the Slack bot forwards the query to a KAgent via the A2A protocol; the agent runs tools and returns results to Slack.
  • KAgent -> Slack: the agent proactively posts notifications to a Slack channel using a Slack MCP server.
Below are the key components for this integration.
A screenshot of a code editor (likely VS Code) with a project sidebar on the left and an open text file on the right. The document shows an ASCII-style "KEY COMPONENTS" section describing a Slack app, a Python Slack bot, and a kagent agent.
This article does not cover Slack app creation specifics because that depends on your organization’s Slack configuration. At a minimum you will need a bot token and an app token with appropriate scopes (chat:write and commands) and Socket Mode enabled for local development.

Key components (overview)

Notes:
  • Use backticks for endpoints that contain braces (e.g., /api/a2a/{namespace}/{agent-name}/).
  • This example uses Socket Mode for the local Slack bot with Python Bolt.

Local connection and setup (development flow)

A typical local development flow:
  1. Port-forward the KAgent controller so your local machine can reach the A2A endpoint:
  1. Set the A2A URL environment variable (pointing to the agent you will deploy). Use backticks when copying the path:
  1. Start the Slack bot locally (example for a uvicorn-based app):
  1. Test from Slack using the configured slash command, e.g.:

Environment variables (.env example)

Store Slack tokens and the A2A URL in a .env file or secret manager:
Do not commit tokens or secrets to source control. Use Kubernetes Secrets or a secret manager for production credentials. Rotate tokens if they are accidentally exposed.

Slack -> KAgent request flow (high-level)

  1. USER (Slack) types a slash command (e.g., /mykagent "show me pods").
  2. Slack delivers the command event (via Socket Mode) to the local Slack bot.
  3. SLACK BOT (Python Bolt) extracts the query and performs an HTTP POST to the A2A endpoint configured in KAGENT_A2A_URL.
  4. The A2A request hits the KAgent controller (port-forwarded to localhost).
  5. The controller routes the request to the appropriate agent pod.
  6. The agent processes the query using its LLM, chooses and executes tools (e.g., Kubernetes resource tools), and crafts a response.
  7. The agent returns the response via A2A; the Slack bot posts formatted output back to the Slack channel.
Example HTTP request to A2A (local dev):

Running the bot and deploying the agent

Start the Slack bot locally:
Deploy the agent manifest into the cluster:
Check agent status:
Retrieve the agent card from the A2A controller (validates the path and capabilities):
Example JSON response (truncated):
Once the agent shows READY in the KAgent UI, invoke it via Slack.

Example Slack query -> agent response

User input:
Agent response (example formatted text):
This demonstrates the full round-trip: Slack -> Slack bot -> A2A -> agent -> tools -> response -> Slack.

KAgent -> Slack (Agent-initiated messages)

Agents can proactively post to Slack channels by calling Slack MCP tools. Typical flow:
  1. Agent determines a message/alert should be posted to Slack.
  2. Agent calls a Slack MCP tool such as send_message_to_slack or slack_post_message.
  3. The Slack MCP server performs an HTTP POST to Slack API chat.postMessage.
  4. The message appears in the configured Slack channel.
Schematic:

Deploying and configuring the Slack MCP server

A Slack MCP server is an MCPServer custom resource. A minimal manifest looks like this:
Create a Kubernetes Secret containing Slack credentials (bot token, team ID, channel IDs) and apply the manifest:
When the Slack MCP server is running, tools such as slack_post_message, slack_get_channel_history, and slack_add_reaction are available to agents. Confirm visibility in the KAgent UI.
A screenshot of a web UI for "kagent" (localhost:8080/servers) showing a list of server/integration entries. The expanded item is kagent/slack-mcp with multiple Slack actions listed (e.g., slack_add_reaction, slack_get_channel_history).

Granting the agent Slack posting permissions

Steps to allow agents to post into Slack:
  1. Create a Kubernetes Secret with Slack credentials (bot token, team ID, channel IDs).
  2. Update your agent manifest to include Slack MCP tools (e.g., slack_post_message) in the agent’s tool list.
  3. Apply the updated agent manifest and wait for KAgent to reconcile. It may take a minute for new tools to become available.
Example:
Example instruction you can give the agent:
Example tools executed:
  • get_resource_information (fetch deployments)
  • slack_post_message (post formatted message to Slack channel)
Example channel output:
You can deploy multiple Slack apps / MCP servers to support different teams, channels, or clusters as needed.

Quick reference commands

Closing

This lesson covered a two-way integration pattern between Slack and KAgent:
  • Slack -> KAgent: Slack commands are forwarded to agents via the A2A protocol; agents execute tools and return results back to Slack.
  • KAgent -> Slack: Agents post messages or alerts to Slack by invoking MCP tools exposed by a Slack MCP server.
You can reuse this pattern to integrate agents with other MCP servers (GitHub, PagerDuty, etc.) to extend agent capabilities across platforms.

Watch Video