feat: better http server support (#199)

* feat: better http server support

1. allow user get extensions in tool call.
2. allow user serve sse service without initialization.

* fix: fix document test
This commit is contained in:
4t145 2025-05-19 18:49:18 +08:00 • committed by GitHub
commit 076dc2c2cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,16 +4,14 @@ use std::{
};
use rmcp::{
ClientHandler, Error as McpError, RoleClient, RoleServer, ServerHandler,
model::*,
service::{Peer, RequestContext},
ClientHandler, Error as McpError, RoleClient, RoleServer, ServerHandler, model::*,
service::RequestContext,
};
use serde_json::json;
use tokio::sync::Notify;
#[derive(Clone)]
pub struct TestClientHandler {
pub peer: Option<Peer<RoleClient>>,
pub honor_this_server: bool,
pub honor_all_servers: bool,
pub receive_signal: Arc<Notify>,
@ -24,7 +22,6 @@ impl TestClientHandler {
#[allow(dead_code)]
pub fn new(honor_this_server: bool, honor_all_servers: bool) -> Self {
Self {
peer: None,
honor_this_server,
honor_all_servers,
receive_signal: Arc::new(Notify::new()),
@ -40,7 +37,6 @@ impl TestClientHandler {
received_messages: Arc<Mutex<Vec<LoggingMessageNotificationParam>>>,
) -> Self {
Self {
peer: None,
honor_this_server,
honor_all_servers,
receive_signal,
@ -50,14 +46,6 @@ impl TestClientHandler {
}
impl ClientHandler for TestClientHandler {
fn get_peer(&self) -> Option<Peer<RoleClient>> {
self.peer.clone()
}
fn set_peer(&mut self, peer: Peer<RoleClient>) {
self.peer = Some(peer);
}
async fn create_message(
&self,
params: CreateMessageRequestParam,