Repository navigation
fix: preserve open capability and subscription fields - #1170
muxammadreza wants to merge 6 commits into
Conversation
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.
| let additional_fields = other | ||
| .additional_fields | ||
| .iter() | ||
| .filter(|(key, _)| self.additional_fields.contains_key(*key)) | ||
| .map(|(key, value)| (key.clone(), value.clone())) |
| #[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, |
ef57c12 to
3e42416
Compare
|
This pull request has had no activity for 60 days and is now marked as stale. It will be closed in 14 days if there is no further activity. Add the |
|
Closing this pull request after 14 days of inactivity since it was marked stale. Feel free to reopen if you plan to continue the work. |
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