Docs menu

Guide

MCP for coding agents

channelstack mcp serves the attach CLI's commands as MCP tools over stdio. A coding agent that is building your bot can then try it the way you would by hand: post as a person, read what the bot answered, see what was delivered and called, redeliver, and look again.

Add it to your coding agent#

Most coding agents take an MCP server as a command in a JSON config:

{
  "mcpServers": {
    "channelstack": { "command": "npx", "args": ["channelstack", "mcp"] }
  }
}

In Claude Code, claude mcp add channelstack -- npx channelstack mcp registers the same server (add --scope project to write it to .mcp.json). Other agents (Cursor, Codex, Windsurf) take the same command and args in their own MCP settings file.

The MCP server attaches to the running channelstack server on its first tool call, not when it starts, so the coding agent can launch it before you start the server. It finds the server the way the CLI does: through server.json, or --server <url> in args with CHANNELSTACK_TOKEN in its environment. If the server isn't reachable, the tool call returns that as an error and the next call tries again.

The server and the bot still need to run, as for the CLI:

CHANNELSTACK_SLACK_WEBHOOK_URL=http://localhost:3000/slack/events npx channelstack start
npx channelstack env > .env.local    # then start the bot with it

The tools#

Every tool acts in the shared dev session, the same one the CLI and the UI use, and prints what the matching CLI command prints. Every channel has the same tools (decision 0028): channel is slack, github, linear, notion, resend, google or discord.

ToolInputsSame as
saychannel, as, in (a place by name, e.g. "#support"), textchannelstack <channel> say
replychannel, as, text, to?channelstack <channel> reply
reactchannel, as, emoji (e.g. ":eyes:"), on?channelstack <channel> react (Slack, GitHub and Linear)
showchannel?, in?, thread?, json?channelstack <channel> show; without channel, channelstack show
<channel>_actaction, params?, as?, in?, on?channelstack <channel> <action>: everything else its people do (slack_act, github_act, …)
tailnonechannelstack tail, but each call returns only what happened since the last one (everything, the first time)
list_deliverieschannel?; every channel's without itchannelstack deliveries
redeliverchannel?, delivery? (last, the default, or an id from list_deliveries)channelstack redeliver
openai_respondtext?, when?, times? (-1 for every call), tool?, args? (JSON)channelstack openai respond: what the fake OpenAI answers the bot's next model calls
openai_callsnonechannelstack openai calls
  • as is a person's name, such as ana. The person is created the first time the name is used.
  • in names a place: a Slack channel ("#support"), a GitHub issue or pull request by its title (in the org's public dev repository), a Linear issue by its title (in a team named Dev), a Notion page by its title, an email thread by its subject, a Discord channel ("#support"). say makes it the first time, with the person and the bot in it.
  • to, on and thread take "last" (the default: the newest entry of the channel's most recently active place), or "<place>:<entry>", as say and reply print it and show with json lists the entries' ids.
  • openai_respond scripts the bot's model when the bot is on the fake OpenAI (OPENAI_BASE_URL from channelstack env). There is no default answer: a model call nothing scripted gets a 400 (channelstack_no_script). The text may use {lastUserText} and {toolResult}; when answers only calls whose newest user message has that text; with tool, the model calls that tool first, with args, and text answers its result.
  • <channel>_act's actions are generated from the channel's routes: each thing its people do that isn't a read (click, stop, select on Slack; review, merge, label on GitHub; delegate, setState, prompt on Linear; …). The tool's description lists each action with its values. params takes them by name; a person or the app ("app") by name, a reference as "last" or an id. A reference the action needs and isn't given comes from the target: the entry on names, the newest one in the place in names, or the newest anywhere. Without as, whoever started the target's thread acts (slack_act stop presses Stop as the person who asked).

The loop#

This is what a coding agent does with the tools while it works on the bot:

  1. Act as a person. If the bot's model is the fake OpenAI, script it first: openai_respond with { "text": "Here's what I found.", "times": -1 }. Then say with { "channel": "slack", "as": "ana", "in": "#support", "text": "@my-agent summarize today" } returns ana said it in #support (C0A1B2C3D4E:1732451234.000100). Follow up with reply, react, or slack_act with { "action": "click", "params": { "button": "Approve" } }.

  2. Read the answer. show returns the most recently active place as a person reads it:

    ana: @my-agent summarize today
      my-agent: Here's what I found about "summarize today".
    

    The bot answers asynchronously. If its reply isn't there yet, call show again.

  3. See why. tail returns the events delivered to the bot (→ slack app_mention 200) and the API calls it made (← slack chat.postMessage 200). A failed delivery, or a call refused with an error code, is usually the bug. openai_calls shows what the bot asked its model and what the model answered.

  4. Change the bot, then send the same event again. list_deliveries with { "channel": "slack" } lists each delivery's id, event, outcome and attempts. redeliver with that id sends it again, the way Slack retries it, and returns Retried Ev0A1B2C3D4E (slack). A bot that now answers twice doesn't handle retries.

  5. Check again with show.

Once the bot behaves, the agent pins it down in a test (Writing tests), which gets a fresh session and creates its own people.

Errors#

A mistake comes back as the tool's error, in one sentence, the same sentence the CLI prints: an unknown delivery id, a missing as, a server that isn't running. The coding agent reads it and tries again; nothing crashes.

What it never returns#

The tools return the same text as show, tail, deliveries and openai calls. None of it carries the server's bearer token, which stays in server.json and in the MCP server's memory. Don't paste the tokens from .env.local into the chat either: the coding agent doesn't need them to use the tools.

The skill#

channelstack's repository has a skill for coding agents in skills/channelstack/SKILL.md. It tells the agent how to set up the server and the MCP config, runs it through the loop above, and shows the test to write afterwards. Copy it into your coding agent's skills folder, for example .claude/skills/channelstack/SKILL.md for Claude Code.

The docs, for your coding agent#

The docs themselves are served for agents too, so a coding agent can look up the API while it writes your tests:

  • An MCP server for the docs at https://channelstack.dev/mcp (Streamable HTTP, no sign-in) with three read-only tools: search_docs finds the sections that answer a question, read_doc reads a page, and list_docs lists them all. Add it to an agent as a remote server:

    {
      "mcpServers": {
        "channelstack-docs": { "type": "http", "url": "https://channelstack.dev/mcp" }
      }
    }

    In Claude Code, claude mcp add --transport http channelstack-docs https://channelstack.dev/mcp does the same. The menu next to Copy page at the top of every docs page installs it in Cursor or VS Code in one click.

  • Every page as Markdown: add .md to its URL (/docs/guide/live-mode.md), or ask for it with Accept: text/markdown. Every example comes with all three languages.

  • llms.txt lists every page by section, and llms-full.txt has all of them in one file.

  • Copy page copies the page's Markdown for a chat, and its menu opens the page in ChatGPT, Claude, Codex or Cursor.

Suggest changes to this page