mcp: fix setProgressToken when Meta is nil (#846)

When `SetProgressToken` is called on a `Params` struct with a nil `Meta`
field, the newly created map is never assigned back to the struct via
`SetMeta`, causing the progress token to be silently lost.

Call `p.SetMeta(m)` after creating the new map so the struct retains the
reference.

Fixes #845

Co-authored-by: Maciej Kisiel <mkisiel@google.com>
This commit is contained in:
Steven Chen 2026-03-18 09:57:45 +00:00 • committed by GitHub
commit 48879f01c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -447,6 +447,7 @@ func setProgressToken(p Params, pt any) {
m := p.GetMeta()
if m == nil {
m = map[string]any{}
p.SetMeta(m)
}
m[progressTokenKey] = pt
}