Skip to content

public accessors use get_ prefix, inconsistent with Rust API guidelines (C-GETTER) #3

Description

@bug-ops

Description

Rust API naming conventions (C-GETTER) call for simple accessors to be named after the field/value they return, without a get_ prefix (user.name() not user.get_name()). Several public methods in this crate use the get_ prefix for what are plain field/derived-value accessors, which is inconsistent with the rest of the crate's accessor naming (e.g. CompletionInfo::has_more_results, CompletionInfo::total_available in the same file use the idiomatic style) and with the wider Rust ecosystem's expectations.

Reproduction Steps

  1. rg -n "pub fn get_[a-z_]+\(" crates/rmcp/src
  2. Compare against neighboring accessors in the same types that already follow C-GETTER (no get_ prefix).

Expected Behavior

Simple accessors follow C-GETTER: argument(), text(), traceparent(), tracestate(), baggage(), progress_token(), required_scope(), authorization_url().

Actual Behavior

Named get_argument, get_text, get_traceparent, get_tracestate, get_baggage, get_progress_token, get_required_scope, get_authorization_url.

Environment

  • Version: v3.1.2 (current main, commit 02c62ae)
  • Features: N/A

Locations

  • crates/rmcp/src/model.rs:3180Prompt::get_argument (or similar; simple field lookup)
  • crates/rmcp/src/model/content.rs:160get_text
  • crates/rmcp/src/model/meta.rs:271,292,302,436get_traceparent, get_tracestate, get_baggage, get_progress_token
  • crates/rmcp/src/transport/streamable_http_client.rs:167get_required_scope
  • crates/rmcp/src/transport/auth.rs:3417get_authorization_url
  • crates/rmcp/src/task_manager.rs:402get_task (borderline: does a lookup by id, get_task-style naming may be acceptable here similar to HashMap::get)

Not flagged: transport/auth.rs:489 get_access_token — this performs actual async work (token fetch/refresh), not a field read, so get_ more plausibly signals "go fetch" rather than "read a field."

Note on breaking change

Renaming these is a public API break — needs !:/BREAKING CHANGE: marker and cargo public-api diff / cargo semver-checks will need updated baselines. Consider batching with another planned breaking-change release rather than a standalone patch.

Upstream

None found — searched modelcontextprotocol/rust-sdk issues and PRs (all states) for "get_ getter naming" with no matches.

Logs / Evidence

N/A — static analysis / naming-convention finding.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Medium: suboptimal behavior, minor inconsistencycode-qualityCode quality and maintainabilityenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions