Skip to content

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

Draft
DaleSeo wants to merge 3 commits intomainfrom
feat/local-feature-send-bounds
Draft

feat: add local feature for !Send tool handler support#740
DaleSeo wants to merge 3 commits intomainfrom
feat/local-feature-send-bounds

Conversation

@DaleSeo
Copy link
Member

@DaleSeo DaleSeo commented Mar 9, 2026

Closes #728

Motivation and Context

Some MCP server use cases involve state that isn't Send. For example, this includes holding a raw pointer, an Rc, or a thread-local resource. The current service stack requires Send + Sync everywhere, which completely rules these out. This PR introduces a local Cargo feature that relaxes all Send and Sync bounds across the service stack. This change allows servers with !Send handlers to run on a single-threaded runtime using tokio::task::LocalSet and spawn_local.

How Has This Been Tested?

The full test suite passes in both modes:

  • cargo test --features server,client (default, no behavior change)
  • cargo test --features server,client,local (new path).

Breaking Changes

None. Without the local feature the effective trait bounds are identical to before — MaybeSend resolves to Send + Sync and MaybeSendFuture resolves to Send via blanket impls. The feature is strictly opt-in.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@DaleSeo DaleSeo self-assigned this Mar 9, 2026
@github-actions github-actions bot added T-dependencies Dependencies related changes T-test Testing related changes T-config Configuration file changes T-core Core library changes T-handler Handler implementation changes T-macros Macro changes T-service Service layer changes labels Mar 9, 2026
@github-actions github-actions bot added the T-transport Transport layer changes label Mar 9, 2026
@github-actions github-actions bot added the T-documentation Documentation improvements label Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-config Configuration file changes T-core Core library changes T-dependencies Dependencies related changes T-documentation Documentation improvements T-handler Handler implementation changes T-macros Macro changes T-service Service layer changes T-test Testing related changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Support for !Send futures in #[tool] handlers (e.g. #[tool(local)])

1 participant