Repository navigation
Conversation
The change is correct — Value.init(_:) only ever encodes its argument, so the Codable constraint is over-tight — but it fixes no bug, and unlike every other entry in the manifest its absence upstream is a compile error rather than a runtime fault. Fork code passing an Encodable-only type would not build against upstream unless modelcontextprotocol#227 lands there, turning the return this fork exists to make easy into a build break. No downstream needs the looser constraint today. Moved from the candidate table to 'Not included, and why'. Remaining candidates renumbered 7-10 to 6-9 so the intended order still continues the manifest sequence. modelcontextprotocol#278's note no longer calls itself the second Value.swift edit in the batch, since modelcontextprotocol#227 was the first. Tracking: fork issue #13, relabelled decline. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Eb9yGSXH1TVkg5Afsu9phk
… as entry 7a
Client.Capabilities.experimental was [String: String] where the 2025-11-25
schema defines a map of arbitrary objects, so a ChatGPT-shaped initialize
carrying {"openai/visibility": {"enabled": true}} failed to decode and the
server answered -32603 to a valid request. Reproduced on the wire before the
merge and confirmed fixed after.
The entry records what the PR description understates: the type change is
source-breaking for a typed [String: String] variable and for reading a value
back as String, and the extensions field it adds is a draft-schema capability
absent from 2025-11-25 — an unmodeled key already decoded fine, so that half
is a feature rather than a fix.
7a restores the typed-variable call site behind a deprecation warning. The
read direction cannot be shimmed by an initializer and still needs updating
downstream.
Remaining candidate modelcontextprotocol#278 renumbered 7 to 6.
Tracking: fork issue #11.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Eb9yGSXH1TVkg5Afsu9phk
…ontextprotocol#278, bitbemol) Manifest entry 8. Upstream refs/pull/278/head at af48e3f, unmodified. Value.init(from:) treated any parseable data-URL-looking JSON string as Value.data, silently changing both the case and the string's spelling. Content explicitly tagged as MCP text was corrupted on round trip: data:text/plain,Hello%20World came back as data:text/plain;base64,SGVsbG8gV29ybGQ=. Generic JSON carries no discriminator, and the spec tags content explicitly (TextContent.type is const "text"), so the decoder had no business guessing. The string branch now always produces .string. Data.isDataURL(string:) and Data.parseDataURL(_:) remain public for callers that want to opt in, and explicit Value.data encoding is unchanged. Verified by running the PR's own tests against the unpatched tree first: six of eight fail there, including typed text content corruption, and all eight pass after the merge. Behavior change, not a source break: no API signature moves, so fork code calling parseDataURL explicitly still compiles and behaves identically against upstream. Note Value.data is now round-trip-asymmetric — it encodes as a data URL but decodes back as .string, which the PR pins with a test. The unrelated NetworkTransport capture-list hunk (Task { @mainactor [self] in) is behaviorally inert and emits no warning on this toolchain; left as authored, review feedback for upstream. Fixes modelcontextprotocol#277. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Eb9yGSXH1TVkg5Afsu9phk
…mple to 0.12.2-ianegordon.8 Value.init(from:) treated any parseable data-URL-looking JSON string as Value.data, silently changing both the case and the string's spelling. Content explicitly tagged as MCP text was corrupted on round trip. The entry records the measured before/after (the PR's own tests fail six of eight against the unpatched tree, all eight pass after), that this is a behavior change rather than a source break with no return trap, and two caveats: Value.data is now round-trip-asymmetric, and the unrelated NetworkTransport capture-list hunk is inert and left as authored. The candidate table is now empty. Its section and header are kept, with a note that the next candidates come from the twelve upstream PRs triaged Investigate under the investigate label. Tracking: fork issue #12. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Eb9yGSXH1TVkg5Afsu9phk
|
Hi @bitbemol, thank you for this contribution. We're consolidating overlapping PRs. #295 makes the same We plan to close this PR once #295 is merged, so the fix isn't lost in between. If you think something here isn't covered by #295, please comment there or here and we'll make sure it's carried over. |
|
Hi @bitbemol, thank you for this PR, and for the care you put into the data-URL fix! We have just opened the Swift SDK 1.0.0 release (#372, branch What 1.0.0 does not cover yet: a plain If you are still interested, we would welcome a PR for that remaining piece, rebased onto Thank you again for contributing. We would love to see more from you on the new stack! |
|
Sure thing ! I can move some of the code to the new release ! I appreciate your time reviewing my small PR |
Fixes #277.
Preserves JSON strings decoded through
Valueas.string, including strings that match data-URL syntax. ExplicitValue.dataencoding and the data-URL helper APIs remain available, and the public API documentation now clarifies that parsing is opt-in.Motivation and Context
Value.init(from:)currently interprets any parseable data-URL-looking JSON string as.data. Because generic JSON contains no discriminator between an ordinary string and an encodedValue.data, this can silently change both theValuecase and the string's spelling.For example:
This can also affect content explicitly tagged as MCP text when it passes through generic
Valueconversion.The change makes the string branch of
Value.init(from:)always produce.string. Applications that intentionally accept data URLs can continue to opt in throughData.parseDataURL(_:), while explicitly constructedValue.datavalues retain their existing encoding.How Has This Been Tested?
Added regression coverage for:
application/octet-streamdata-URL-looking stringsValue.dataencoding.datadiscriminator on the generic JSON wireValueerasureVerification performed:
swift test --filter ValueTests: 8/8 tests passedgit diff --check: cleanThe regression tests were also run against the previous decoder implementation to confirm that they reproduce the reported behavior.
Breaking Changes
This intentionally changes observable behavior for callers that relied on generic
Valuedecoding to automatically convert data-URL-looking JSON strings into.data.Those callers will need to explicitly call
Data.parseDataURL(_:)in fields where data URLs are expected. Encoding an explicitly constructedValue.dataremains unchanged, as does typed image and audio content serialization.Types of changes
Checklist
Additional context
This behavior was encountered in bitbemol/second-brain-mcp, which currently vendors the patched SDK pending an upstream resolution.
This is my first contribution to
swift-sdk. I may be missing context behind the original implicit decoding behavior and am happy to adjust the approach based on maintainer feedback.AI assistance disclosure: This bug was initially identified with LLM assistance, and Codex assisted with implementation analysis and regression-test development. I personally reviewed the relevant SDK behavior, reproduced the failure in Xcode with the previous decoder, and verified the fix with the complete test suite.