Skip to content

refactor: remove unused axum dependency from server-side-http feature#642

Open
andrewgazelka wants to merge 2 commits intomodelcontextprotocol:mainfrom
andrewgazelka:remove-axum-dependency
Open

refactor: remove unused axum dependency from server-side-http feature#642
andrewgazelka wants to merge 2 commits intomodelcontextprotocol:mainfrom
andrewgazelka:remove-axum-dependency

Conversation

@andrewgazelka
Copy link

@andrewgazelka andrewgazelka commented Feb 3, 2026

Summary

The server-side-http feature included dep:axum but axum was never actually used in the rmcp library source code (verified: 0 references found via grep).

The StreamableHttpService is a tower service that works with any HTTP server framework. Users can choose to use:

  • axum (via Router::nest_service() or fallback_service())
  • hyper directly (via hyper_util::service::TowerToHyperService)
  • any other tower-compatible HTTP server

Motivation

This came up while integrating rmcp into nushell (PR #17161) - a reviewer raised concerns about adding axum as a dependency. After investigation, we found that:

  1. StreamableHttpService only uses tower_service::Service trait
  2. axum is listed as a dependency but has 0 actual usages in rmcp source
  3. Examples that use axum already have their own explicit dependency

Changes

  • Remove dep:axum from the server-side-http feature in crates/rmcp/Cargo.toml

Testing

  • cargo build -p rmcp --features "transport-streamable-http-server"
  • cargo test -p rmcp --all-features
  • Examples still work (they have their own axum dependency)

Impact

Users who want to use axum can add it as a direct dependency (as the examples do). Users who prefer hyper or another tower-compatible server no longer have axum as a transitive dependency.

The `server-side-http` feature included `dep:axum` but axum was never
actually used in the rmcp library source code (0 references found).

The `StreamableHttpService` is a tower service that works with any
HTTP server framework. Users can choose to use:
- axum (via `Router::nest_service()` or `fallback_service()`)
- hyper directly (via `hyper_util::service::TowerToHyperService`)
- any other tower-compatible HTTP server

This change removes the unnecessary transitive dependency, giving users
more flexibility in their choice of HTTP server framework.

Examples that use axum already have their own explicit axum dependency
in their Cargo.toml, so they continue to work unchanged.
@github-actions github-actions bot added T-dependencies Dependencies related changes T-config Configuration file changes labels Feb 3, 2026
Copy link

Choose a reason for hiding this comment

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

I was actually about to open a PR but didn't realize the dependency is unused. If we aren't removing this dependency definition, could you incorporate my would-be change?

Suggested change
axum = { version = "0.8", default-features = false, features = ["http1", "tokio"], optional = true }

Copy link
Collaborator

Choose a reason for hiding this comment

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

@andrewgazelka @ofek Yeah something like this makes sense.

It looks like it might only be used in crates/rmcp/tests?

- Remove axum from library dependencies (not used in library source)
- Add axum to dev-dependencies for tests with minimal features:
  default-features = false, features = ["http1", "tokio"]
- Examples have their own axum dependency and are unaffected

This addresses review feedback from @ofek to use minimal features,
while ensuring axum is only bundled for running rmcp's own tests,
not for downstream users.
@andrewgazelka
Copy link
Author

🦾: Thanks for the feedback! 2a29c55

After looking closer, I realized axum is only used in the tests (not the library source itself), so I've moved it to dev-dependencies instead with the minimal features @ofek suggested:

[dev-dependencies]
axum = { version = "0.8", default-features = false, features = ["http1", "tokio"] }

This way:

  • Library users don't get axum as a transitive dependency at all
  • rmcp's own tests still work (they use axum to spin up test servers)
  • Examples are unaffected (they have their own axum dependency)

Verified:

  • cargo build -p rmcp --features "transport-streamable-http-server"
  • cargo test -p rmcp --all-features
  • cargo build -p mcp-server-examples --examples
  • cargo build -p mcp-client-examples --examples

@andrewgazelka
Copy link
Author

andrewgazelka commented Feb 4, 2026

any thoughts on adding proper CI to rust-sdk as well? I suppose could have merged without realizing it was used in a test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-config Configuration file changes T-dependencies Dependencies related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants