Skip to content

Warn when a pre-provisioned OAuth client is created without an issuer - #3435

Open
maxisbey wants to merge 2 commits into
mainfrom
m2m-issuer-warning
Open

Warn when a pre-provisioned OAuth client is created without an issuer#3435
maxisbey wants to merge 2 commits into
mainfrom
m2m-issuer-warning

Conversation

@maxisbey

@maxisbey maxisbey commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

ClientCredentialsOAuthProvider and PrivateKeyJWTOAuthProvider now emit a UserWarning at construction when issuer= is not given.

Motivation and Context

#3398 added the optional issuer= keyword to the two pre-provisioned providers: with it, token requests are only ever built from metadata for that authorization server. Without it the provider follows whichever authorization server the MCP server advertises, which is the behaviour these providers have always had, and it stays allowed. The difference between the two is easy to miss when reading a constructor call, so the provider now says which one you picked:

UserWarning: No `issuer` given: client credentials will be sent to whichever authorization server the MCP
server advertises. Pass issuer=<your authorization server's issuer URL> to send them only there.

stacklevel points the warning at the caller's constructor line. Passing issuer= silences it, and there is no other change in behaviour.

How Has This Been Tested?

tests/client/auth/extensions/test_client_credentials.py: a parametrised test asserts the warning text and that it is attributed to the calling file for both providers, and one test keeps exercising the no-issuer exchange path under pytest.warns. The older tests in that file, the interaction tests and the PrivateKeyJWTOAuthProvider docs test now pass issuer= matching the authorization server they already mock or run. The oauth_client_credentials example story passes issuer= too.

Breaking Changes

None. Code that constructs either provider without issuer= keeps working and now sees one UserWarning per call site (test suites running with warnings as errors will want to pass issuer= or filter it).

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 am assigned to the linked issue (or it is labeled help wanted, or I'm a maintainer)
  • I have disclosed any AI assistance and can explain the change in my own words
  • 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 conformance client script constructs these providers from the harness's context, which does not carry an issuer yet, so the client-conformance job will print the warning; that is expected.

AI Disclaimer

ClientCredentialsOAuthProvider and PrivateKeyJWTOAuthProvider send fixed
credentials to whichever authorization server discovery yields unless
`issuer=` names the one they belong to. Leaving it out stays allowed, but
the provider now says so at construction with a UserWarning that names the
server URL and the keyword to pass, so the choice is visible rather than
silent. Nothing else changes: with `issuer=` set there is no warning, and a
value that is not an http(s) URL is still a ValueError.

The example story and the interaction tests pass `issuer=` (their
authorization server is known); the extension tests that exercise the
no-issuer path opt in to the warning explicitly.
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

📚 Documentation preview

Preview https://pr-3435.mcp-python-docs.pages.dev
Deployment https://f634a978.mcp-python-docs.pages.dev
Commit 91d18b4
Triggered by @maxisbey
Updated 2026-09-03 15:49:13 UTC

@maxisbey
maxisbey marked this pull request as ready for review September 3, 2026 14:12

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

Re-trigger cubic

The warning is already attributed to the caller's constructor line, so it does not need the provider name or server URL; _checked_issuer keeps its single argument.
@maxisbey

maxisbey commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

test2

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