Skip to content

async-trait: make it an optional dependency #1112

Description

@bug-ops

Problem

async-trait is declared as an unconditional dependency in crates/rmcp/Cargo.toml, but
every use of it sits behind non-default features:

  • CredentialStore / StateStore (transport/auth.rs) — feature auth
  • EventStore / SessionStore (session/store.rs) — feature transport-streamable-http-server-session

Default features (base64, macros, server) pull in neither, yet the proc-macro crate
still compiles for every consumer:

$ cargo tree -p rmcp -e normal --no-default-features --features base64,macros,server -i async-trait
async-trait (proc-macro)
└── rmcp

Proposal

# crates/rmcp/Cargo.toml
async-trait = { version = "0.1.89", optional = true }

[features]
auth = [..., "dep:async-trait"]
transport-streamable-http-server-session = [..., "dep:async-trait"]

Dev-dependency stays as-is (used directly by the event/session store integration tests).
Non-breaking, no public API change — trims the default build graph only.

Activity

  1. bug-ops commented on Aug 1, 2026

    @bug-ops
    ContributorAuthor

    Why not remove it entirely?

    All 15 #[async_trait] sites are on traits consumed as Arc<dyn Trait>. Async fn in traits
    (stable since 1.75, below our MSRV) doesn't apply — it isn't dyn-compatible, and no
    async_fn_in_dyn_trait stabilization exists yet. The traits that don't need dyn dispatch
    (Service, ServerHandler, ClientHandler, Transport) are already on hand-written RPITIT
    with a MaybeSendFuture marker (service.rs:31-40) — that migration is done; this is what's
    left over, by design.

    Hand-boxing the remaining 4 traits (pattern already exists for Service/DynService,
    service.rs:323-437) would add what the macro generates.

  2. self-assigned this
    on Aug 3, 2026
  3. added
    T-dependenciesDependencies related changes
    T-configConfiguration file changes
    P3Low: nice-to-have, long-term, or exploratory
    ready for workIssue is well-defined and ready to be picked up
    on Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3Low: nice-to-have, long-term, or exploratoryT-configConfiguration file changesT-dependenciesDependencies related changesready for workIssue is well-defined and ready to be picked up

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions