Skip to content

Stop requiring base64 in the OAuth client - #678

Merged
koic merged 1 commit into
modelcontextprotocol:mainfrom
koic:stop_requiring_base64_in_the_oauth_client
Nov 11, 2026
Merged

koic merged 1 commit into
modelcontextprotocol:mainfrom
koic:stop_requiring_base64_in_the_oauth_client

Conversation

@koic

@koic koic commented Nov 11, 2026

Copy link
Copy Markdown
Member

Motivation and Context

base64 stopped being a default gem in Ruby 3.4, and the gemspec does not declare it. Under Bundler, an application that does not get it through another gem could require "mcp", but the first reference to MCP::Client, or to a server-side OAuth class that uses the client's URL checks such as MCP::Server::OAuth::ProtectedResourceMetadata, raised LoadError: cannot load such file -- base64. The suite did not see it because activesupport in the Gemfile brings base64 in.

The three Base64 calls (the PKCE code challenge, the segments of a JWT client assertion, and the Authorization: Basic credentials) are spelled with Array#pack("m0"), as the rest of the library already encodes, so the gem keeps json_schemer as its only runtime dependency. The output is byte for byte the same.

Reported in the side note of #677.

How Has This Been Tested?

test/mcp/client/oauth/base64_dependency_test.rb loads the client and the server-side OAuth classes in a fresh process that refuses require "base64"; it fails on the previous library with the LoadError. The existing PKCE, client assertion and flow tests compare the output with Base64.

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

## Motivation and Context

`base64` stopped being a default gem in Ruby 3.4, and the gemspec does not declare it. Under Bundler, an application
that does not get it through another gem could `require "mcp"`, but the first reference to `MCP::Client`,
or to a server-side OAuth class that uses the client's URL checks such as `MCP::Server::OAuth::ProtectedResourceMetadata`,
raised `LoadError: cannot load such file -- base64`. The suite did not see it because `activesupport` in the Gemfile brings `base64` in.

The three `Base64` calls (the PKCE code challenge, the segments of a JWT client assertion, and the `Authorization: Basic` credentials)
are spelled with `Array#pack("m0")`, as the rest of the library already encodes, so the gem keeps `json_schemer` as its only runtime dependency.
The output is byte for byte the same.

Reported in the side note of modelcontextprotocol#677.

## How Has This Been Tested?

`test/mcp/client/oauth/base64_dependency_test.rb` loads the client and the server-side OAuth classes in a fresh process
that refuses `require "base64"`; it fails on the previous library with the `LoadError`. The existing PKCE, client assertion
and flow tests compare the output with `Base64`.

## Breaking Changes

None.
@koic
koic merged commit a0757ca into modelcontextprotocol:main Nov 11, 2026
13 checks passed
@koic
koic deleted the stop_requiring_base64_in_the_oauth_client branch November 11, 2026 13:13
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.

2 participants