Skip to content

fix: duplicate meta serialization#662

Open
DaleSeo wants to merge 1 commit intomodelcontextprotocol:mainfrom
DaleSeo:fix-duplicate-meta-serialization
Open

fix: duplicate meta serialization#662
DaleSeo wants to merge 1 commit intomodelcontextprotocol:mainfrom
DaleSeo:fix-duplicate-meta-serialization

Conversation

@DaleSeo
Copy link
Contributor

@DaleSeo DaleSeo commented Feb 16, 2026

Fixes #647

Motivation and Context

PR #617 (SEP-1319) added _meta fields to params structs, but WithMeta already injects _meta from extensions via #[serde(flatten)]. When both are populated, the serialized JSON contains duplicate _meta keys, which is invalid.

This PR replaces the derived Serialize on WithMeta with a manual implementation that extracts _meta from the flattened params, merges it with extensions _meta, and emits a single key. The fix is centralized in one place and covers all affected types. On conflict, extensions-level values take priority. No API changes; deserialization is unchanged.

How Has This Been Tested?

Add unit tests to verify the new behavior and prevent any regression.

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@github-actions github-actions bot added T-core Core library changes T-model Model/data structure changes labels Feb 16, 2026
@DaleSeo DaleSeo marked this pull request as ready for review February 16, 2026 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-core Core library changes T-model Model/data structure changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate _meta field during serialization when params already contains _meta (conflicts with WithMeta injection)

1 participant