Repository navigation
Conversation
Add samples/simple-oauth-client, a command-line client that signs in to an OAuth-protected MCP server over Streamable HTTP. On a 401 it discovers the protected resource and authorization server metadata, registers a public client dynamically, runs the authorization code flow with PKCE on a loopback redirect, exchanges the code with the resource parameter and retries. The test runs the full flow against an in-process MCP server guarded by a minimal authorization server.
Rutvij97
force-pushed
the
feat/simple-oauth-client-sample
branch
from
November 10, 2026 21:20
d050792 to
52f3af1
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #166.
Adds
samples/simple-oauth-client, a command-line client that signs in to an OAuth-protected MCP server over Streamable HTTP. The SDK doesn't ship client-side OAuth yet, so the sample implements the MCP authorization flow with plain Ktor:HttpSendinterceptor adds the bearer token. On401it runs the flow and retries once.resource_metadatahint fromWWW-Authenticate, then the authorization server metadata (RFC 8414, with OIDC as a fallback).MCP_CLIENT_ID/MCP_CLIENT_SECRETcan be used instead.S256and astatecheck, receiving the code on a loopback redirect (http://127.0.0.1:<port>/callback).resourceparameter (RFC 8707), then lists tools and optionally calls one.samples/README.mdnow lists the new sample.I left the CI sample matrices in
build.ymlandsamples.ymluntouched. Happy to addsimple-oauth-clientto them if you'd like it built in CI.Testing
OAuthClientTestruns the full flow against an in-process MCP server. The server is the SDK'smcpStreamableHttpwith awhoamitool, guarded by a minimal authorization server that checks the PKCE verifier, redirect URI andresource. The test also covers state mismatch rejection, the RFC 7636 S256 test vector andWWW-Authenticateparsing../gradlew buildinsamples/simple-oauth-client(JDK 21) passes: 4 tests..editorconfigreports no issues.