Skip to content

SEP-1489: Tool Error Responses for Triggering OAuth Flows #1489

Closed

Description

@thiago-openai

SEP: Tool Error Responses for Triggering OAuth Flows

Authors: Duke Kim ([email protected]), Thiago Hirai ([email protected])
Status: Draft
Sponsor: Nick Cooper ([email protected])
Type: Standards Track
Created: 2025-09-17

Summary

When a tool requires authentication at runtime, it can return an error that tells clients to start an OAuth flow. The signal is carried in the tool’s _meta field under mcp/www_authenticate, which contains one or more WWW-Authenticate header values (per RFC 9278).

Clients that understand this convention will:

  • Parse the WWW-Authenticate challenge
  • Extract the resource_metadata URI
  • Fetch authorization server metadata
  • Run the OAuth flow as defined in MCP

Motivation

Even with static securitySchemes, clients sometimes hit runtime failures (e.g. scope mismatched tokens). This mechanism provides a clear, machine-readable signal that authentication is needed, plus enough metadata for clients to resolve which auth server to use.

Design

Error Response Shape

A tool signals “auth required” by sending a ToolResponse with:

  • isError: true
  • _meta.mcp/www_authenticate: a string or array of strings containing RFC-compliant WWW-Authenticate header values
  • content: still required by the MCP spec, but mainly for human-readable display and old client compatibility

Example

  "jsonrpc": "2.0",
  "id": 4,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "Authentication required: no access token provided."
      }
    ],
    "_meta": {
      "mcp/www_authenticate": [
        "Bearer error=\"invalid_request\" error_description=\"No access token was provided\" resource_metadata=\"https://auth.openai.com\""
      ]
    },
    "isError": true
  }
}

Client Behavior

  • Detect isError: true.
  • Display content if needed for the user.
  • If _meta.mcp/www_authenticate is present:
    • Parse challenge(s)
    • Extract resource_metadata
    • Fetch metadata and locate the authorization server
    • Trigger the OAuth flow (per MCP spec)
    • Retry the tool call if a token is obtained

Server Behavior

  • Always include content (for spec compliance and old clients
  • Return a standards-compliant WWW-Authenticate header value inside _meta.mcp/www_authenticate
  • Ensure resource_metadata points to a valid metadata document
  • Leave actual token enforcement to the authorization server

Compatibility

  • Optional mechanism: servers can choose to implement or not.
  • Backward-compatible: old clients ignore the field in _meta and just display the error.

Security Notes

  • Clients must validate resource_metadata documents before trusting them
  • Servers should not return misleading or incorrect metadata URIs
  • This only advertises auth needs; token enforcement remains the same

Activity

  1. changed the title [-]SEP: Tool Error Responses for Triggering OAuth Flows[/-] [+]SEP-1489: Tool Error Responses for Triggering OAuth Flows[/+] on Sep 18, 2025
  2. self-assigned this
    on Sep 18, 2025
  3. ggoodman commented on Sep 18, 2025

    @ggoodman
    Contributor

    Here's a slightly different approach that tried to generalize and solve the same issue: https://github.com/orgs/modelcontextprotocol/discussions/405

  4. max-stytch commented on Sep 18, 2025

    @max-stytch
    Contributor

    Check out #835 which is extremely similar in terms of letting the MCP Server drive OAuth flows at tool-call time using WWW-Authenticate headers. One potential point of discussion is that (835) today binds the authorization tightly to the HTTP transport - yours is transport independent.

  5. localden commented on Sep 18, 2025

    @localden
    Contributor

    I second what @max-stytch suggested - #835 covers the bulk of the scenarios here, it seems. I am not so sure about transport-agnosticism here, TBH, mainly because a local (STDIO)-based server can do a lot of things directly within the environment without having to rely on transport logic.

    It also may be a personal preference speaking here, but feels a bit odd to start embedding HTTP header logic into _meta.

  6. pcarleton commented on Sep 19, 2025

    @pcarleton
    Member

    I think transport agnostic auth is interesting, but would require more than just this proposal to work. As in, the token would need to be passed somehow in the stdio message negotiation. I'd be in favor of closing this in favor of #835 and discussing transport agnostic auth separately.

  7. github-actions commented on Jan 16, 2026

    @github-actions
    Contributor

    Maintainer Activity Check

    Hi @nickcoai!

    You're assigned to this SEP but there hasn't been any activity from you in 119 days.

    Please provide an update on:

    • Current status of your review/work
    • Any blockers or concerns
    • Expected timeline for next steps

    If you're no longer able to sponsor this SEP, please let us know so we can find another maintainer.


    This is an automated message from the SEP lifecycle bot.

  8. sep-automation-bot commented on Feb 2, 2026

    @sep-automation-bot

    Maintainer Activity Check

    Hi @nickcoai!

    You're assigned to this SEP but there hasn't been any activity from you in 16 days.

    Please provide an update on:

    • Current status of your review/work
    • Any blockers or concerns
    • Expected timeline for next steps

    If you're no longer able to sponsor this SEP, please let us know so we can find another maintainer.


    This is an automated message from the SEP lifecycle bot.

  9. sep-automation-bot commented on Feb 16, 2026

    @sep-automation-bot

    Maintainer Activity Check

    Hi @nickcoai!

    You're assigned to this SEP but there hasn't been any activity from you in 14 days.

    Please provide an update on:

    • Current status of your review/work
    • Any blockers or concerns
    • Expected timeline for next steps

    If you're no longer able to sponsor this SEP, please let us know so we can find another maintainer.


    This is an automated message from the SEP lifecycle bot.

  10. sep-automation-bot commented on Mar 9, 2026

    @sep-automation-bot

    Maintainer Activity Check

    Hi @nickcoai!

    You're assigned to this SEP but there hasn't been any activity from you in 20 days.

    Please provide an update on:

    • Current status of your review/work
    • Any blockers or concerns
    • Expected timeline for next steps

    If you're no longer able to sponsor this SEP, please let us know so we can find another maintainer.


    This is an automated message from the SEP lifecycle bot.

  11. sep-automation-bot commented on Mar 23, 2026

    @sep-automation-bot

    Maintainer Activity Check

    Hi @nickcoai!

    You're assigned to this SEP but there hasn't been any activity from you in 14 days.

    Please provide an update on:

    • Current status of your review/work
    • Any blockers or concerns
    • Expected timeline for next steps

    If you're no longer able to sponsor this SEP, please let us know so we can find another maintainer.


    This is an automated message from the SEP lifecycle bot.

  12. sep-automation-bot commented on Apr 6, 2026

    @sep-automation-bot

    Maintainer Activity Check

    Hi @nickcoai!

    You're assigned to this SEP but there hasn't been any activity from you in 14 days.

    Please provide an update on:

    • Current status of your review/work
    • Any blockers or concerns
    • Expected timeline for next steps

    If you're no longer able to sponsor this SEP, please let us know so we can find another maintainer.


    This is an automated message from the SEP lifecycle bot.

  13. sep-automation-bot commented on Apr 20, 2026

    @sep-automation-bot

    Maintainer Activity Check

    Hi @nickcoai!

    You're assigned to this SEP but there hasn't been any activity from you in 14 days.

    Please provide an update on:

    • Current status of your review/work
    • Any blockers or concerns
    • Expected timeline for next steps

    If you're no longer able to sponsor this SEP, please let us know so we can find another maintainer.


    This is an automated message from the SEP lifecycle bot.

  14. sep-automation-bot commented on May 4, 2026

    @sep-automation-bot

    Maintainer Activity Check

    Hi @nickcoai!

    You're assigned to this SEP but there hasn't been any activity from you in 14 days.

    Please provide an update on:

    • Current status of your review/work
    • Any blockers or concerns
    • Expected timeline for next steps

    If you're no longer able to sponsor this SEP, please let us know so we can find another maintainer.


    This is an automated message from the SEP lifecycle bot.

  15. sep-automation-bot commented on May 18, 2026

    @sep-automation-bot

    Maintainer Activity Check

    Hi @nickcoai!

    You're assigned to this SEP but there hasn't been any activity from you in 14 days.

    Please provide an update on:

    • Current status of your review/work
    • Any blockers or concerns
    • Expected timeline for next steps

    If you're no longer able to sponsor this SEP, please let us know so we can find another maintainer.


    This is an automated message from the SEP lifecycle bot.

  16. sep-automation-bot commented on Jun 1, 2026

    @sep-automation-bot

    Maintainer Activity Check

    Hi @nickcoai!

    You're assigned to this SEP but there hasn't been any activity from you in 14 days.

    Please provide an update on:

    • Current status of your review/work
    • Any blockers or concerns
    • Expected timeline for next steps

    If you're no longer able to sponsor this SEP, please let us know so we can find another maintainer.


    This is an automated message from the SEP lifecycle bot.

  17. sep-automation-bot commented on Jun 15, 2026

    @sep-automation-bot

    Maintainer Activity Check

    Hi @nickcoai!

    You're assigned to this SEP but there hasn't been any activity from you in 14 days.

    Please provide an update on:

    • Current status of your review/work
    • Any blockers or concerns
    • Expected timeline for next steps

    If you're no longer able to sponsor this SEP, please let us know so we can find another maintainer.


    This is an automated message from the SEP lifecycle bot.

  18. localden commented on Jun 26, 2026

    @localden
    Contributor

    Closing as #835 landed for step-up auth. Thank you for the contribution, @thiago-openai!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions