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:
parent
c1c4c9a0c9
commit
076dc2c2cd
1 changed files with 95 additions and 96 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue