Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(coderd): accept RFC 9728 resource metadata with array-valued resource (#28592) - #28647

Merged
mtojek merged 1 commit into
release/2.37from
backport/28592-to-2.37
Aug 27, 2026
Merged

fix(coderd): accept RFC 9728 resource metadata with array-valued resource (#28592)#28647
mtojek merged 1 commit into
release/2.37from
backport/28592-to-2.37

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Cherry-pick of #28592

Original PR: #28592 — fix(coderd): accept RFC 9728 resource metadata with array-valued resource
Merge commit: 50f3631
Requested by: @f0ssel

…urce (#28592)

GitLab's official MCP server returns `"resource"` as a JSON array in its
`/.well-known/oauth-protected-resource` document, while RFC 9728 §2
defines it as a string. Coder's OAuth2 auto-discovery failed to decode
the response (`json: cannot unmarshal array into Go struct field
protectedResourceMetadata.resource of type string`), blocking
zero-config `oauth2` DCR against GitLab.

This makes `protectedResourceMetadata.Resource` tolerate both a single
string and an array of strings.

Part of
[CODAGT-570](https://linear.app/codercom/issue/CODAGT-570/coder-agents-mcp-client-cannot-connect-to-gitlabs-official-mcp-server).
The other blocker in that issue (GitLab replying 204 to
`notifications/initialized`) was already fixed by the migration from
`mark3labs/mcp-go` to `modelcontextprotocol/go-sdk`, whose
streamable-HTTP client accepts 204.

<details>
<summary>Investigation notes</summary>

CODAGT-570 reported two independent incompatibilities with GitLab CE's
`/api/v4/mcp` server:

1. **204 vs 202 on `notifications/initialized` (blocked all auth
modes):** the bundled `mark3labs/mcp-go` client only accepted 200/202
for notification POSTs. That library has since been removed entirely;
`coderd/x/chatd/mcpclient` now uses
`github.com/modelcontextprotocol/go-sdk v1.7.0`, which accepts both 204
and 202 (and only warns on other codes in non-strict mode, which is the
only mode reachable from Coder). No further change needed.
2. **RFC 9728 `resource` array (blocked zero-config oauth2 DCR):**
Coder's own parser in `coderd/mcp.go` declared `Resource string`. This
lives outside the MCP library, so the SDK migration did not fix it.
Fixed here with a custom `UnmarshalJSON` accepting string or array of
strings. The field is only decoded, never consumed downstream, so
behavior is otherwise unchanged.

</details>

---

Generated by Coder Agents on behalf of @f0ssel.

(cherry picked from commit 50f3631)
@f0ssel

f0ssel commented Aug 27, 2026

Copy link
Copy Markdown
Member

Before cherry picking I verified this solution against a local Gitlab deployment - #28592 (comment)

@f0ssel
f0ssel requested a review from mtojek August 27, 2026 17:38
@mtojek
mtojek merged commit 7986365 into release/2.37 Aug 27, 2026
25 checks passed
@mtojek
mtojek deleted the backport/28592-to-2.37 branch August 27, 2026 17:42
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cherry-pick/v2.37 Cherry-pick PR targeting release/2.37

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants