Skip to content

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

Open
ragen1337 wants to merge 1 commit into
modelcontextprotocol:mainfrom
ragen1337:fix/no-default-features-dead-code
Open

ragen1337 wants to merge 1 commit 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 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
Comment on lines +76 to +79
cargo clippy --package rmcp --lib -- -D warnings
cargo clippy --package rmcp --lib --no-default-features -- -D warnings
cargo clippy --package rmcp --lib --no-default-features --features client -- -D warnings
cargo clippy --package rmcp --lib --no-default-features --features server -- -D warnings

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.

Can we keep the guarantee from regressing as new features are added?

Suggested change
cargo clippy --package rmcp --lib -- -D warnings
cargo clippy --package rmcp --lib --no-default-features -- -D warnings
cargo clippy --package rmcp --lib --no-default-features --features client -- -D warnings
cargo clippy --package rmcp --lib --no-default-features --features server -- -D warnings
cargo hack clippy --package rmcp --lib --each-feature --exclude-features local -- -D warnings

Comment thread crates/rmcp/src/model.rs
#[cfg(feature = "transport-streamable-http-client")]
#[cfg(all(
feature = "transport-streamable-http-client",
any(feature = "client", feature = "server")

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.

I think this would describe the dependency more accurately.

Suggested change
any(feature = "client", feature = "server")
feature = "client"

This branch has not been deployed

No deployments
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