feat(model): add ServerConfig and ClientConfig (#1266)
This commit is contained in:
parent
fbfc5cc96e
commit
165ff92df1
43 changed files with 331 additions and 303 deletions
|
|
@ -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) -> InitializeResult {
|
||||
/// InitializeResult::new(ServerCapabilities::builder().enable_tools().build())
|
||||
/// fn get_info(&self) -> ServerConfig {
|
||||
/// ServerConfig::new(ServerCapabilities::builder().enable_tools().build())
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ pub(crate) enum CallerCapability {
|
|||
Prompts,
|
||||
}
|
||||
|
||||
/// Build a `get_info()` method that returns `InitializeResult` with the appropriate capabilities.
|
||||
/// Build a `get_info()` method that returns `ServerConfig` 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::InitializeResult {
|
||||
rmcp::model::InitializeResult::new(
|
||||
fn get_info(&self) -> rmcp::model::ServerConfig {
|
||||
rmcp::model::ServerConfig::new(
|
||||
rmcp::model::ServerCapabilities::builder()
|
||||
#(#capability_calls)*
|
||||
.build()
|
||||
|
|
|
|||
|
|
@ -274,8 +274,8 @@ macro_rules! client_handler_methods {
|
|||
std::future::ready(())
|
||||
}
|
||||
|
||||
fn get_info(&self) -> ClientInfo {
|
||||
InitializeRequestParams::default()
|
||||
fn get_info(&self) -> ClientConfig {
|
||||
ClientConfig::default()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -292,12 +292,12 @@ pub trait ClientHandler: Sized + 'static {
|
|||
client_handler_methods!();
|
||||
}
|
||||
|
||||
/// Do nothing, with default client info.
|
||||
/// Do nothing, with the default client config.
|
||||
impl ClientHandler for () {}
|
||||
|
||||
/// Do nothing, with a specific client info.
|
||||
impl ClientHandler for ClientInfo {
|
||||
fn get_info(&self) -> ClientInfo {
|
||||
/// Do nothing, with a specific client config.
|
||||
impl ClientHandler for ClientConfig {
|
||||
fn get_info(&self) -> ClientConfig {
|
||||
self.clone()
|
||||
}
|
||||
}
|
||||
|
|
@ -422,7 +422,7 @@ macro_rules! impl_client_handler_for_wrapper {
|
|||
(**self).on_custom_notification(notification, context)
|
||||
}
|
||||
|
||||
fn get_info(&self) -> ClientInfo {
|
||||
fn get_info(&self) -> ClientConfig {
|
||||
(**self).get_info()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -334,15 +334,15 @@ macro_rules! server_handler_methods {
|
|||
/// ```
|
||||
/// use rmcp::{
|
||||
/// ErrorData as McpError, RoleServer, ServerHandler,
|
||||
/// model::{InitializeRequestParams, InitializeResult, ServerInfo},
|
||||
/// model::{InitializeRequestParams, InitializeResult, ServerConfig},
|
||||
/// service::RequestContext,
|
||||
/// };
|
||||
///
|
||||
/// struct MyServer;
|
||||
///
|
||||
/// impl ServerHandler for MyServer {
|
||||
/// fn get_info(&self) -> ServerInfo {
|
||||
/// ServerInfo::default()
|
||||
/// fn get_info(&self) -> ServerConfig {
|
||||
/// ServerConfig::default()
|
||||
/// }
|
||||
///
|
||||
/// async fn initialize(
|
||||
|
|
@ -600,8 +600,8 @@ macro_rules! server_handler_methods {
|
|||
std::future::ready(())
|
||||
}
|
||||
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
InitializeResult::default()
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
ServerConfig::default()
|
||||
}
|
||||
|
||||
/// SEP-2663 `tasks/get`: return the current [`DetailedTask`] state.
|
||||
|
|
@ -839,7 +839,7 @@ macro_rules! impl_server_handler_for_wrapper {
|
|||
(**self).on_custom_notification(notification, context)
|
||||
}
|
||||
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
(**self).get_info()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1119,26 +1119,58 @@ impl InitializeResult {
|
|||
}
|
||||
}
|
||||
|
||||
/// Full server initialize payload (`InitializeResult`).
|
||||
/// A server's own configuration: the protocol version, capabilities,
|
||||
/// implementation identity, and instructions it advertises to clients.
|
||||
///
|
||||
/// 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")]
|
||||
/// This is what `ServerHandler::get_info` returns. It is an alias for
|
||||
/// [`InitializeResult`] because the same value is sent as the `initialize`
|
||||
/// response on the wire.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use rmcp::model::{ServerCapabilities, ServerConfig};
|
||||
///
|
||||
/// let config = ServerConfig::new(ServerCapabilities::builder().enable_tools().build())
|
||||
/// .with_instructions("Call `add` to sum two numbers.");
|
||||
/// assert!(config.capabilities.tools.is_some());
|
||||
/// ```
|
||||
pub type ServerConfig = InitializeResult;
|
||||
|
||||
/// A client's own configuration: the protocol version, capabilities, and
|
||||
/// implementation identity it advertises to servers.
|
||||
///
|
||||
/// This is what `ClientHandler::get_info` returns. It is an alias for
|
||||
/// [`InitializeRequestParams`] because the same value is sent as the
|
||||
/// `initialize` request on the wire.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use rmcp::model::{ClientCapabilities, ClientConfig, Implementation};
|
||||
///
|
||||
/// let config = ClientConfig::new(
|
||||
/// ClientCapabilities::builder().enable_elicitation().build(),
|
||||
/// Implementation::new("my-client", "1.0.0"),
|
||||
/// );
|
||||
/// assert!(config.capabilities.elicitation.is_some());
|
||||
/// ```
|
||||
pub type ClientConfig = InitializeRequestParams;
|
||||
|
||||
/// Deprecated alias for [`ServerConfig`].
|
||||
///
|
||||
/// The name collides with the protocol's `serverInfo` field, which is only the
|
||||
/// [`Implementation`] identity, so `server_info.server_info` was easy to
|
||||
/// misread (#1082).
|
||||
#[deprecated(note = "use `ServerConfig` instead")]
|
||||
pub type ServerInfo = InitializeResult;
|
||||
|
||||
/// Full client initialize params (`InitializeRequestParams`).
|
||||
/// Deprecated alias for [`ClientConfig`].
|
||||
///
|
||||
/// Prefer [`InitializeRequestParams`]. The name collides with the protocol's
|
||||
/// `clientInfo` field, which is only the [`Implementation`] identity (#1082).
|
||||
#[deprecated(note = "use `InitializeRequestParams` instead")]
|
||||
/// The name collides with the protocol's `clientInfo` field, which is only the
|
||||
/// [`Implementation`] identity, so `client_info.client_info` was easy to
|
||||
/// misread (#1082).
|
||||
#[deprecated(note = "use `ClientConfig` instead")]
|
||||
pub type ClientInfo = InitializeRequestParams;
|
||||
|
||||
/// Information negotiated about a server peer.
|
||||
|
|
@ -1298,18 +1330,18 @@ impl DiscoverResult {
|
|||
self
|
||||
}
|
||||
|
||||
/// Create a discovery result from the server's initialization information.
|
||||
/// Create a discovery result from the server's configuration.
|
||||
pub fn from_server_info(
|
||||
supported_versions: Vec<ProtocolVersion>,
|
||||
server_info: ServerInfo,
|
||||
server_config: ServerConfig,
|
||||
) -> Self {
|
||||
let InitializeResult {
|
||||
let ServerConfig {
|
||||
capabilities,
|
||||
server_info,
|
||||
instructions,
|
||||
meta,
|
||||
..
|
||||
} = server_info;
|
||||
} = server_config;
|
||||
let mut result = Self {
|
||||
result_type: ResultType::COMPLETE,
|
||||
supported_versions,
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ use crate::{
|
|||
model::{
|
||||
ArgumentInfo, CacheScope, CallToolRequest, CallToolRequestParams, CallToolResponse,
|
||||
CallToolResult, CancelTaskParams, CancelTaskRequest, CancelledNotification,
|
||||
CancelledNotificationParam, ClientJsonRpcMessage, ClientNotification, ClientRequest,
|
||||
ClientResult, CompleteRequest, CompleteRequestParams, CompleteResult, CompletionContext,
|
||||
CompletionInfo, DEFAULT_MRTR_MAX_ROUNDS, DiscoverRequest, DiscoverRequestParams,
|
||||
DiscoverResult, ErrorData, GetExtensions, GetMeta, GetPromptRequest,
|
||||
CancelledNotificationParam, ClientConfig, 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, InitializeRequestParams, InitializedNotification,
|
||||
InputRequest, InputRequiredResult, InputResponses, JsonRpcResponse, ListPromptsRequest,
|
||||
|
|
@ -266,7 +266,7 @@ impl ServiceRole for RoleClient {
|
|||
type PeerReq = ServerRequest;
|
||||
type PeerResp = ServerResult;
|
||||
type PeerNot = ServerNotification;
|
||||
type Info = InitializeRequestParams;
|
||||
type Info = ClientConfig;
|
||||
type PeerInfo = ServerPeerInfo;
|
||||
type InitializeError = ClientInitializeError;
|
||||
const IS_CLIENT: bool = true;
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ use crate::{
|
|||
CancelledNotification, CancelledNotificationParam, ClientJsonRpcMessage,
|
||||
ClientNotification, ClientRequest, ClientResult, CreateMessageRequest,
|
||||
CreateMessageRequestParams, CreateMessageResult, EmptyResult, ErrorData,
|
||||
InitializeRequestParams, InitializeResult, ListRootsRequest, ListRootsResult,
|
||||
LoggingMessageNotification, LoggingMessageNotificationParam, ProgressNotification,
|
||||
ProgressNotificationParam, PromptListChangedNotification, ProtocolVersion,
|
||||
ResourceListChangedNotification, ResourceUpdatedNotification,
|
||||
ResourceUpdatedNotificationParam, ServerNotification, ServerRequest, ServerResult,
|
||||
SubscriptionFilter, SubscriptionsAcknowledgedNotification,
|
||||
SubscriptionsAcknowledgedNotificationParams, ToolListChangedNotification,
|
||||
InitializeRequestParams, ListRootsRequest, ListRootsResult, LoggingMessageNotification,
|
||||
LoggingMessageNotificationParam, ProgressNotification, ProgressNotificationParam,
|
||||
PromptListChangedNotification, ProtocolVersion, ResourceListChangedNotification,
|
||||
ResourceUpdatedNotification, ResourceUpdatedNotificationParam, ServerConfig,
|
||||
ServerNotification, ServerRequest, ServerResult, SubscriptionFilter,
|
||||
SubscriptionsAcknowledgedNotification, SubscriptionsAcknowledgedNotificationParams,
|
||||
ToolListChangedNotification,
|
||||
},
|
||||
transport::DynamicTransportError,
|
||||
};
|
||||
|
|
@ -38,7 +38,7 @@ impl ServiceRole for RoleServer {
|
|||
type PeerReq = ClientRequest;
|
||||
type PeerResp = ClientResult;
|
||||
type PeerNot = ClientNotification;
|
||||
type Info = InitializeResult;
|
||||
type Info = ServerConfig;
|
||||
type PeerInfo = InitializeRequestParams;
|
||||
|
||||
type InitializeError = ServerInitializeError;
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ use crate::{
|
|||
model::{
|
||||
ClientCapabilities, ClientJsonRpcMessage, ClientNotification, ClientRequest, ErrorCode,
|
||||
ErrorData, GetExtensions, GetMeta, Implementation, InitializeRequest,
|
||||
InitializeRequestParams, InitializeResult, InitializedNotification, JsonObject,
|
||||
JsonRpcError, ProtocolVersion, RequestId, ServerJsonRpcMessage, ServerResult,
|
||||
InitializeRequestParams, InitializedNotification, JsonObject, JsonRpcError,
|
||||
ProtocolVersion, RequestId, ServerConfig, 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) -> InitializeResult {
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
self.0.get_info()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
use rmcp::{
|
||||
ServerHandler,
|
||||
handler::server::{router::tool::ToolRouter, wrapper::Parameters},
|
||||
model::{InitializeResult, ServerCapabilities},
|
||||
model::{ServerCapabilities, ServerConfig},
|
||||
schemars, tool, tool_router,
|
||||
};
|
||||
#[derive(Debug, serde::Deserialize, schemars::JsonSchema)]
|
||||
|
|
@ -52,8 +52,8 @@ impl Calculator {
|
|||
}
|
||||
|
||||
impl ServerHandler for Calculator {
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().enable_tools().build())
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
ServerConfig::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) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().enable_logging().build())
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
ServerConfig::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, InitializeResult,
|
||||
ServerCapabilities,
|
||||
CallToolRequestParams, CallToolResponse, CallToolResult, ContentBlock, ServerCapabilities,
|
||||
ServerConfig,
|
||||
},
|
||||
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) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().enable_tools().build())
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
ServerConfig::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::{InitializeResult, ServerCapabilities},
|
||||
model::{ServerCapabilities, ServerConfig},
|
||||
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) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().build())
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
ServerConfig::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::{InitializeResult, ServerCapabilities},
|
||||
model::{ServerCapabilities, ServerConfig},
|
||||
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) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().build())
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
ServerConfig::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::{InitializeResult, ServerCapabilities},
|
||||
model::{ServerCapabilities, ServerConfig},
|
||||
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) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().build())
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
ServerConfig::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::{InitializeResult, ServerCapabilities},
|
||||
model::{ServerCapabilities, ServerConfig},
|
||||
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) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().build())
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
ServerConfig::new(ServerCapabilities::builder().build())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1132,7 +1132,7 @@ mod origin_validation {
|
|||
use http_body_util::Full;
|
||||
use rmcp::{
|
||||
handler::server::ServerHandler,
|
||||
model::{InitializeResult, ServerCapabilities},
|
||||
model::{ServerCapabilities, ServerConfig},
|
||||
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) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().build())
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
ServerConfig::new(ServerCapabilities::builder().build())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use axum::{
|
|||
};
|
||||
use rmcp::{
|
||||
ClientLifecycleMode, ClientServiceExt, ServerHandler,
|
||||
model::{DiscoverResult, ErrorCode, ErrorData, InitializeRequestParams, ProtocolVersion},
|
||||
model::{ClientConfig, DiscoverResult, ErrorCode, ErrorData, 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 = InitializeRequestParams::default()
|
||||
let client = ClientConfig::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 = InitializeRequestParams::default()
|
||||
let client = ClientConfig::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 = InitializeRequestParams::default()
|
||||
let client = ClientConfig::default()
|
||||
.serve_with_lifecycle(
|
||||
transport,
|
||||
ClientLifecycleMode::Auto {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use rmcp::{
|
|||
ClientHandler, RoleClient, RoleServer, ServerHandler,
|
||||
handler::server::router::{prompt::PromptRouter, tool::ToolRouter},
|
||||
model::{
|
||||
CacheScope, InitializeRequestParams, InitializeResult, ListPromptsResult, ListToolsResult,
|
||||
CacheScope, ClientConfig, InitializeResult, ListPromptsResult, ListToolsResult,
|
||||
ProtocolVersion,
|
||||
},
|
||||
prompt_handler,
|
||||
|
|
@ -38,8 +38,8 @@ struct VersionedClient {
|
|||
}
|
||||
|
||||
impl ClientHandler for VersionedClient {
|
||||
fn get_info(&self) -> InitializeRequestParams {
|
||||
let mut info = InitializeRequestParams::default();
|
||||
fn get_info(&self) -> ClientConfig {
|
||||
let mut info = ClientConfig::default();
|
||||
info.protocol_version = self.protocol_version.clone();
|
||||
info
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use std::{
|
|||
use rmcp::{
|
||||
ServerHandler, ServiceExt,
|
||||
handler::server::{router::tool::ToolRouter, wrapper::Parameters},
|
||||
model::{CallToolRequestParams, InitializeRequestParams, InitializeResult, ServerCapabilities},
|
||||
model::{CallToolRequestParams, ClientConfig, ServerCapabilities, ServerConfig},
|
||||
service::QuitReason,
|
||||
tool, tool_handler, tool_router,
|
||||
};
|
||||
|
|
@ -55,8 +55,8 @@ impl SlowToolServer {
|
|||
|
||||
#[tool_handler]
|
||||
impl ServerHandler for SlowToolServer {
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::new(ServerCapabilities::builder().enable_tools().build())
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
ServerConfig::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) -> InitializeRequestParams {
|
||||
InitializeRequestParams::default()
|
||||
fn get_info(&self) -> ClientConfig {
|
||||
ClientConfig::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,8 +114,8 @@ impl MacroMrtrServer {
|
|||
|
||||
#[tool_handler]
|
||||
impl ServerHandler for MacroMrtrServer {
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
let mut info = InitializeResult::new(ServerCapabilities::builder().enable_tools().build());
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
let mut info = ServerConfig::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) -> InitializeResult {
|
||||
let mut info = InitializeResult::new(
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
let mut info = ServerConfig::new(
|
||||
ServerCapabilities::builder()
|
||||
.enable_tools()
|
||||
.enable_prompts()
|
||||
|
|
@ -609,9 +609,8 @@ async fn request_state_codec_seals_and_verifies_through_the_loop() -> anyhow::Re
|
|||
struct SealingServer;
|
||||
|
||||
impl ServerHandler for SealingServer {
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
let mut info =
|
||||
InitializeResult::new(ServerCapabilities::builder().enable_tools().build());
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
let mut info = ServerConfig::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, InitializeResult, ResourceUpdatedNotificationParam,
|
||||
ServerCapabilities, ServerNotification, SubscribeRequestParams,
|
||||
ClientNotification, CustomNotification, ResourceUpdatedNotificationParam,
|
||||
ServerCapabilities, ServerConfig, 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) -> InitializeResult {
|
||||
InitializeResult::new(
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
ServerConfig::new(
|
||||
ServerCapabilities::builder()
|
||||
.enable_resources()
|
||||
.enable_resources_subscribe()
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ use rmcp::{
|
|||
ClientHandler, ServerHandler, ServiceExt,
|
||||
handler::server::{router::prompt::PromptRouter, wrapper::Parameters},
|
||||
model::{
|
||||
ContentBlock, GetPromptRequestParams, GetPromptResult, InitializeRequestParams,
|
||||
PromptMessage, Role,
|
||||
ClientConfig, ContentBlock, GetPromptRequestParams, GetPromptResult, PromptMessage, Role,
|
||||
},
|
||||
prompt, prompt_handler, prompt_router,
|
||||
};
|
||||
|
|
@ -298,8 +297,8 @@ fn test_optional_field_schema_generation_via_macro() {
|
|||
struct DummyClientHandler {}
|
||||
|
||||
impl ClientHandler for DummyClientHandler {
|
||||
fn get_info(&self) -> InitializeRequestParams {
|
||||
InitializeRequestParams::default()
|
||||
fn get_info(&self) -> ClientConfig {
|
||||
ClientConfig::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ use std::{
|
|||
use rmcp::{
|
||||
ClientHandler, ErrorData, RoleServer, ServerHandler, ServiceExt,
|
||||
model::{
|
||||
ClientCapabilities, ErrorCode, Implementation, InitializeRequestParams, InitializeResult,
|
||||
ProtocolVersion,
|
||||
ClientCapabilities, ClientConfig, ErrorCode, Implementation, InitializeRequestParams,
|
||||
InitializeResult, ProtocolVersion, ServerConfig,
|
||||
},
|
||||
service::{ClientInitializeError, RequestContext},
|
||||
};
|
||||
|
|
@ -26,8 +26,8 @@ use rmcp::{
|
|||
struct EchoServer;
|
||||
|
||||
impl ServerHandler for EchoServer {
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::default()
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
ServerConfig::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -45,8 +45,8 @@ const HANDSHAKE_VERSIONS: &[ProtocolVersion] = &[
|
|||
struct NarrowedServer;
|
||||
|
||||
impl ServerHandler for NarrowedServer {
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::default()
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
ServerConfig::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) -> InitializeResult {
|
||||
let mut info = InitializeResult::default();
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
let mut info = ServerConfig::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) -> InitializeResult {
|
||||
InitializeResult::default()
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
ServerConfig::default()
|
||||
}
|
||||
|
||||
fn supported_protocol_versions(&self) -> Cow<'static, [ProtocolVersion]> {
|
||||
|
|
@ -102,8 +102,8 @@ struct VersionedClient {
|
|||
}
|
||||
|
||||
impl ClientHandler for VersionedClient {
|
||||
fn get_info(&self) -> InitializeRequestParams {
|
||||
let mut info = InitializeRequestParams::default();
|
||||
fn get_info(&self) -> ClientConfig {
|
||||
let mut info = ClientConfig::default();
|
||||
info.protocol_version = self.protocol_version.clone();
|
||||
info
|
||||
}
|
||||
|
|
@ -247,8 +247,8 @@ struct DelegatingServer {
|
|||
}
|
||||
|
||||
impl ServerHandler for DelegatingServer {
|
||||
fn get_info(&self) -> InitializeResult {
|
||||
InitializeResult::default()
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
ServerConfig::default()
|
||||
}
|
||||
|
||||
fn supported_protocol_versions(&self) -> Cow<'static, [ProtocolVersion]> {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
use rmcp::{
|
||||
ClientHandler, RoleClient, RoleServer, ServerHandler, ServiceError,
|
||||
model::{
|
||||
ErrorCode, ErrorData, InitializeRequestParams, InitializeResult, ProtocolVersion,
|
||||
ClientConfig, ErrorCode, ErrorData, InitializeResult, ProtocolVersion,
|
||||
ReadResourceRequestParams, ReadResourceResponse,
|
||||
},
|
||||
service::{RequestContext, serve_directly},
|
||||
|
|
@ -33,8 +33,8 @@ struct VersionedClient {
|
|||
}
|
||||
|
||||
impl ClientHandler for VersionedClient {
|
||||
fn get_info(&self) -> InitializeRequestParams {
|
||||
let mut info = InitializeRequestParams::default();
|
||||
fn get_info(&self) -> ClientConfig {
|
||||
let mut info = ClientConfig::default();
|
||||
info.protocol_version = self.protocol_version.clone();
|
||||
info
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue