fix: preserve open capability and subscription fields - #1170
Open
muxammadreza wants to merge 6 commits into
Open
fix: preserve open capability and subscription fields#1170muxammadreza wants to merge 6 commits into
muxammadreza wants to merge 6 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates RMCP’s MCP model handling to preserve open-set capability objects and extension-owned subscription filter fields across serde round trips, ensuring intermediaries don’t drop unknown protocol data and that handler-accepted extension fields remain authoritative.
Changes:
- Preserve unknown top-level fields in
ClientCapabilitiesandServerCapabilitiesvia flattened JSON object storage. - Preserve extension-owned
SubscriptionFilterfields and ensure they survive intersection/capability filtering flows. - Add tests covering serde round-trips for extension fields and handler-accepted subscription acknowledgements.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/rmcp/tests/test_subscriptions.rs | Adds an integration test ensuring extension-owned subscription fields are acknowledged exactly as accepted by the handler. |
| crates/rmcp/tests/test_subscriptions_model.rs | Adds a unit test verifying extension-owned subscription fields survive serde deserialize/serialize. |
| crates/rmcp/src/model/capabilities.rs | Adds #[serde(flatten)] storage for unknown capability fields and adjusts builder construction to remain forward-compatible. |
| crates/rmcp/src/model.rs | Adds SubscriptionFilter support for extension-owned fields and updates subset/intersection/support filtering logic accordingly. |
| crates/rmcp/src/handler/server.rs | Updates server subscription acceptance flow to preserve handler-accepted extension fields while still filtering core categories by advertised capabilities. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+1965
to
+1969
| let additional_fields = other | ||
| .additional_fields | ||
| .iter() | ||
| .filter(|(key, _)| self.additional_fields.contains_key(*key)) | ||
| .map(|(key, value)| (key.clone(), value.clone())) |
Comment on lines
1927
to
+1936
| #[serde(default, skip_serializing_if = "Option::is_none")] | ||
| #[cfg_attr(feature = "schemars", schemars(with = "Vec<String>"))] | ||
| pub resource_subscriptions: Option<Vec<String>>, | ||
| /// Extension-owned subscription filter entries not modeled by the core SDK. | ||
| /// | ||
| /// The server handler remains responsible for validating and accepting | ||
| /// these values. Core capability filtering preserves handler-accepted | ||
| /// extension fields instead of interpreting their schemas. | ||
| #[serde(flatten)] | ||
| pub additional_fields: JsonObject, |
muxammadreza
force-pushed
the
feat/open-world-capability-preservation
branch
from
August 13, 2026 21:39
ef57c12 to
3e42416
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ClientCapabilitiesandServerCapabilitiesthrough serde round tripsSubscriptionFilterfields without teaching core RMCP extension semanticsMCP capability objects are open sets, and extension contracts may augment subscription filters. Intermediaries otherwise lose protocol data during typed decode/re-encode.
Tests
cargo test -p rmcp --lib model::capabilities::test -- --nocapturecargo test -p rmcp --test test_subscriptions_model -- --nocapturecargo test -p rmcp --test test_subscriptions --features client,server,transport-io -- --nocapturecargo fmt --all -- --checkgit diff --check