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

View file

@ -719,7 +719,7 @@ async fn test_server_rejects_unsupported_protocol_version() {
use http_body_util::Full;
use rmcp::{
handler::server::ServerHandler,
model::{ServerCapabilities, ServerInfo},
model::{InitializeResult, ServerCapabilities},
transport::streamable_http_server::{
StreamableHttpServerConfig, StreamableHttpService, session::local::LocalSessionManager,
},
@ -730,8 +730,8 @@ async fn test_server_rejects_unsupported_protocol_version() {
struct TestHandler;
impl ServerHandler for TestHandler {
fn get_info(&self) -> ServerInfo {
ServerInfo::new(ServerCapabilities::builder().build())
fn get_info(&self) -> InitializeResult {
InitializeResult::new(ServerCapabilities::builder().build())
}
}
@ -892,7 +892,7 @@ async fn test_server_validates_host_when_origin_validation_is_disabled_by_defaul
use http_body_util::Full;
use rmcp::{
handler::server::ServerHandler,
model::{ServerCapabilities, ServerInfo},
model::{InitializeResult, ServerCapabilities},
transport::streamable_http_server::{
StreamableHttpServerConfig, StreamableHttpService, session::local::LocalSessionManager,
},
@ -903,8 +903,8 @@ async fn test_server_validates_host_when_origin_validation_is_disabled_by_defaul
struct TestHandler;
impl ServerHandler for TestHandler {
fn get_info(&self) -> ServerInfo {
ServerInfo::new(ServerCapabilities::builder().build())
fn get_info(&self) -> InitializeResult {
InitializeResult::new(ServerCapabilities::builder().build())
}
}
@ -975,7 +975,7 @@ async fn test_server_validates_host_header_port_for_dns_rebinding_protection() {
use http_body_util::Full;
use rmcp::{
handler::server::ServerHandler,
model::{ServerCapabilities, ServerInfo},
model::{InitializeResult, ServerCapabilities},
transport::streamable_http_server::{
StreamableHttpServerConfig, StreamableHttpService, session::local::LocalSessionManager,
},
@ -986,8 +986,8 @@ async fn test_server_validates_host_header_port_for_dns_rebinding_protection() {
struct TestHandler;
impl ServerHandler for TestHandler {
fn get_info(&self) -> ServerInfo {
ServerInfo::new(ServerCapabilities::builder().build())
fn get_info(&self) -> InitializeResult {
InitializeResult::new(ServerCapabilities::builder().build())
}
}
@ -1046,7 +1046,7 @@ async fn test_server_falls_back_to_uri_authority_when_host_header_missing() {
use http_body_util::Full;
use rmcp::{
handler::server::ServerHandler,
model::{ServerCapabilities, ServerInfo},
model::{InitializeResult, ServerCapabilities},
transport::streamable_http_server::{
StreamableHttpServerConfig, StreamableHttpService, session::local::LocalSessionManager,
},
@ -1057,8 +1057,8 @@ async fn test_server_falls_back_to_uri_authority_when_host_header_missing() {
struct TestHandler;
impl ServerHandler for TestHandler {
fn get_info(&self) -> ServerInfo {
ServerInfo::new(ServerCapabilities::builder().build())
fn get_info(&self) -> InitializeResult {
InitializeResult::new(ServerCapabilities::builder().build())
}
}
@ -1132,7 +1132,7 @@ mod origin_validation {
use http_body_util::Full;
use rmcp::{
handler::server::ServerHandler,
model::{ServerCapabilities, ServerInfo},
model::{InitializeResult, ServerCapabilities},
transport::streamable_http_server::{
StreamableHttpServerConfig, StreamableHttpService, session::local::LocalSessionManager,
},
@ -1143,8 +1143,8 @@ mod origin_validation {
struct TestHandler;
impl ServerHandler for TestHandler {
fn get_info(&self) -> ServerInfo {
ServerInfo::new(ServerCapabilities::builder().build())
fn get_info(&self) -> InitializeResult {
InitializeResult::new(ServerCapabilities::builder().build())
}
}