Skip to content

Practical OAuth implementation for production #1052

Description

@dennis-yemelyanov

For building a production-ready remote MCP server with OAuth authentication, what is a practical way to implement the authentication part?

So far all the examples I've checked have comments like "not for production use" and often contain code implementing low-level details of some security protocols. For example, the ProtectedMcpServer sample seem to depend on the TestOAuthServer, which basically implements an OAuth server from scratch, including things like token encryption, encoding etc. This is very useful for educational purposes, but probably not very practical for building a real application.

It's also possible to point the AuthorizationServers metadata to an existing auth provider (Microsoft/Google/etc.), but seems like even that doesn't work well with some providers due to issues like #648, and it's not clear whether those issues might actually be by design due to incorrect usage.

So, as of today, how should someone building a real world MCP server go about authentication? Is their best bet to build an OAuth server from scratch just like the samples show? Or is there a better re-usable solution, ideally an existing authentication service that is well supported and works smoothly with MCP scenarios?

Activity

  1. added
    help wantedContributions welcome from those familiar with codebase
    ready for workHas enough information to start
    on Mar 31, 2026
  2. jeffhandley commented on Jul 20, 2026

    @jeffhandley
    Contributor

    Thanks for raising this. Labeling as an enhancement for production-ready OAuth guidance/samples that go beyond the current ProtectedMcpServer + TestOAuthServer examples (which are intentionally not production-grade).

    This is marked help wanted and ready for work -- a community pull request adding a production-oriented OAuth sample or conceptual guide is very welcome.

  3. added this to the 2.x milestone on Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Nice to haves, rare edge casesarea-authdocumentationImprovements or additions to documentationenhancementNew feature or requesthelp wantedContributions welcome from those familiar with codebaseready for workHas enough information to start

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions