fix(model): deprecate ServerInfo and ClientInfo aliases (#1156)

* fix(model): deprecate ServerInfo and ClientInfo aliases

Those names collide with the protocol's serverInfo/clientInfo fields,
which are only Implementation identity. Prefer InitializeResult and
InitializeRequestParams. Handler trait signatures, the tool_handler
macro output, tests, examples and docs now use the canonical types; the
aliases remain as deprecated shims for the rest of 3.x.

Fixes #1082

* fix(model): keep public signatures on the deprecated aliases

The public API check compares rendered signatures, and rustdoc records a
type alias by the name it was written with. Respelling
`ServerHandler::get_info`, `ClientHandler::get_info`,
`DiscoverResult::from_server_info` and `impl ClientHandler for ClientInfo`
onto `InitializeResult`/`InitializeRequestParams` therefore reads as
changed public items even though the aliases resolve to those exact types
and nothing downstream breaks.

Put those four signatures back on the aliases so the published API is
byte-identical, and note why at the alias definitions. The deprecation
still steers new code, and the macro output, tests, examples and docs
keep using the canonical names.

* fix(model): migrate leftover ClientInfo test sites

Two tests landed on main after the alias deprecation and still named
ClientInfo. Clippy -D warnings and the no-local feature test job both
failed on them.
This commit is contained in:
Teddy Tennant 2026-09-12 12:11:30 -04:00 • committed by GitHub
commit 3075dc9152
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 323 additions and 286 deletions

View file

@ -3,7 +3,7 @@ use std::env;
use anyhow::{Context, Result};
use rmcp::{
ServiceExt,
model::ClientInfo,
model::InitializeRequestParams,
transport::{
StreamableHttpClientTransport,
auth::{AuthClient, ClientCredentialsConfig, OAuthState},
@ -73,7 +73,7 @@ async fn main() -> Result<()> {
);
// Connect to MCP server and list tools
let client_service = ClientInfo::default();
let client_service = InitializeRequestParams::default();
let client = client_service.serve(transport).await?;
tracing::info!("Connected to MCP server");

View file

@ -9,7 +9,7 @@ use axum::{
};
use rmcp::{
RoleClient, ServiceExt,
model::ClientInfo,
model::InitializeRequestParams,
service::RunningService,
transport::{
StreamableHttpClientTransport,
@ -58,7 +58,7 @@ async fn callback_handler(
enum ConnectOutcome {
/// The server accepted the unauthenticated connection.
Connected(RunningService<RoleClient, ClientInfo>),
Connected(RunningService<RoleClient, InitializeRequestParams>),
/// The server answered 401; authorize with this `WWW-Authenticate`
/// challenge and reconnect.
AuthRequired(String),
@ -72,7 +72,7 @@ async fn try_connect(http_client: reqwest::Client, server_url: &str) -> Result<C
http_client,
StreamableHttpClientTransportConfig::with_uri(server_url),
);
match ClientInfo::default().serve(transport).await {
match InitializeRequestParams::default().serve(transport).await {
Ok(client) => Ok(ConnectOutcome::Connected(client)),
Err(error) => match error.auth_challenge() {
Some(challenge) => Ok(ConnectOutcome::AuthRequired(challenge.to_string())),
@ -90,7 +90,7 @@ async fn authorize_and_connect(
client_metadata_url: &str,
code_receiver: oneshot::Receiver<CallbackParams>,
output: &mut BufWriter<tokio::io::Stdout>,
) -> Result<RunningService<RoleClient, ClientInfo>> {
) -> Result<RunningService<RoleClient, InitializeRequestParams>> {
tracing::info!("Server requires authorization: {challenge}");
// initialize oauth state machine
@ -156,7 +156,7 @@ async fn authorize_and_connect(
auth_client,
StreamableHttpClientTransportConfig::with_uri(server_url),
);
Ok(ClientInfo::default().serve(transport).await?)
Ok(InitializeRequestParams::default().serve(transport).await?)
}
#[tokio::main]