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:
parent
a5d1169e20
commit
3075dc9152
35 changed files with 323 additions and 286 deletions
|
|
@ -2,7 +2,7 @@
|
|||
use rmcp::{
|
||||
ServerHandler,
|
||||
handler::server::{router::tool::ToolRouter, wrapper::Parameters},
|
||||
model::{ServerCapabilities, ServerInfo},
|
||||
model::{InitializeResult, ServerCapabilities},
|
||||
schemars, tool, tool_router,
|
||||
};
|
||||
#[derive(Debug, serde::Deserialize, schemars::JsonSchema)]
|
||||
|
|
@ -52,8 +52,8 @@ impl Calculator {
|
|||
}
|
||||
|
||||
impl ServerHandler for Calculator {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().enable_tools().build())
|
||||
.with_instructions("A simple calculator")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,8 +115,8 @@ impl TestServer {
|
|||
|
||||
impl ServerHandler for TestServer {
|
||||
#[allow(deprecated)]
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::new(ServerCapabilities::builder().enable_logging().build())
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().enable_logging().build())
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ use std::{collections::BTreeSet, process::Stdio, time::Duration};
|
|||
use rmcp::{
|
||||
ErrorData as McpError, RoleServer, ServerHandler, ServiceExt,
|
||||
model::{
|
||||
CallToolRequestParams, CallToolResponse, CallToolResult, ContentBlock, ServerCapabilities,
|
||||
ServerInfo,
|
||||
CallToolRequestParams, CallToolResponse, CallToolResult, ContentBlock, InitializeResult,
|
||||
ServerCapabilities,
|
||||
},
|
||||
service::RequestContext,
|
||||
};
|
||||
|
|
@ -91,8 +91,8 @@ async fn cancelled_request_receives_no_response() -> anyhow::Result<()> {
|
|||
struct WaitForCancelServer;
|
||||
|
||||
impl ServerHandler for WaitForCancelServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().enable_tools().build())
|
||||
}
|
||||
|
||||
async fn call_tool(
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use axum::{
|
|||
};
|
||||
use rmcp::{
|
||||
ClientLifecycleMode, ClientServiceExt, ServerHandler,
|
||||
model::{ClientInfo, DiscoverResult, ErrorCode, ErrorData, ProtocolVersion},
|
||||
model::{DiscoverResult, ErrorCode, ErrorData, InitializeRequestParams, ProtocolVersion},
|
||||
service::{MaybeSendFuture, RequestContext, RoleServer},
|
||||
transport::{
|
||||
StreamableHttpClientTransport,
|
||||
|
|
@ -132,7 +132,7 @@ async fn discover_http_client_bootstraps_headers_without_initialize() {
|
|||
let transport = StreamableHttpClientTransport::from_config(
|
||||
StreamableHttpClientTransportConfig::with_uri(format!("http://{address}/mcp")),
|
||||
);
|
||||
let client = ClientInfo::default()
|
||||
let client = InitializeRequestParams::default()
|
||||
.serve_with_lifecycle(
|
||||
transport,
|
||||
ClientLifecycleMode::Discover {
|
||||
|
|
@ -176,7 +176,7 @@ async fn auto_http_client_falls_back_to_stateful_legacy_startup() {
|
|||
let transport = StreamableHttpClientTransport::from_config(
|
||||
StreamableHttpClientTransportConfig::with_uri(format!("http://{address}/mcp")),
|
||||
);
|
||||
let client = ClientInfo::default()
|
||||
let client = InitializeRequestParams::default()
|
||||
.serve_with_lifecycle(
|
||||
transport,
|
||||
ClientLifecycleMode::Auto {
|
||||
|
|
@ -217,7 +217,7 @@ async fn auto_http_client_falls_back_after_plain_text_4xx_rejection() {
|
|||
let transport = StreamableHttpClientTransport::from_config(
|
||||
StreamableHttpClientTransportConfig::with_uri(format!("http://{address}/mcp")),
|
||||
);
|
||||
let client = ClientInfo::default()
|
||||
let client = InitializeRequestParams::default()
|
||||
.serve_with_lifecycle(
|
||||
transport,
|
||||
ClientLifecycleMode::Auto {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ use rmcp::{
|
|||
ClientHandler, RoleClient, RoleServer, ServerHandler,
|
||||
handler::server::router::{prompt::PromptRouter, tool::ToolRouter},
|
||||
model::{
|
||||
CacheScope, ClientInfo, ListPromptsResult, ListToolsResult, ProtocolVersion, ServerInfo,
|
||||
CacheScope, InitializeRequestParams, InitializeResult, ListPromptsResult, ListToolsResult,
|
||||
ProtocolVersion,
|
||||
},
|
||||
prompt_handler,
|
||||
service::serve_directly,
|
||||
|
|
@ -37,8 +38,8 @@ struct VersionedClient {
|
|||
}
|
||||
|
||||
impl ClientHandler for VersionedClient {
|
||||
fn get_info(&self) -> ClientInfo {
|
||||
let mut info = ClientInfo::default();
|
||||
fn get_info(&self) -> InitializeRequestParams {
|
||||
let mut info = InitializeRequestParams::default();
|
||||
info.protocol_version = self.protocol_version.clone();
|
||||
info
|
||||
}
|
||||
|
|
@ -53,7 +54,7 @@ async fn list_results(protocol_version: ProtocolVersion) -> (ListToolsResult, Li
|
|||
let client_handler = VersionedClient {
|
||||
protocol_version: protocol_version.clone(),
|
||||
};
|
||||
let mut server_peer_info = ServerInfo::default();
|
||||
let mut server_peer_info = InitializeResult::default();
|
||||
server_peer_info.protocol_version = protocol_version;
|
||||
|
||||
let server = serve_directly::<RoleServer, _, _, _, _>(
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use std::{
|
|||
use rmcp::{
|
||||
ServerHandler, ServiceExt,
|
||||
handler::server::{router::tool::ToolRouter, wrapper::Parameters},
|
||||
model::{CallToolRequestParams, ClientInfo, ServerCapabilities, ServerInfo},
|
||||
model::{CallToolRequestParams, InitializeRequestParams, InitializeResult, ServerCapabilities},
|
||||
service::QuitReason,
|
||||
tool, tool_handler, tool_router,
|
||||
};
|
||||
|
|
@ -55,8 +55,8 @@ impl SlowToolServer {
|
|||
|
||||
#[tool_handler]
|
||||
impl ServerHandler for SlowToolServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().enable_tools().build())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -64,8 +64,8 @@ impl ServerHandler for SlowToolServer {
|
|||
struct DummyClientHandler;
|
||||
|
||||
impl rmcp::ClientHandler for DummyClientHandler {
|
||||
fn get_info(&self) -> ClientInfo {
|
||||
ClientInfo::default()
|
||||
fn get_info(&self) -> InitializeRequestParams {
|
||||
InitializeRequestParams::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,8 +114,8 @@ impl MacroMrtrServer {
|
|||
|
||||
#[tool_handler]
|
||||
impl ServerHandler for MacroMrtrServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
let mut info = ServerInfo::new(ServerCapabilities::builder().enable_tools().build());
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
let mut info = InitializeResult::new(ServerCapabilities::builder().enable_tools().build());
|
||||
info.protocol_version = ProtocolVersion::V_2026_07_28;
|
||||
info
|
||||
}
|
||||
|
|
@ -221,8 +221,8 @@ impl MrtrServer {
|
|||
}
|
||||
|
||||
impl ServerHandler for MrtrServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
let mut info = ServerInfo::new(
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
let mut info = InitializeResult::new(
|
||||
ServerCapabilities::builder()
|
||||
.enable_tools()
|
||||
.enable_prompts()
|
||||
|
|
@ -328,16 +328,16 @@ impl ClientHandler for MrtrClient {
|
|||
// Harness
|
||||
// =============================================================================
|
||||
|
||||
fn client_info(protocol_version: ProtocolVersion) -> ClientInfo {
|
||||
ClientInfo::new(
|
||||
fn client_info(protocol_version: ProtocolVersion) -> InitializeRequestParams {
|
||||
InitializeRequestParams::new(
|
||||
ClientCapabilities::builder().enable_elicitation().build(),
|
||||
Implementation::new("mrtr-test-client", "0.0.0"),
|
||||
)
|
||||
.with_protocol_version(protocol_version)
|
||||
}
|
||||
|
||||
fn server_info(protocol_version: ProtocolVersion) -> ServerInfo {
|
||||
let mut info = ServerInfo::new(ServerCapabilities::builder().enable_tools().build());
|
||||
fn server_info(protocol_version: ProtocolVersion) -> InitializeResult {
|
||||
let mut info = InitializeResult::new(ServerCapabilities::builder().enable_tools().build());
|
||||
info.protocol_version = protocol_version;
|
||||
info
|
||||
}
|
||||
|
|
@ -609,8 +609,9 @@ async fn request_state_codec_seals_and_verifies_through_the_loop() -> anyhow::Re
|
|||
struct SealingServer;
|
||||
|
||||
impl ServerHandler for SealingServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
let mut info = ServerInfo::new(ServerCapabilities::builder().enable_tools().build());
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
let mut info =
|
||||
InitializeResult::new(ServerCapabilities::builder().enable_tools().build());
|
||||
info.protocol_version = ProtocolVersion::V_2026_07_28;
|
||||
info
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ use std::sync::Arc;
|
|||
use rmcp::{
|
||||
ClientHandler, ServerHandler, ServiceExt,
|
||||
model::{
|
||||
ClientNotification, CustomNotification, ResourceUpdatedNotificationParam,
|
||||
ServerCapabilities, ServerInfo, ServerNotification, SubscribeRequestParams,
|
||||
ClientNotification, CustomNotification, InitializeResult, ResourceUpdatedNotificationParam,
|
||||
ServerCapabilities, ServerNotification, SubscribeRequestParams,
|
||||
},
|
||||
};
|
||||
use serde_json::json;
|
||||
|
|
@ -16,8 +16,8 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
|||
struct Server {}
|
||||
|
||||
impl ServerHandler for Server {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::new(
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(
|
||||
ServerCapabilities::builder()
|
||||
.enable_resources()
|
||||
.enable_resources_subscribe()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ use rmcp::{
|
|||
ClientHandler, ServerHandler, ServiceExt,
|
||||
handler::server::{router::prompt::PromptRouter, wrapper::Parameters},
|
||||
model::{
|
||||
ClientInfo, ContentBlock, GetPromptRequestParams, GetPromptResult, PromptMessage, Role,
|
||||
ContentBlock, GetPromptRequestParams, GetPromptResult, InitializeRequestParams,
|
||||
PromptMessage, Role,
|
||||
},
|
||||
prompt, prompt_handler, prompt_router,
|
||||
};
|
||||
|
|
@ -297,8 +298,8 @@ fn test_optional_field_schema_generation_via_macro() {
|
|||
struct DummyClientHandler {}
|
||||
|
||||
impl ClientHandler for DummyClientHandler {
|
||||
fn get_info(&self) -> ClientInfo {
|
||||
ClientInfo::default()
|
||||
fn get_info(&self) -> InitializeRequestParams {
|
||||
InitializeRequestParams::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ use std::{
|
|||
use rmcp::{
|
||||
ClientHandler, ErrorData, RoleServer, ServerHandler, ServiceExt,
|
||||
model::{
|
||||
ClientCapabilities, ClientInfo, ErrorCode, Implementation, InitializeRequestParams,
|
||||
InitializeResult, ProtocolVersion, ServerInfo,
|
||||
ClientCapabilities, ErrorCode, Implementation, InitializeRequestParams, InitializeResult,
|
||||
ProtocolVersion,
|
||||
},
|
||||
service::{ClientInitializeError, RequestContext},
|
||||
};
|
||||
|
|
@ -26,8 +26,8 @@ use rmcp::{
|
|||
struct EchoServer;
|
||||
|
||||
impl ServerHandler for EchoServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::default()
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -45,8 +45,8 @@ const HANDSHAKE_VERSIONS: &[ProtocolVersion] = &[
|
|||
struct NarrowedServer;
|
||||
|
||||
impl ServerHandler for NarrowedServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::default()
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::default()
|
||||
}
|
||||
|
||||
fn supported_protocol_versions(&self) -> Cow<'static, [ProtocolVersion]> {
|
||||
|
|
@ -61,8 +61,8 @@ struct ModernOnlyServer;
|
|||
const MODERN_ONLY_VERSIONS: &[ProtocolVersion] = &[ProtocolVersion::V_2026_07_28];
|
||||
|
||||
impl ServerHandler for ModernOnlyServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
let mut info = ServerInfo::default();
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
let mut info = InitializeResult::default();
|
||||
info.protocol_version = ProtocolVersion::V_2026_07_28;
|
||||
info
|
||||
}
|
||||
|
|
@ -79,8 +79,8 @@ impl ServerHandler for ModernOnlyServer {
|
|||
struct NarrowedOverridingServer;
|
||||
|
||||
impl ServerHandler for NarrowedOverridingServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::default()
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::default()
|
||||
}
|
||||
|
||||
fn supported_protocol_versions(&self) -> Cow<'static, [ProtocolVersion]> {
|
||||
|
|
@ -102,8 +102,8 @@ struct VersionedClient {
|
|||
}
|
||||
|
||||
impl ClientHandler for VersionedClient {
|
||||
fn get_info(&self) -> ClientInfo {
|
||||
let mut info = ClientInfo::default();
|
||||
fn get_info(&self) -> InitializeRequestParams {
|
||||
let mut info = InitializeRequestParams::default();
|
||||
info.protocol_version = self.protocol_version.clone();
|
||||
info
|
||||
}
|
||||
|
|
@ -247,8 +247,8 @@ struct DelegatingServer {
|
|||
}
|
||||
|
||||
impl ServerHandler for DelegatingServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::default()
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::default()
|
||||
}
|
||||
|
||||
fn supported_protocol_versions(&self) -> Cow<'static, [ProtocolVersion]> {
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
use rmcp::{
|
||||
ClientHandler, RoleClient, RoleServer, ServerHandler, ServiceError,
|
||||
model::{
|
||||
ClientInfo, ErrorCode, ErrorData, ProtocolVersion, ReadResourceRequestParams,
|
||||
ReadResourceResponse, ServerInfo,
|
||||
ErrorCode, ErrorData, InitializeRequestParams, InitializeResult, ProtocolVersion,
|
||||
ReadResourceRequestParams, ReadResourceResponse,
|
||||
},
|
||||
service::{RequestContext, serve_directly},
|
||||
};
|
||||
|
|
@ -33,8 +33,8 @@ struct VersionedClient {
|
|||
}
|
||||
|
||||
impl ClientHandler for VersionedClient {
|
||||
fn get_info(&self) -> ClientInfo {
|
||||
let mut info = ClientInfo::default();
|
||||
fn get_info(&self) -> InitializeRequestParams {
|
||||
let mut info = InitializeRequestParams::default();
|
||||
info.protocol_version = self.protocol_version.clone();
|
||||
info
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ async fn not_found_code(client_version: ProtocolVersion) -> ErrorCode {
|
|||
let client_handler = VersionedClient {
|
||||
protocol_version: client_version.clone(),
|
||||
};
|
||||
let mut server_peer_info = ServerInfo::default();
|
||||
let mut server_peer_info = InitializeResult::default();
|
||||
server_peer_info.protocol_version = client_version;
|
||||
|
||||
let server = serve_directly::<RoleServer, _, _, _, _>(
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
use rmcp::{
|
||||
ClientHandler, RoleClient, RoleServer, ServerHandler,
|
||||
model::{
|
||||
CallToolRequestParams, CallToolResponse, CallToolResult, ClientInfo, ContentBlock,
|
||||
ErrorData, ProtocolVersion, ResultType, ServerInfo,
|
||||
CallToolRequestParams, CallToolResponse, CallToolResult, ContentBlock, ErrorData,
|
||||
InitializeRequestParams, InitializeResult, ProtocolVersion, ResultType,
|
||||
},
|
||||
service::{RequestContext, serve_directly},
|
||||
};
|
||||
|
|
@ -33,8 +33,8 @@ struct VersionedClient {
|
|||
}
|
||||
|
||||
impl ClientHandler for VersionedClient {
|
||||
fn get_info(&self) -> ClientInfo {
|
||||
let mut info = ClientInfo::default();
|
||||
fn get_info(&self) -> InitializeRequestParams {
|
||||
let mut info = InitializeRequestParams::default();
|
||||
info.protocol_version = self.protocol_version.clone();
|
||||
info
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ async fn call_tool_result_type(client_version: ProtocolVersion) -> Option<Result
|
|||
let client_handler = VersionedClient {
|
||||
protocol_version: client_version.clone(),
|
||||
};
|
||||
let mut server_peer_info = ServerInfo::default();
|
||||
let mut server_peer_info = InitializeResult::default();
|
||||
server_peer_info.protocol_version = client_version;
|
||||
|
||||
let server = serve_directly::<RoleServer, _, _, _, _>(
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@ use std::sync::{Arc, Mutex};
|
|||
use rmcp::{
|
||||
ClientHandler, RoleClient, RoleServer, ServerHandler, ServiceError, ServiceExt,
|
||||
model::{
|
||||
CallToolRequestParams, CallToolResponse, CallToolResult, ClientInfo, ContentBlock,
|
||||
CreateMessageRequest, CreateMessageRequestParams, CreateMessageResult, ProtocolVersion,
|
||||
SamplingMessage, ServerCapabilities, ServerInfo, ServerRequest,
|
||||
CallToolRequestParams, CallToolResponse, CallToolResult, ContentBlock,
|
||||
CreateMessageRequest, CreateMessageRequestParams, CreateMessageResult,
|
||||
InitializeRequestParams, InitializeResult, ProtocolVersion, SamplingMessage,
|
||||
ServerCapabilities, ServerRequest,
|
||||
},
|
||||
service::{RequestContext, RunningService, serve_directly},
|
||||
};
|
||||
|
|
@ -29,8 +30,8 @@ struct SamplingServer {
|
|||
}
|
||||
|
||||
impl ServerHandler for SamplingServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().enable_tools().build())
|
||||
}
|
||||
|
||||
async fn call_tool(
|
||||
|
|
@ -93,8 +94,8 @@ impl ClientHandler for SamplingClient {
|
|||
.with_stop_reason(CreateMessageResult::STOP_REASON_END_TURN))
|
||||
}
|
||||
|
||||
fn get_info(&self) -> ClientInfo {
|
||||
let mut info = ClientInfo::default();
|
||||
fn get_info(&self) -> InitializeRequestParams {
|
||||
let mut info = InitializeRequestParams::default();
|
||||
info.protocol_version = ProtocolVersion::V_2026_07_28;
|
||||
info
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,9 @@ use http::{HeaderName, HeaderValue};
|
|||
use rmcp::{
|
||||
ClientHandler,
|
||||
model::{
|
||||
ClientInfo, ClientJsonRpcMessage, CreateMessageRequestParams, CreateMessageResult,
|
||||
ProtocolVersion, SamplingMessage, ServerCapabilities, ServerInfo, ServerJsonRpcMessage,
|
||||
ClientJsonRpcMessage, CreateMessageRequestParams, CreateMessageResult,
|
||||
InitializeRequestParams, InitializeResult, ProtocolVersion, SamplingMessage,
|
||||
ServerCapabilities, ServerJsonRpcMessage,
|
||||
},
|
||||
service::{ClientLifecycleMode, RequestContext, RoleClient, serve_client_with_lifecycle},
|
||||
transport::streamable_http_client::{
|
||||
|
|
@ -80,7 +81,7 @@ impl StreamableHttpClient for ScriptedServer {
|
|||
// Receiver drop is normal at test teardown; never panic in the transport task.
|
||||
let _ = self.posted.send(value.clone());
|
||||
if value["method"] == "initialize" {
|
||||
let mut info = ServerInfo::new(ServerCapabilities::default());
|
||||
let mut info = InitializeResult::new(ServerCapabilities::default());
|
||||
info.protocol_version = ProtocolVersion::V_2026_07_28;
|
||||
let response = ServerJsonRpcMessage::response(
|
||||
rmcp::model::ServerResult::InitializeResult(info),
|
||||
|
|
@ -152,8 +153,8 @@ impl ClientHandler for SamplingClient {
|
|||
))
|
||||
}
|
||||
|
||||
fn get_info(&self) -> ClientInfo {
|
||||
ClientInfo::default()
|
||||
fn get_info(&self) -> InitializeRequestParams {
|
||||
InitializeRequestParams::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use rmcp::{
|
|||
ErrorData as McpError, RoleServer, ServerHandler,
|
||||
model::{
|
||||
CallToolRequestParams, CallToolResponse, CallToolResult, ContentBlock, ElicitRequestParams,
|
||||
ElicitationSchema, ServerCapabilities, ServerInfo,
|
||||
ElicitationSchema, InitializeResult, ServerCapabilities,
|
||||
},
|
||||
service::RequestContext,
|
||||
transport::streamable_http_server::{
|
||||
|
|
@ -23,8 +23,8 @@ use tokio_util::sync::CancellationToken;
|
|||
struct ElicitingServer;
|
||||
|
||||
impl ServerHandler for ElicitingServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().enable_tools().build())
|
||||
}
|
||||
|
||||
async fn call_tool(
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
use rmcp::{
|
||||
ClientHandler, ServerHandler, ServiceExt,
|
||||
model::{
|
||||
ClientCapabilities, Implementation, ProtocolVersion, RequestMetaObject, ServerCapabilities,
|
||||
ServerInfo,
|
||||
ClientCapabilities, Implementation, InitializeResult, ProtocolVersion, RequestMetaObject,
|
||||
ServerCapabilities,
|
||||
},
|
||||
select_protocol_version,
|
||||
};
|
||||
|
|
@ -13,8 +13,8 @@ use rmcp::{
|
|||
struct DiscoveryServer;
|
||||
|
||||
impl ServerHandler for DiscoveryServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().enable_tools().build())
|
||||
.with_server_info(Implementation::new("discovery-server", "1.0.0"))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use std::borrow::Cow;
|
|||
|
||||
use rmcp::{
|
||||
ServerHandler,
|
||||
model::{Implementation, ProtocolVersion, ServerCapabilities, ServerInfo},
|
||||
model::{Implementation, InitializeResult, ProtocolVersion, ServerCapabilities},
|
||||
transport::streamable_http_server::{
|
||||
StreamableHttpServerConfig, StreamableHttpService, session::local::LocalSessionManager,
|
||||
},
|
||||
|
|
@ -20,8 +20,8 @@ use tokio_util::sync::CancellationToken;
|
|||
struct DiscoveryServer;
|
||||
|
||||
impl ServerHandler for DiscoveryServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().enable_tools().build())
|
||||
.with_server_info(Implementation::new("discovery-server", "1.0.0"))
|
||||
.with_instructions("Use the tools carefully")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use common::handlers::TestServer;
|
|||
use rmcp::{
|
||||
ServerHandler, ServiceExt,
|
||||
model::{
|
||||
ClientJsonRpcMessage, ProtocolVersion, ServerCapabilities, ServerInfo,
|
||||
ClientJsonRpcMessage, InitializeResult, ProtocolVersion, ServerCapabilities,
|
||||
ServerJsonRpcMessage, ServerResult,
|
||||
},
|
||||
transport::{IntoTransport, Transport},
|
||||
|
|
@ -281,8 +281,8 @@ async fn server_falls_back_when_client_protocol_version_unknown() {
|
|||
struct PinnedServer;
|
||||
|
||||
impl ServerHandler for PinnedServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::new(ServerCapabilities::builder().build())
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().build())
|
||||
.with_protocol_version(ProtocolVersion::V_2025_06_18)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use std::time::Duration;
|
|||
use futures::StreamExt;
|
||||
use rmcp::{
|
||||
RoleServer, ServerHandler,
|
||||
model::{Implementation, ServerCapabilities, ServerInfo, ToolsCapability},
|
||||
model::{Implementation, InitializeResult, ServerCapabilities, ToolsCapability},
|
||||
service::NotificationContext,
|
||||
transport::streamable_http_server::{
|
||||
StreamableHttpServerConfig, StreamableHttpService, session::local::LocalSessionManager,
|
||||
|
|
@ -45,8 +45,8 @@ impl TestServer {
|
|||
}
|
||||
|
||||
impl ServerHandler for TestServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::new(
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(
|
||||
ServerCapabilities::builder()
|
||||
.enable_tools_with({
|
||||
let mut tools = ToolsCapability::default();
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue