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
63 changed files with 323 additions and 286 deletions
36
README.md
36
README.md
|
|
@ -99,10 +99,10 @@ Use [`ClientServiceExt::serve_with_lifecycle`](crates/rmcp/src/service/client.rs
|
|||
select another lifecycle explicitly:
|
||||
|
||||
```rust, ignore
|
||||
use rmcp::{ClientInfo, ClientLifecycleMode, ClientServiceExt, ProtocolVersion};
|
||||
use rmcp::{ClientLifecycleMode, ClientServiceExt, InitializeRequestParams, ProtocolVersion};
|
||||
|
||||
// Start directly with server/discover and include client metadata on every request.
|
||||
let client = ClientInfo::default()
|
||||
let client = InitializeRequestParams::default()
|
||||
.serve_with_lifecycle(
|
||||
transport,
|
||||
ClientLifecycleMode::Discover {
|
||||
|
|
@ -113,7 +113,7 @@ let client = ClientInfo::default()
|
|||
|
||||
// Or probe the discover lifecycle and fall back when a legacy server reports
|
||||
// that server/discover is not implemented or does not respond within 10 seconds.
|
||||
let client = ClientInfo::default()
|
||||
let client = InitializeRequestParams::default()
|
||||
.serve_with_lifecycle(
|
||||
transport,
|
||||
ClientLifecycleMode::Auto {
|
||||
|
|
@ -369,8 +369,8 @@ use serde_json::json;
|
|||
struct MyServer;
|
||||
|
||||
impl ServerHandler for MyServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::new(
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(
|
||||
ServerCapabilities::builder()
|
||||
.enable_resources()
|
||||
.build(),
|
||||
|
|
@ -582,8 +582,8 @@ impl MyServer {
|
|||
|
||||
#[prompt_handler]
|
||||
impl ServerHandler for MyServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::new(ServerCapabilities::builder().enable_prompts().build())
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().enable_prompts().build())
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
@ -934,8 +934,8 @@ Enable the logging capability, handle level changes from the client, and send lo
|
|||
use rmcp::{ServerHandler, model::*, service::RequestContext};
|
||||
|
||||
impl ServerHandler for MyServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::new(
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(
|
||||
ServerCapabilities::builder()
|
||||
.enable_logging()
|
||||
.build(),
|
||||
|
|
@ -1007,8 +1007,8 @@ Enable the completions capability and implement the `complete()` handler. Use `r
|
|||
use rmcp::{ErrorData as McpError, ServerHandler, model::*, service::RequestContext, RoleServer};
|
||||
|
||||
impl ServerHandler for MyServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::new(
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(
|
||||
ServerCapabilities::builder()
|
||||
.enable_completions()
|
||||
.enable_prompts()
|
||||
|
|
@ -1253,8 +1253,8 @@ use rmcp::{
|
|||
};
|
||||
|
||||
impl ServerHandler for MyServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::new(
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(
|
||||
ServerCapabilities::builder()
|
||||
.enable_tools()
|
||||
.enable_tool_list_changed()
|
||||
|
|
@ -1584,7 +1584,7 @@ use rmcp::transport::StreamableHttpClientTransport;
|
|||
|
||||
// Defaults are stateless-friendly.
|
||||
let transport = StreamableHttpClientTransport::from_uri("http://localhost:8000/mcp");
|
||||
let client = ClientInfo::default().serve(transport).await?;
|
||||
let client = InitializeRequestParams::default().serve(transport).await?;
|
||||
```
|
||||
|
||||
**Example:** [`examples/servers/src/counter_streamhttp.rs`](examples/servers/src/counter_streamhttp.rs) (server), [`examples/clients/src/streamable_http.rs`](examples/clients/src/streamable_http.rs) (client)
|
||||
|
|
@ -1638,7 +1638,7 @@ server example). The client transport connects with a single URI:
|
|||
use rmcp::transport::StreamableHttpClientTransport;
|
||||
|
||||
let transport = StreamableHttpClientTransport::from_uri("http://localhost:8000/mcp");
|
||||
let client = ClientInfo::default().serve(transport).await?;
|
||||
let client = InitializeRequestParams::default().serve(transport).await?;
|
||||
```
|
||||
|
||||
The client allows up to 16 ordinary http POSTs at once. Configure this with
|
||||
|
|
@ -1742,10 +1742,10 @@ knows what the other supports. Declare yours with the `ServerCapabilities`
|
|||
builder in `get_info()`:
|
||||
|
||||
```rust,ignore
|
||||
use rmcp::model::{ServerCapabilities, ServerInfo};
|
||||
use rmcp::model::{InitializeResult, ServerCapabilities};
|
||||
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::new(
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(
|
||||
ServerCapabilities::builder()
|
||||
.enable_tools()
|
||||
.enable_prompts()
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ impl ClientHandler for BasicClientHandler {}
|
|||
struct ElicitationDefaultsClientHandler;
|
||||
|
||||
impl ClientHandler for ElicitationDefaultsClientHandler {
|
||||
fn get_info(&self) -> ClientInfo {
|
||||
let mut info = ClientInfo::default();
|
||||
fn get_info(&self) -> InitializeRequestParams {
|
||||
let mut info = InitializeRequestParams::default();
|
||||
info.capabilities.elicitation = Some(
|
||||
ElicitationCapability::new()
|
||||
.with_form(FormElicitationCapability::new().with_schema_validation(true)),
|
||||
|
|
@ -163,8 +163,8 @@ impl ClientHandler for ElicitationDefaultsClientHandler {
|
|||
struct FullClientHandler;
|
||||
|
||||
impl ClientHandler for FullClientHandler {
|
||||
fn get_info(&self) -> ClientInfo {
|
||||
let mut info = ClientInfo::default();
|
||||
fn get_info(&self) -> InitializeRequestParams {
|
||||
let mut info = InitializeRequestParams::default();
|
||||
info.capabilities.elicitation = Some(
|
||||
ElicitationCapability::new()
|
||||
.with_form(FormElicitationCapability::new().with_schema_validation(true)),
|
||||
|
|
|
|||
|
|
@ -704,8 +704,8 @@ impl ServerHandler for ConformanceServer {
|
|||
(name == "test_custom_header").then(custom_header_tool)
|
||||
}
|
||||
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::new(
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(
|
||||
ServerCapabilities::builder()
|
||||
.enable_prompts()
|
||||
.enable_prompts_list_changed()
|
||||
|
|
|
|||
|
|
@ -217,8 +217,8 @@ pub fn tool_router(attr: TokenStream, input: TokenStream) -> TokenStream {
|
|||
/// ```rust,ignore
|
||||
/// #[tool_handler]
|
||||
/// impl ServerHandler for MyToolHandler {
|
||||
/// fn get_info(&self) -> ServerInfo {
|
||||
/// ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
|
||||
/// fn get_info(&self) -> InitializeResult {
|
||||
/// InitializeResult::new(ServerCapabilities::builder().enable_tools().build())
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ pub(crate) enum CallerCapability {
|
|||
Prompts,
|
||||
}
|
||||
|
||||
/// Build a `get_info()` method that returns `ServerInfo` with the appropriate capabilities.
|
||||
/// Build a `get_info()` method that returns `InitializeResult` with the appropriate capabilities.
|
||||
///
|
||||
/// The caller declares its own capability via `caller`. Sibling handler attributes
|
||||
/// (`prompt_handler`, `tool_handler`) are detected automatically
|
||||
|
|
@ -157,8 +157,8 @@ pub(crate) fn build_get_info(
|
|||
}
|
||||
|
||||
syn::parse2::<ImplItem>(quote! {
|
||||
fn get_info(&self) -> rmcp::model::ServerInfo {
|
||||
rmcp::model::ServerInfo::new(
|
||||
fn get_info(&self) -> rmcp::model::InitializeResult {
|
||||
rmcp::model::InitializeResult::new(
|
||||
rmcp::model::ServerCapabilities::builder()
|
||||
#(#capability_calls)*
|
||||
.build()
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ macro_rules! client_handler_methods {
|
|||
}
|
||||
|
||||
fn get_info(&self) -> ClientInfo {
|
||||
ClientInfo::default()
|
||||
InitializeRequestParams::default()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -601,7 +601,7 @@ macro_rules! server_handler_methods {
|
|||
}
|
||||
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo::default()
|
||||
InitializeResult::default()
|
||||
}
|
||||
|
||||
/// SEP-2663 `tasks/get`: return the current [`DetailedTask`] state.
|
||||
|
|
|
|||
|
|
@ -1119,7 +1119,26 @@ impl InitializeResult {
|
|||
}
|
||||
}
|
||||
|
||||
/// Full server initialize payload (`InitializeResult`).
|
||||
///
|
||||
/// Prefer [`InitializeResult`]. The name collides with the protocol's
|
||||
/// `serverInfo` field, which is only the [`Implementation`] identity (#1082).
|
||||
//
|
||||
// The signatures this crate publishes (`ServerHandler::get_info`,
|
||||
// `DiscoverResult::from_server_info`, and the `ClientInfo` equivalents below)
|
||||
// keep spelling the alias. It resolves to the same type, so the spelling makes
|
||||
// no difference to callers, but rustdoc records the name as written and the
|
||||
// public API check treats a respelling as a changed item. Moving those
|
||||
// signatures onto the canonical names is a documented API change and belongs in
|
||||
// the next major release.
|
||||
#[deprecated(note = "use `InitializeResult` instead")]
|
||||
pub type ServerInfo = InitializeResult;
|
||||
|
||||
/// Full client initialize params (`InitializeRequestParams`).
|
||||
///
|
||||
/// Prefer [`InitializeRequestParams`]. The name collides with the protocol's
|
||||
/// `clientInfo` field, which is only the [`Implementation`] identity (#1082).
|
||||
#[deprecated(note = "use `InitializeRequestParams` instead")]
|
||||
pub type ClientInfo = InitializeRequestParams;
|
||||
|
||||
/// Information negotiated about a server peer.
|
||||
|
|
@ -1284,7 +1303,7 @@ impl DiscoverResult {
|
|||
supported_versions: Vec<ProtocolVersion>,
|
||||
server_info: ServerInfo,
|
||||
) -> Self {
|
||||
let ServerInfo {
|
||||
let InitializeResult {
|
||||
capabilities,
|
||||
server_info,
|
||||
instructions,
|
||||
|
|
@ -1332,9 +1351,9 @@ impl ServerPeerInfo {
|
|||
}
|
||||
|
||||
#[allow(clippy::derivable_impls)]
|
||||
impl Default for ServerInfo {
|
||||
impl Default for InitializeResult {
|
||||
fn default() -> Self {
|
||||
ServerInfo {
|
||||
InitializeResult {
|
||||
protocol_version: ProtocolVersion::default(),
|
||||
capabilities: ServerCapabilities::default(),
|
||||
server_info: Implementation::from_build_env(),
|
||||
|
|
@ -1345,9 +1364,9 @@ impl Default for ServerInfo {
|
|||
}
|
||||
|
||||
#[allow(clippy::derivable_impls)]
|
||||
impl Default for ClientInfo {
|
||||
impl Default for InitializeRequestParams {
|
||||
fn default() -> Self {
|
||||
ClientInfo {
|
||||
InitializeRequestParams {
|
||||
meta: None,
|
||||
protocol_version: ProtocolVersion::default(),
|
||||
capabilities: ClientCapabilities::default(),
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ use crate::{
|
|||
model::{
|
||||
ArgumentInfo, CacheScope, CallToolRequest, CallToolRequestParams, CallToolResponse,
|
||||
CallToolResult, CancelTaskParams, CancelTaskRequest, CancelledNotification,
|
||||
CancelledNotificationParam, ClientInfo, ClientJsonRpcMessage, ClientNotification,
|
||||
ClientRequest, ClientResult, CompleteRequest, CompleteRequestParams, CompleteResult,
|
||||
CompletionContext, CompletionInfo, DEFAULT_MRTR_MAX_ROUNDS, DiscoverRequest,
|
||||
DiscoverRequestParams, DiscoverResult, ErrorData, GetExtensions, GetMeta, GetPromptRequest,
|
||||
CancelledNotificationParam, ClientJsonRpcMessage, ClientNotification, ClientRequest,
|
||||
ClientResult, CompleteRequest, CompleteRequestParams, CompleteResult, CompletionContext,
|
||||
CompletionInfo, DEFAULT_MRTR_MAX_ROUNDS, DiscoverRequest, DiscoverRequestParams,
|
||||
DiscoverResult, ErrorData, GetExtensions, GetMeta, GetPromptRequest,
|
||||
GetPromptRequestParams, GetPromptResponse, GetPromptResult, GetTaskParams, GetTaskRequest,
|
||||
GetTaskResult, InitializeRequest, InitializedNotification, InputRequest,
|
||||
InputRequiredResult, InputResponses, JsonRpcResponse, ListPromptsRequest,
|
||||
GetTaskResult, InitializeRequest, InitializeRequestParams, InitializedNotification,
|
||||
InputRequest, InputRequiredResult, InputResponses, JsonRpcResponse, ListPromptsRequest,
|
||||
ListPromptsResult, ListResourceTemplatesRequest, ListResourceTemplatesResult,
|
||||
ListResourcesRequest, ListResourcesResult, ListToolsRequest, ListToolsResult,
|
||||
NumberOrString, PaginatedRequestParams, ProgressNotification, ProgressNotificationParam,
|
||||
|
|
@ -266,7 +266,7 @@ impl ServiceRole for RoleClient {
|
|||
type PeerReq = ServerRequest;
|
||||
type PeerResp = ServerResult;
|
||||
type PeerNot = ServerNotification;
|
||||
type Info = ClientInfo;
|
||||
type Info = InitializeRequestParams;
|
||||
type PeerInfo = ServerPeerInfo;
|
||||
type InitializeError = ClientInitializeError;
|
||||
const IS_CLIENT: bool = true;
|
||||
|
|
@ -870,7 +870,7 @@ async fn legacy_startup<S, T>(
|
|||
transport: &mut T,
|
||||
id_provider: &Arc<AtomicU32RequestIdProvider>,
|
||||
peer: &Peer<RoleClient>,
|
||||
client_info: ClientInfo,
|
||||
client_info: InitializeRequestParams,
|
||||
) -> Result<(), ClientInitializeError>
|
||||
where
|
||||
S: Service<RoleClient>,
|
||||
|
|
@ -919,7 +919,7 @@ async fn discover_startup<S, T>(
|
|||
transport: &mut T,
|
||||
id_provider: &Arc<AtomicU32RequestIdProvider>,
|
||||
peer: &Peer<RoleClient>,
|
||||
client_info: &ClientInfo,
|
||||
client_info: &InitializeRequestParams,
|
||||
preferred_versions: Vec<ProtocolVersion>,
|
||||
) -> Result<DiscoverOutcome, ClientInitializeError>
|
||||
where
|
||||
|
|
|
|||
|
|
@ -13,14 +13,15 @@ use super::*;
|
|||
use crate::model::{ElicitRequest, ElicitRequestParams, ElicitResult, ElicitationAction};
|
||||
use crate::{
|
||||
model::{
|
||||
CancelledNotification, CancelledNotificationParam, ClientInfo, ClientJsonRpcMessage,
|
||||
CancelledNotification, CancelledNotificationParam, ClientJsonRpcMessage,
|
||||
ClientNotification, ClientRequest, ClientResult, CreateMessageRequest,
|
||||
CreateMessageRequestParams, CreateMessageResult, EmptyResult, ErrorData, ListRootsRequest,
|
||||
ListRootsResult, LoggingMessageNotification, LoggingMessageNotificationParam,
|
||||
ProgressNotification, ProgressNotificationParam, PromptListChangedNotification,
|
||||
ProtocolVersion, ResourceListChangedNotification, ResourceUpdatedNotification,
|
||||
ResourceUpdatedNotificationParam, ServerInfo, ServerNotification, ServerRequest,
|
||||
ServerResult, SubscriptionFilter, SubscriptionsAcknowledgedNotification,
|
||||
CreateMessageRequestParams, CreateMessageResult, EmptyResult, ErrorData,
|
||||
InitializeRequestParams, InitializeResult, ListRootsRequest, ListRootsResult,
|
||||
LoggingMessageNotification, LoggingMessageNotificationParam, ProgressNotification,
|
||||
ProgressNotificationParam, PromptListChangedNotification, ProtocolVersion,
|
||||
ResourceListChangedNotification, ResourceUpdatedNotification,
|
||||
ResourceUpdatedNotificationParam, ServerNotification, ServerRequest, ServerResult,
|
||||
SubscriptionFilter, SubscriptionsAcknowledgedNotification,
|
||||
SubscriptionsAcknowledgedNotificationParams, ToolListChangedNotification,
|
||||
},
|
||||
transport::DynamicTransportError,
|
||||
|
|
@ -37,8 +38,8 @@ impl ServiceRole for RoleServer {
|
|||
type PeerReq = ClientRequest;
|
||||
type PeerResp = ClientResult;
|
||||
type PeerNot = ClientNotification;
|
||||
type Info = ServerInfo;
|
||||
type PeerInfo = ClientInfo;
|
||||
type Info = InitializeResult;
|
||||
type PeerInfo = InitializeRequestParams;
|
||||
|
||||
type InitializeError = ServerInitializeError;
|
||||
const IS_CLIENT: bool = false;
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ use crate::{
|
|||
model::{
|
||||
ClientCapabilities, ClientJsonRpcMessage, ClientNotification, ClientRequest, ErrorCode,
|
||||
ErrorData, GetExtensions, GetMeta, Implementation, InitializeRequest,
|
||||
InitializeRequestParams, InitializedNotification, JsonObject, JsonRpcError,
|
||||
ProtocolVersion, RequestId, ServerInfo, ServerJsonRpcMessage, ServerResult,
|
||||
InitializeRequestParams, InitializeResult, InitializedNotification, JsonObject,
|
||||
JsonRpcError, ProtocolVersion, RequestId, ServerJsonRpcMessage, ServerResult,
|
||||
},
|
||||
serve_server,
|
||||
service::{
|
||||
|
|
@ -367,7 +367,7 @@ impl<S: Service<RoleServer>> Service<RoleServer> for NegotiatingStatelessHttpSer
|
|||
self.0.handle_notification(notification, context).await
|
||||
}
|
||||
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
self.0.get_info()
|
||||
}
|
||||
|
||||
|
|
@ -2111,7 +2111,7 @@ where
|
|||
Ok(accepted_response())
|
||||
}
|
||||
|
||||
/// Build a `ClientInfo` (peer_info) for a stateless request so that
|
||||
/// Build a `InitializeRequestParams` (peer_info) for a stateless request so that
|
||||
/// `context.protocol_version()` returns the correct value inside handlers.
|
||||
///
|
||||
/// `serve_directly` skips the MCP handshake and accepts `peer_info = None`,
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue