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)

ComponentPurposeExample / Notes
Slack AppProvides tokens and scopes to interact with the workspaceCreate at api.slack.com/apps — requires SLACK_BOT_TOKEN, SLACK_APP_TOKEN, chat:write, commands, Socket Mode for local development
Slack Bot (Python Bolt)Receives Slack events and forwards queries to KAgent via A2ARuns locally with uvicorn main:app --reload. Listens for /mykagent slash command and formats responses as Slack Block Kit
KAgent AgentExecutes LLM + tools inside KubernetesDeployed in the kagent namespace and exposed via A2A
A2A ProtocolREST API for external systems to invoke agentsEndpoint pattern: /api/a2a/{namespace}/{agent-name}/ — use backticks when documenting (e.g., /api/a2a/{namespace}/{agent-name}/)
MCP ServersProvide tool integrations to agents (Slack, GitHub, PagerDuty, etc.)Slack MCP server exposes tools like slack_post_message, slack_get_channel_history, etc.
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:
kubectl port-forward -n kagent svc/kagent-controller 8083:8083
  1. Set the A2A URL environment variable (pointing to the agent you will deploy). Use backticks when copying the path:
export KAGENT_A2A_URL="http://127.0.0.1:8083/api/a2a/kagent/my-k8s-agent/"
  1. Start the Slack bot locally (example for a uvicorn-based app):
uvicorn main:app --reload
  1. Test from Slack using the configured slash command, e.g.:
/mykagent show me the pods in the cluster

Environment variables (.env example)

Store Slack tokens and the A2A URL in a .env file or secret manager:
SLACK_BOT_TOKEN=xoxb-...
SLACK_APP_TOKEN=xapp-1-...
KAGENT_A2A_URL=http://127.0.0.1:8083/api/a2a/kagent/my-k8s-agent/
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):
POST http://127.0.0.1:8083/api/a2a/kagent/my-k8s-agent/
Payload: { "input": "show me pods", ... }

Running the bot and deploying the agent

Start the Slack bot locally:
uvicorn main:app --reload
# Example log:
# INFO:root:Starting kagent Slack bot
Deploy the agent manifest into the cluster:
kubectl apply -f slack-k8s-agent.yaml
# Example output:
# agent.kagent.dev/my-k8s-agent created
Check agent status:
kubectl get agent -n kagent
# NAME            TYPE          READY   ACCEPTED
# my-k8s-agent    Declarative   False   True
Retrieve the agent card from the A2A controller (validates the path and capabilities):
curl http://127.0.0.1:8083/api/a2a/kagent/my-k8s-agent/.well-known/agent.json
Example JSON response (truncated):
{
  "name": "my_k8s_agent",
  "description": "My Kubernetes Agent",
  "url": "http://kagent-controller.kagent.svc.cluster.local:8083/api/a2a/kagent/my-k8s-agent/",
  "capabilities": {
    "streaming": true,
    "pushNotifications": false,
    "stateTransitionHistory": true
  },
  "defaultInputModes": ["text"],
  "defaultOutputModes": ["text"],
  "skills": [
    {
      "id": "answer-questions-about-your-cluster",
      "name": "Answer Questions About Your Cluster",
      "description": "Answer questions about your Kubernetes cluster",
      "tags": ["kubernetes"],
      "inputModes": ["text"],
      "outputModes": ["text"]
    }
  ]
}
Once the agent shows READY in the KAgent UI, invoke it via Slack.

Example Slack query -> agent response

User input:
/mykagent get the list of pods running in the cluster
Agent response (example formatted text):
Here are the pods running in the cluster across all namespaces:

Namespace: kagent
- kagent-controller-6f546c65bd-ckk6s
- kagent-grafana-mcp-597df4c7f4-r4fdq
- kagent-kmcp-controller-manager-86b48b656d-l8zdb
- kagent-querydoc-7dc78dc9d7-pqf92
- kagent-tools-6d6695c5-rw7rz
- kagent-ui-5757fccb58-bsbbc
- my-k8s-agent-7b98575b68-kds2f

Namespace: kube-system
- metrics-server-67c9654d97-dc7tm
- metrics-server-67c9654d97-g9crq

All pods listed are in Running status. How can I assist you further?
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:
KAGENT AGENT (in Kubernetes)
  -> call send_message_to_slack
SLACK MCP SERVER (in Kubernetes)
  -> POST chat.postMessage to Slack API
SLACK WORKSPACE
  -> message appears in channel

Deploying and configuring the Slack MCP server

A Slack MCP server is an MCPServer custom resource. A minimal manifest looks like this:
apiVersion: kagent.dev/v1alpha1
kind: MCPServer
metadata:
  name: slack-mcp
  namespace: kagent
spec:
  deployment:
    image: "node:latest"
    port: 3000
    cmd: ["npx"]
    args:
      - "-y"
      - "@modelcontextprotocol/server-slack"
  secretRefs:
    # secret references for Slack credentials (see your manifest)
Create a Kubernetes Secret containing Slack credentials (bot token, team ID, channel IDs) and apply the manifest:
kubectl apply -f slack-mcp.yaml
kubectl get mcpserver -n kagent
# NAME        READY   AGE
# slack-mcp   True    14s
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:
kubectl apply -f slack-k8s-agent.yaml
# agent.kagent.dev/my-k8s-agent configured
Example instruction you can give the agent:
Get the list of deployments on the cluster and post it to the Slack channel "cluster-info".
Example tools executed:
  • get_resource_information (fetch deployments)
  • slack_post_message (post formatted message to Slack channel)
Example channel output:
List of deployments on the cluster:

Namespace: kagent
- kagent-controller
- kagent-grafana-mcp
- kagent-kmcp-controller-manager
- kagent-querydoc
- kagent-tools
- kagent-ui
- my-k8s-agent
- slack-mcp

Namespace: kube-system
- metrics-server
You can deploy multiple Slack apps / MCP servers to support different teams, channels, or clusters as needed.

Quick reference commands

TaskCommand
Port-forward KAgent controllerkubectl port-forward -n kagent svc/kagent-controller 8083:8083
Start Slack botuvicorn main:app --reload
Apply agent manifestkubectl apply -f slack-k8s-agent.yaml
Retrieve agent cardcurl http://127.0.0.1:8083/api/a2a/kagent/my-k8s-agent/.well-known/agent.json

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