Skip to content

Use accessor method in server_context_with_meta instead of ivar#273

Merged
koic merged 1 commit intomodelcontextprotocol:mainfrom
koic:use_accessor_in_server_context_with_meta
Mar 27, 2026
Merged

Use accessor method in server_context_with_meta instead of ivar#273
koic merged 1 commit intomodelcontextprotocol:mainfrom
koic:use_accessor_in_server_context_with_meta

Conversation

@koic
Copy link
Copy Markdown
Member

@koic koic commented Mar 27, 2026

Motivation and Context

server_context_with_meta reads @server_context (the instance variable) directly instead of calling the server_context accessor method. This prevents subclasses from overriding server_context. Ffor example, to provide thread-local context in multi-threaded servers like Puma.

Fixes #271.

How Has This Been Tested?

Added a regression test and passed.

Breaking Changes

None. This restores the expected behavior of attr_accessor :server_context.

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

## Motivation and Context

`server_context_with_meta` reads `@server_context` (the instance variable)
directly instead of calling the `server_context` accessor method.
This prevents subclasses from overriding `server_context`. Ffor example,
to provide thread-local context in multi-threaded servers like Puma.

Fixes modelcontextprotocol#271.

## How Has This Been Tested?

Added a regression test and passed.

## Breaking Changes

None. This restores the expected behavior of `attr_accessor :server_context`.
@koic koic merged commit 6b09279 into modelcontextprotocol:main Mar 27, 2026
11 checks passed
@koic koic deleted the use_accessor_in_server_context_with_meta branch March 27, 2026 03:08
@koic koic mentioned this pull request Mar 27, 2026
5 tasks
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.

server_context_with_meta reads @server_context ivar instead of accessor method

2 participants