Skip to content

Pass the access token to a handler the legacy input_required shim re-runs - #696

Open
koic wants to merge 1 commit into
modelcontextprotocol:mainfrom
koic:pass_the_access_token_to_a_handler_the_legacy_input_required_shim_re_runs
Open

koic wants to merge 1 commit into
modelcontextprotocol:mainfrom
koic:pass_the_access_token_to_a_handler_the_legacy_input_required_shim_re_runs

Conversation

@koic

@koic koic commented Nov 20, 2026

Copy link
Copy Markdown
Member

Motivation and Context

When a handler on the handshake lifecycle returns input_required, the legacy shim sends the embedded requests to the client and runs the handler again with the answers. The re-run was dispatched without the access token of the request, so server_context.auth_info was nil on every round after the first: a tool that calls server_context.require_scopes! was answered insufficient_scope after the user had replied, and a handler that reads the caller's identity lost it. tools/call, prompts/get and resources/read were all affected.

Every round belongs to the one authenticated request, so the shim now threads auth_info through to the re-run.

How Has This Been Tested?

test/mcp/server_input_required_legacy_shim_test.rb; both new tests fail on the previous library, where the second run sees no token.

Breaking Changes

None.

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

…e-runs

## Motivation and Context

When a handler on the handshake lifecycle returns `input_required`, the legacy shim sends the embedded requests
to the client and runs the handler again with the answers. The re-run was dispatched without the access token of
the request, so `server_context.auth_info` was `nil` on every round after the first: a tool that calls
`server_context.require_scopes!` was answered `insufficient_scope` after the user had replied, and a handler that
reads the caller's identity lost it. `tools/call`, `prompts/get` and `resources/read` were all affected.

Every round belongs to the one authenticated request, so the shim now threads `auth_info` through to the re-run.

## How Has This Been Tested?

`test/mcp/server_input_required_legacy_shim_test.rb`; both new tests fail on the previous library, where
the second run sees no token.

## Breaking Changes

None.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant