Skip to content

feat: add Coder Agents chat tools to the MCP toolsdk - #28025

Open
ibetitsmike wants to merge 14 commits into
mainfrom
mike/toolsdk-chat-tools
Open

feat: add Coder Agents chat tools to the MCP toolsdk#28025
ibetitsmike wants to merge 14 commits into
mainfrom
mike/toolsdk-chat-tools

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Exposes the experimental Coder Agents chats API through the MCP tool registry, so MCP clients (the hosted /api/experimental/mcp/http server and coder exp mcp server) can start and drive server-side coding agents.

New tools in codersdk/toolsdk, all thin wrappers over existing codersdk.ExperimentalClient methods:

Tool Wraps
coder_create_chat CreateChat (prompt, optional org, model config, labels)
coder_get_chat GetChat (status, last error, last turn summary, workspace, files)
coder_get_chat_messages GetChatMessages (user-facing parts, chronological, cursor pagination, queued prompts)
coder_send_chat_message CreateChatMessage (queue or interrupt busy behavior)
coder_interrupt_chat InterruptChat
coder_archive_chat UpdateChat with archived: true
coder_list_chat_model_configs ListChatModelConfigs (enabled configs with default flag)

Both MCP servers register tools from toolsdk.All, so no additional wiring is needed. Responses are trimmed to what an MCP caller needs (IDs as strings, user-facing transcripts) rather than full SDK payloads. No new endpoints and no database changes.

Also adds MCP prompts for the chat workflows, defined once in codersdk/toolsdk and registered by both servers:

Prompt Purpose
coder_agents_delegate delegate a task to a Coder Agents chat and monitor it to completion
coder_agents_check check the status and recent activity of an existing chat

Each prompt declares the tools its workflow needs; the stdio server skips prompts whose tools are excluded by --allowed-tools.

Tests run the tools against a chat-enabled coderdtest instance (fake OpenAI-compatible provider plus in-process AI bridge), covering the full lifecycle, an interrupt against a blocked turn, pagination cursors, permission-dependent model config filtering, and argument validation. Prompt coverage spans SDK rendering, the hosted prompts/list/prompts/get round trip, and the stdio server including allowlist gating.

Mux created this PR on Mike's behalf.

Expose the experimental chats API through MCP so agents can start and
drive Coder Agents chats: coder_create_chat, coder_get_chat,
coder_get_chat_messages, coder_send_chat_message, coder_interrupt_chat,
coder_archive_chat, and coder_list_chat_model_configs. Both the hosted
MCP server and the CLI stdio server pick these up from toolsdk.All.
Type busy_behavior with the SDK enum, derive the schema enum from
constants, validate the message limit locally so out-of-range values
fail loudly, and drop comments and checks inconsistent with sibling
tools.
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown

Docs preview

Check off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 78b3e7cd60

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codersdk/toolsdk/chats.go
Comment thread codersdk/toolsdk/chats.go
Add a before_id cursor to coder_get_chat_messages so has_more pages
are reachable, and filter provider-disabled model configs out of
coder_list_chat_model_configs for admin callers.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4b94c814a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codersdk/toolsdk/chats.go Outdated
A page holding only tool-call rows filters to an empty messages slice,
leaving callers with no id to derive a cursor from. Return
next_before_id from the unfiltered API page instead.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: be6e7872d6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 83b427b541

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codersdk/toolsdk/chats.go
…ation

An admin can remove a user's only membership, so indexing
OrganizationIDs[0] can panic and surface as a recovered handler panic
instead of an actionable error.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f21095ae07

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codersdk/toolsdk/chats.go Outdated
Hook-notice parts are user-facing per the SDK part contract, so
coder_get_chat_messages must not filter them out with internal parts.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d93cc83872

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codersdk/toolsdk/chats.go Outdated
A deployment-config reader without AI provider read access (such as an
auditor) receives the unfiltered admin model config list, and silently
discarding the AIProviders error let provider-disabled configs leak
through. Distinguish that case and error instead.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6aba5c2154

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codersdk/toolsdk/chats.go
Comment thread codersdk/toolsdk/chats.go Outdated
…ovider probe

A prompt queued behind a busy chat now appears in queued_messages so
polling callers do not conclude it was lost, and a failing
deployment-config probe now propagates instead of falling through to
the fail-open member path.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c73810e414

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codersdk/toolsdk/chats.go Outdated
…viders

Provider deletion only soft-deletes the provider row, so its enabled
model configs stay in the admin list while AIProviders omits the
provider. Treat a successful provider enumeration as authoritative and
exclude configs whose provider is absent, not just disabled ones.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@ThomasK33 ThomasK33 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it. Either in this PR or in another one, I'd also add a built-in skill behind an MCP prompt (https://modelcontextprotocol.io/specification/2025-06-18/server/prompts).

That way, agents connecting to this would have a quick way to know how to interact with all these APIs.
That's also how Claude Design's MCP server works; they provide tools and a guiding skill for Claude Code via prompts.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 52271891aa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Add coder_agents_delegate and coder_agents_check prompt templates per
the MCP prompts spec (2026-07-28). Definitions live in the toolsdk so
the coderd-hosted and CLI stdio MCP servers adapt one shared list, the
same way tools flow through toolsdk.All. The stdio server registers
them only when the chat tools they reference are available.
…ilable

A restricted --allowed-tools list could advertise prompts whose
workflow tools were not registered. Each prompt now declares its
RequiredTools and the stdio server skips prompts with missing tools.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@coder-tasks

coder-tasks Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Documentation Check

Updates Needed

  • docs/ai-coder/mcp-server.md - The MCP server now also exposes MCP prompts (coder_agents_delegate, coder_agents_check), registered on both the HTTP server (RegisterPrompts) and the CLI coder exp mcp server. The Available Tools section documents only tools and never mentions prompts. Add a short "Available Prompts" subsection describing this capability, mirroring how the tools list defers the authoritative set to the toolsdk package (here codersdk/toolsdk/prompts.go).

Automated review via Coder Agents

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 17cedd44fa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codersdk/toolsdk/prompts.go Outdated
…ompt requirements

The delegate workflow only suggests coder_list_chat_model_configs as an
optional step and omits it entirely when model_config_id is supplied,
so requiring it suppressed the prompt for valid restricted allowlists.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 87646cfdf7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants