feat: provide more context information (#236)
* feat: provide more context information 1. provide context for notification 2. allow extract more info from tool call 3. inject http request part for streamable http server * docs: add document for getting peer from context
This commit is contained in:
parent
9fc6af091d
commit
969fad26cc
2 changed files with 194 additions and 40 deletions
|
|
@ -4,8 +4,9 @@ use std::{
|
|||
};
|
||||
|
||||
use rmcp::{
|
||||
ClientHandler, Error as McpError, RoleClient, RoleServer, ServerHandler, model::*,
|
||||
service::RequestContext,
|
||||
ClientHandler, Error as McpError, RoleClient, RoleServer, ServerHandler,
|
||||
model::*,
|
||||
service::{NotificationContext, RequestContext},
|
||||
};
|
||||
use serde_json::json;
|
||||
use tokio::sync::Notify;
|
||||
|
|
@ -83,6 +84,7 @@ impl ClientHandler for TestClientHandler {
|
|||
fn on_logging_message(
|
||||
&self,
|
||||
params: LoggingMessageNotificationParam,
|
||||
_context: NotificationContext<RoleClient>,
|
||||
) -> impl Future<Output = ()> + Send + '_ {
|
||||
let receive_signal = self.receive_signal.clone();
|
||||
let received_messages = self.received_messages.clone();
|
||||
|
|
|
|||
|
|
@ -52,7 +52,11 @@ pub struct Client {
|
|||
}
|
||||
|
||||
impl ClientHandler for Client {
|
||||
async fn on_resource_updated(&self, params: rmcp::model::ResourceUpdatedNotificationParam) {
|
||||
async fn on_resource_updated(
|
||||
&self,
|
||||
params: rmcp::model::ResourceUpdatedNotificationParam,
|
||||
_context: rmcp::service::NotificationContext<rmcp::RoleClient>,
|
||||
) {
|
||||
let uri = params.uri;
|
||||
tracing::info!("Resource updated: {}", uri);
|
||||
self.receive_signal.notify_one();
|
||||
|
|
|
|||
Loading…
Reference in a new issue