feat: add local feature for !Send tool handler support (#740)

* feat: add local feature for !Send tool handler support

* fix: gate streamable HTTP transport on not(local) feature
This commit is contained in:
Dale Seo 2026-03-11 17:22:56 -04:00 • committed by GitHub
commit 1a4a52a173
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 362 additions and 222 deletions

View file

@ -7,7 +7,11 @@ use std::{
use rmcp::service::NotificationContext;
#[cfg(feature = "client")]
use rmcp::{ClientHandler, RoleClient};
use rmcp::{ErrorData as McpError, RoleServer, ServerHandler, model::*, service::RequestContext};
use rmcp::{
ErrorData as McpError, RoleServer, ServerHandler,
model::*,
service::{MaybeSendFuture, RequestContext},
};
#[cfg(feature = "client")]
use serde_json::json;
use tokio::sync::Notify;
@ -85,7 +89,7 @@ impl ClientHandler for TestClientHandler {
&self,
params: LoggingMessageNotificationParam,
_context: NotificationContext<RoleClient>,
) -> impl Future<Output = ()> + Send + '_ {
) -> impl Future<Output = ()> + MaybeSendFuture + '_ {
let receive_signal = self.receive_signal.clone();
let received_messages = self.received_messages.clone();
@ -116,7 +120,7 @@ impl ServerHandler for TestServer {
&self,
request: SetLevelRequestParams,
context: RequestContext<RoleServer>,
) -> impl Future<Output = Result<(), McpError>> + Send + '_ {
) -> impl Future<Output = Result<(), McpError>> + MaybeSendFuture + '_ {
let peer = context.peer;
async move {
let (data, logger) = match request.level {

View file

@ -1,5 +1,5 @@
// cargo test --features "server client" --package rmcp test_client_initialization
#![cfg(feature = "client")]
#![cfg(all(feature = "client", not(feature = "local")))]
mod common;

View file

@ -1,3 +1,4 @@
#![cfg(not(feature = "local"))]
//cargo test --test test_close_connection --features "client server"
mod common;

View file

@ -1,3 +1,4 @@
#![cfg(not(feature = "local"))]
use std::collections::HashMap;
use http::{HeaderName, HeaderValue};

View file

@ -1,3 +1,4 @@
#![cfg(not(feature = "local"))]
use std::sync::Arc;
use rmcp::{

View file

@ -1,4 +1,5 @@
// cargo test --features "server client" --package rmcp test_logging
#![cfg(not(feature = "local"))]
mod common;
use std::sync::{Arc, Mutex};

View file

@ -1,4 +1,5 @@
//cargo test --test test_message_protocol --features "client server"
#![cfg(not(feature = "local"))]
mod common;
use common::handlers::{TestClientHandler, TestServer};

View file

@ -1,3 +1,4 @@
#![cfg(not(feature = "local"))]
use std::sync::Arc;
use rmcp::{

View file

@ -1,3 +1,4 @@
#![cfg(not(feature = "local"))]
use futures::StreamExt;
use rmcp::{
ClientHandler, Peer, RoleServer, ServerHandler, ServiceExt,

View file

@ -1,3 +1,4 @@
#![cfg(not(feature = "local"))]
//cargo test --test test_prompt_macros --features "client server"
#![allow(dead_code)]
use std::sync::Arc;

View file

@ -1,3 +1,4 @@
#![cfg(not(feature = "local"))]
use std::collections::HashMap;
use futures::future::BoxFuture;

View file

@ -1,3 +1,4 @@
#![cfg(not(feature = "local"))]
mod common;
use anyhow::Result;

View file

@ -1,5 +1,5 @@
// cargo test --features "client" --package rmcp -- server_init
#![cfg(feature = "client")]
#![cfg(all(feature = "client", not(feature = "local")))]
mod common;
use common::handlers::TestServer;

View file

@ -1,3 +1,4 @@
#![cfg(not(feature = "local"))]
/// Tests for concurrent SSE stream handling (shadow channels)
///
/// These tests verify that multiple GET SSE streams on the same session

View file

@ -1,3 +1,4 @@
#![cfg(not(feature = "local"))]
use rmcp::transport::streamable_http_server::{
StreamableHttpServerConfig, StreamableHttpService, session::local::LocalSessionManager,
};

View file

@ -1,3 +1,4 @@
#![cfg(not(feature = "local"))]
use std::time::Duration;
use rmcp::transport::streamable_http_server::{

View file

@ -1,7 +1,8 @@
#![cfg(all(
feature = "transport-streamable-http-client",
feature = "transport-streamable-http-client-reqwest",
feature = "transport-streamable-http-server"
feature = "transport-streamable-http-server",
not(feature = "local")
))]
use std::{collections::HashMap, sync::Arc};

View file

@ -1,3 +1,4 @@
#![cfg(not(feature = "local"))]
//! Tests for task support validation in tool calls.
//!
//! Verifies that the server correctly validates `execution.taskSupport` settings

View file

@ -1,3 +1,4 @@
#![cfg(not(feature = "local"))]
//! Test tool macros, including documentation for generated fns.
//cargo test --test test_tool_macros --features "client server"

View file

@ -1,3 +1,4 @@
#![cfg(not(feature = "local"))]
use std::collections::HashMap;
use futures::future::BoxFuture;

Some files were not shown because too many files have changed in this diff Show more