Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions pkgs/mcpx/internal/mcpserver/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,28 @@ func (p Peer) Declared(name string) bool {
//
// Three gates, and all three are needed. The revision has to define
// elicitation at all -- 2025-03-26 does not. The client has to have declared
// it. And url mode has to be separately declared, because it arrived in
// 2025-11-25 and a client that knows only form mode receives a request with
// no `requestedSchema` and no way to render it.
// it. And each mode has to be separately declared from 2025-11-25, when the
// declaration gained sub-keys: url mode because it arrived then and a client
// that knows only form mode receives a request with no `requestedSchema` and
// no way to render it, and form mode because a client that declared only
// url never agreed to a form -- {} remains the form-only declaration, and
// below 2025-11-25 presence of the capability is the form declaration.
func (p Peer) CanElicit(mode string) bool {
if !AtLeast(p.Version, "2025-06-18") || !p.Declared("elicitation") {
return false
}
if mode != "url" {
return true
if !AtLeast(p.Version, "2025-11-25") {
return true
}
var e struct {
Form json.RawMessage `json:"form"`
URL json.RawMessage `json:"url"`
}
if json.Unmarshal(p.Caps["elicitation"], &e) != nil {
return false
}
return len(e.Form) > 0 || len(e.URL) == 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve inline routing for URL-only clients

For a client on revision 2025-11-25 or later that declares only elicitation.url and no sampling, this change also makes AnswersInline() return false because it checks only CanElicit("form") || CanSample(). Consequently, canAsk in ask.go rejects the client and the request handlers bypass viaAsk, so supported URL questions are no longer relayed to that client, even though CanElicit("url") still returns true. Keep the stricter form check, but also include URL capability in AnswersInline() so URL-only clients retain their supported elicitation flow.

Useful? React with 👍 / 👎.

}
if !AtLeast(p.Version, "2025-11-25") {
return false
Expand Down
12 changes: 12 additions & 0 deletions pkgs/mcpx/internal/mcpserver/proto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ func TestAClientIsNeverSentSomethingItDidNotDeclare(t *testing.T) {
peer("2025-11-25", `{"elicitation":{"form":{}}}`), "url", false, false},
{"url mode declared on 2025-11-25",
peer("2025-11-25", `{"elicitation":{"url":{}}}`), "url", true, false},
{"url-only declaration refuses form on 2025-11-25",
peer("2025-11-25", `{"elicitation":{"url":{}}}`), "form", false, false},
{"form declared on 2025-11-25",
peer("2025-11-25", `{"elicitation":{"form":{}}}`), "form", true, false},
{"both modes declared on 2025-11-25, form allowed",
peer("2025-11-25", `{"elicitation":{"form":{},"url":{}}}`), "form", true, false},
{"empty declaration on 2025-11-25 is form-only",
peer("2025-11-25", `{"elicitation":{}}`), "form", true, false},
{"url-only on 2025-06-18 is still form -- sub-keys do not exist yet",
peer("2025-06-18", `{"elicitation":{"url":{}}}`), "form", true, false},
{"malformed declaration on 2025-11-25 reads as undeclared",
peer("2025-11-25", `{"elicitation":"yes"}`), "form", false, false},
{"nothing declared",
peer("2026-07-28", `{}`), "form", false, false},
{"sampling only",
Expand Down
Loading