Skip to content

Conversation

@apexlnc
Copy link
Contributor

@apexlnc apexlnc commented Jan 29, 2026

Move CustomRequest and CustomResult to end of their respective untagged enums to ensure specific task variants match before catch-all custom types. Add deny_unknown_fields to GetTaskInfoResult to prevent matching arbitrary JSON objects.

Fixes issue where tasks/get, tasks/list, tasks/result, and tasks/cancel incorrectly deserialized as CustomRequest instead of their typed variants.

Motivation and Context

Fixes deserialization bug where task-related requests (tasks/get, tasks/list, tasks/result, tasks/cancel) were incorrectly matching CustomRequest instead of their specific typed variants. This occurred because serde tries untagged enum variants in order, and CustomRequest accepted any method string.

The bug prevented proper routing of task requests in gateways and servers that deserialize into ClientRequest/ServerResult enums.

How Has This Been Tested?

  • All existing tests pass (268 tests)
  • Tested with custom request integration tests
  • Schema validation tests updated and passing
  • Verified task requests now deserialize to correct types (GetTaskInfoRequest, etc.) instead of CustomRequest

Breaking Changes

None. This is a bug fix that corrects deserialization behavior without changing the public API.

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

The fix involves two changes:

  1. Reordering enum variants to place catch-all types (CustomRequest, CustomResult) last
  2. Adding #[serde(deny_unknown_fields)] to GetTaskInfoResult to prevent it from matching arbitrary JSON

This ensures serde's untagged enum deserialization tries specific variants before falling back to custom types.

Move CustomRequest and CustomResult to end of their respective untagged
enums to ensure specific task variants match before catch-all custom types.
Add deny_unknown_fields to GetTaskInfoResult to prevent matching arbitrary
JSON objects.

Fixes issue where tasks/get, tasks/list, tasks/result, and tasks/cancel
incorrectly deserialized as CustomRequest instead of their typed variants.
@github-actions github-actions bot added T-test Testing related changes T-config Configuration file changes T-core Core library changes labels Jan 29, 2026
apexlnc added a commit to apexlnc/agentgateway that referenced this pull request Jan 29, 2026
- Add support for "Human-in-the-loop" parameter filling (SEP-1330) and
  handroll URL-mode support (SEP-1036) locally while awaiting
  upstream inclusion in modelcontextprotocol/rust-sdk#605.
- Implement full lifecycle management for background tasks (SEP-1686),
  allowing tools to enqueue long-running work and poll for results
  across multiplexed upstreams.
- Implement a "Soft Error" parser for code -32042 (URL Required) to
  relay interactive requirements as JSON-RPC data instead of
  transport failures, preserving stateful sessions.
- Refactor session setup to automatically negotiate and mirror
  protocol capabilities between downstream clients and upstream servers.
- Upgrade rmcp to 0.14.0, adopt decoupled structures (SEP-1319), and
  pin git rev ac4146e to resolve an enum variant shadowing issue
  (see modelcontextprotocol/rust-sdk#634).
- Enhance multiplexing logic to preserve and nest upstream _meta fields
  for end-to-end tracing and observability compliance.
- Replace legacy-rmcp (0.10.0) with modern 0.14.0 resumable-polling
  SSE implementations.
apexlnc added a commit to apexlnc/agentgateway that referenced this pull request Jan 29, 2026
- Add support for "Human-in-the-loop" parameter filling (SEP-1330) and
  handroll URL-mode support (SEP-1036) locally while awaiting
  upstream inclusion in modelcontextprotocol/rust-sdk#605.
- Implement full lifecycle management for background tasks (SEP-1686),
  allowing tools to enqueue long-running work and poll for results
  across multiplexed upstreams.
- Implement a "Soft Error" parser for code -32042 (URL Required) to
  relay interactive requirements as JSON-RPC data instead of
  transport failures, preserving stateful sessions.
- Refactor session setup to automatically negotiate and mirror
  protocol capabilities between downstream clients and upstream servers.
- Upgrade rmcp to 0.14.0, adopt decoupled structures (SEP-1319), and
  pin git rev ac4146e to resolve an enum variant shadowing issue
  (see modelcontextprotocol/rust-sdk#634).
- Enhance multiplexing logic to preserve and nest upstream _meta fields
  for end-to-end tracing and observability compliance.
- Replace legacy-rmcp (0.10.0) with modern 0.14.0 resumable-polling
  SSE implementations.
@jokemanfire jokemanfire merged commit 32a68aa into modelcontextprotocol:main Jan 30, 2026
11 checks passed
apexlnc added a commit to apexlnc/agentgateway that referenced this pull request Jan 30, 2026
- Add support for "Human-in-the-loop" parameter filling (SEP-1330) and
  handroll URL-mode support (SEP-1036) locally while awaiting
  upstream inclusion in modelcontextprotocol/rust-sdk#605.
- Implement full lifecycle management for background tasks (SEP-1686),
  allowing tools to enqueue long-running work and poll for results
  across multiplexed upstreams.
- Implement a "Soft Error" parser for code -32042 (URL Required) to
  relay interactive requirements as JSON-RPC data instead of
  transport failures, preserving stateful sessions.
- Refactor session setup to automatically negotiate and mirror
  protocol capabilities between downstream clients and upstream servers.
- Upgrade rmcp to 0.14.0, adopt decoupled structures (SEP-1319), and
  pin git rev ac4146e to resolve an enum variant shadowing issue
  (see modelcontextprotocol/rust-sdk#634).
- Enhance multiplexing logic to preserve and nest upstream _meta fields
  for end-to-end tracing and observability compliance.
- Replace legacy-rmcp (0.10.0) with modern 0.14.0 resumable-polling
  SSE implementations.
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-test Testing related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants