Skip to content

Add Initial Access Token Support for Dynamic Client Registration #772

Open
@andormarkus

Description

@andormarkus

Is your feature request related to a problem? Please describe.

The current MCP TypeScript SDK implementation of OAuth 2.0 Dynamic Client Registration does not support initial access tokens, which limits deployment flexibility for enterprise use cases. According to RFC 7591, authorization servers may optionally restrict client registration to only previously authorized parties using initial access tokens.

While open registration is perfectly acceptable for consumer applications and development scenarios, enterprise deployments often require this additional security layer. Without this optional support, enterprise MCP servers must either:

  1. Implement custom workarounds outside the standard OAuth flow
  2. Use third-party solutions
  3. Pre-register all clients manually (defeats the purpose of dynamic registration)

This limitation prevents enterprise-grade deployments while maintaining current open registration capabilities for consumer applications.

Describe the solution you'd like

Add optional support for initial access tokens in the dynamic client registration flow. The implementation should:

  1. Provide an easy configuration method such as:

    • Environment variables (e.g., MCP_INITIAL_ACCESS_TOKEN, OAUTH_INITIAL_ACCESS_TOKEN)
    • Configuration files
    • Constructor parameters
    • Other standard configuration approaches
  2. Maintain backward compatibility - existing code should continue to work without changes

  3. Follow RFC 7591 specification - when an initial access token is provided, include it as a Bearer token in the Authorization header of the registration request:

    Authorization: Bearer <initial_access_token>
    
  4. Handle missing tokens gracefully - when no token is provided, proceed with open registration (normal behavior for consumer apps)

  5. Provide clear error handling for cases where tokens are invalid (but remember that missing tokens are expected and valid for consumer apps)

Describe alternatives you've considered

  • Custom middleware: Implementing initial access token validation as separate middleware, but this breaks the standard OAuth flow
  • Third-party solutions: Using external libraries, but this adds complexity and dependencies
  • Pre-registration: Manually registering all clients, but this eliminates the benefits of dynamic registration
  • Open registration only: This works for consumer applications but doesn't meet enterprise security requirements

Additional context

  • RFC 7591 compliance: The OAuth 2.0 Dynamic Client Registration Protocol supports initial access tokens as an optional feature for restricting registration access
  • Enterprise flexibility: This provides an optional security layer for enterprise deployments without impacting consumer applications
  • Industry standard: Authorization servers like Auth0, Keycloak, and others already support this feature
  • Deployment options: This enables both open registration (consumer apps) and restricted registration (enterprise) from the same codebase

Implementation considerations

The maintainers can choose the most appropriate implementation approach, but it should be easy for developers to configure, such as:

  • Setting an environment variable
  • Adding a configuration option
  • Providing the token through existing configuration mechanisms

Expected behavior

When an initial access token is configured:

  • Include it as Authorization: Bearer <token> in the registration request
  • Handle 401/403 responses appropriately when tokens are invalid

When no initial access token is configured:

  • Proceed with open registration (current behavior)
  • Maintain full backward compatibility

This enhancement would provide deployment flexibility for both consumer applications and enterprise deployments while bringing the TypeScript SDK closer to full RFC 7591 compliance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions