Skip to content

[backport] Wire OAuth 2.1 login into stdio server (upstream main) #11

Description

@gastrodon

Summary

Connects the internal/oauth core library to the stdio MCP server:

  • BearerAuthTransport gains a TokenProvider consulted per-request, so the lazily-acquired, auto-refreshing OAuth token replaces the pinned static token without rebuilding the HTTP client
  • RunStdioServer starts without a token and installs receiving middleware that runs the authorization flow on the first tool call, surfacing the auth URL or device code via elicitation (or a tool-result fallback)
  • Tool filtering uses the requested OAuth scopes; missing-scope tools are hidden
  • A sessionPrompter adapts the MCP server session to oauth.Prompter, keeping the auth URL off the model's context
  • New stdio flags: --oauth-client-id, --oauth-client-secret, --oauth-scopes, --oauth-callback-port
  • New internal/ghmcp/oauth.go integrates the session layer; internal/ghmcp/server.go updated

Upstream reference

Fork conflict

None. internal/ghmcp/server.go additions are additive alongside the fork's existing project-management setup.

Context

Without this wiring, the core OAuth library has no effect. This commit makes OAuth login the default path for stdio users on github.com by intercepting the first MCP tool call.

Depends on

See parent issue (OAuth story).

Metadata

Metadata

Assignees

No one assigned

    Labels

    backportBackport from upstreamfeatureNew featureno-opFork already has equivalent functionality

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions