Skip to content

fix(rmcp): gate client- and server-only helpers behind their features - #1329

Merged
DaleSeo merged 2 commits into
modelcontextprotocol:mainfrom
ragen1337:fix/no-default-features-dead-code
Oct 11, 2026
Merged

DaleSeo merged 2 commits into
modelcontextprotocol:mainfrom
ragen1337:fix/no-default-features-dead-code

Conversation

@ragen1337

Copy link
Copy Markdown
Contributor

Follow-up to my comment in #1314.

Some crate-internal helpers are only called from client or server code, so building rmcp with fewer features fails under -D warnings:

RUSTFLAGS="-D warnings" cargo check -p rmcp --lib --no-default-features
error: methods `numeric_string_value` and `matches_response_id` are never used
error: associated items `TRANSPORT_CLOSED_MARKER`, `is_transport_closed`, and `transport_closed_token` are never used

Default, client-only and server-only builds fail the same way on other helpers. I gated them with #[cfg], like send_subscription_request. ErrorData::transport_closed is only used by the streamable HTTP client, so it now also needs client or server.

CI didn't see it because both clippy steps enable client and server, and the no-default-features test job from #1318 doesn't use -D warnings. @chrikrah suggested a clippy step for this in #1314, so I added one. It's --lib only because some tests don't build with reduced features.

With -D warnings, no features and every single feature fail on main and pass here. Clippy and fmt pass. cargo test --all-features has the same 2 child_process failures as main for me. No API changes.

@ragen1337
ragen1337 requested a review from a team as a code owner October 7, 2026 15:42
@github-actions github-actions Bot added T-CI Changes to CI/CD workflows and configuration T-config Configuration file changes T-core Core library changes labels Oct 7, 2026
DaleSeo
DaleSeo previously approved these changes Oct 9, 2026

@DaleSeo DaleSeo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the following up, @ragen1337! I left a couple of minor comments.

Comment thread .github/workflows/ci.yml Outdated
Comment thread crates/rmcp/src/model.rs Outdated
Lint every rmcp feature on its own with cargo-hack instead of a fixed
list of feature sets, and install cargo-hack in the clippy job.

Gate ErrorData::transport_closed and its test on the client feature
only: the streamable HTTP client is its sole caller.

Co-authored-by: Dale Seo <5466341+DaleSeo@users.noreply.github.com>
@DaleSeo
DaleSeo merged commit 07ff92d into modelcontextprotocol:main Oct 11, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-CI Changes to CI/CD workflows and configuration T-config Configuration file changes T-core Core library changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants