Replies: 3 comments 19 replies
-
With regards to this...
I don't think the meatadata should have the "auth url". If at all just point to the PRM endpoint. We don't want multiple discovery mechanism for auth in the spec. Just the scopes are enough IMO. We assume the client already knows how to authenticate and ask for extra scopes. |
Beta Was this translation helpful? Give feedback.
-
@ggoodman - check this out: https://docs.google.com/document/d/1460o7LRZPMDFxoDgdYTI4gdxjgdBMKDxnN5Ic1DGhng/edit?usp=sharing I've been working on it as it relates specifically to primitive authorization. I am a bit uneasy with baking in a bunch of I would also highly recommend cross-checking the proposal from @nbarbettini and @wdawson in #475. |
Beta Was this translation helpful? Give feedback.
-
Closing per @ggoodman (let me know if this was not your intent and I'll re-open):
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Pre-submission Checklist
Your Idea
This document describes an extension to the Model Context Protocol (MCP) to handle scenarios where an MCP Server requires certain conditions to be met before a tool call can be successfully processed. This mechanism is generalizable to various types of preconditions.
Warning
This proposal is being withdrawn to focus efforts on modelcontextprotocol/modelcontextprotocol#475 whose goals and capabilities align with this.
Important
Added 2 Jun 2025 Everything in this proposal is negotiable except for these two key ideas:
AuthorizationRequired
precondition) with the result of a tool call or other capability use. This lets the Host correlate the challenge with the failure.notifications/preconditions_met
. The original challenge MUST have a unique identifier so that the MCP Server can reference in the original unmet precondition with the later notification that it was fulfilled.These are the two novelties of this proposal that set it apart from ideas like Elicitation and modelcontextprotocol/modelcontextprotocol#45.
Extended Model Context Protocol Flow for Handling Preconditions
Introduction
This extension provides a generalizable mechanism for an MCP Server to signal to an MCP Host that a tool operation cannot be completed because certain preconditions are not met. It allows the MCP Server to describe these unmet preconditions. One common example, which will be used to illustrate the flow, is the
AuthorizationRequired
precondition, where the user might need to go through an OAuth2 authorization flow. Upon satisfaction of the precondition (e.g., successful authorization), the MCP Server notifies the MCP Host, which can then offer the user the option to retry the original tool call.Participants
AuthorizationRequired
example): The OAuth2 provider for the third-party service the MCP Server needs to access.Extended Protocol Elements
ToolCallResult
Extension:The standard
ToolCallResult
from an MCP Server is extended with an optional field:preconditions_failed
(array, optional): A list ofPrecondition
objects that were not met.Precondition
Object:Describes a single unmet precondition. It has a general structure:
type
(string): A string identifying the kind of precondition. Examples include"AuthorizationRequired"
,"PaymentRequired"
,"TermsOfServiceAgreementNeeded"
, etc.preconditionId
(string): A unique identifier for this specific precondition instance. This ID is used by the MCP Server to later notify the MCP Host that the precondition has been satisfied.metadata
(object): An object containing data specific to thetype
of precondition, providing information needed to resolve it.Example
Precondition
Type:AuthorizationRequired
This specific type indicates that the MCP Server needs the user to authorize it, typically via OAuth2.
type
: MUST be"AuthorizationRequired"
.preconditionId
: A unique identifier for this authorization request.metadata
: ForAuthorizationRequired
, this object would contain:authorizationUrl
(string): The URL the user should be directed to for initiating the OAuth2 authorization code flow (e.g.,https://auth.example.com/authorize?...
). This URL itself MUST encode all necessary OAuth2 parameters required by the Authorization Server, includingclient_id
,response_type=code
,scope
, the MCP Server'sredirect_uri
,state
, and PKCE parameters (code_challenge
,code_challenge_method
).requestedScopes
(array of strings, optional): A list of scopes the MCP Server is requesting. This can be useful for the MCP Host to display to the user, even if also encoded within theauthorizationUrl
.New Notification:
notifications/preconditions_satisfied
:A new notification sent by the MCP Server to the MCP Host.
method
:"notifications/preconditions_satisfied"
params
: (object)preconditionId
(string): The unique identifier of thePrecondition
(from thepreconditionId
field of the object in thepreconditions_failed
array) that has now been satisfied.Interaction Flow (Illustrated with
AuthorizationRequired
Precondition)The following steps describe the interaction, using the
AuthorizationRequired
precondition as an example:Tool Invocation: The MCP Host, on behalf of an authenticated user, invokes a tool on the MCP Server.
Precondition Check by Server: The MCP Server's tool handler logic determines that one or more preconditions are not met. In this example, it lacks the necessary user credentials for a third-party service.
Server Responds with
preconditions_failed
: The MCP Server returns aToolCallResult
. This result indicates the immediate tool call failed or cannot proceed and includes thepreconditions_failed
field. For this example, this field contains anAuthorizationRequired
object with a uniquepreconditionId
and theauthorizationUrl
.Example
ToolCallResult
snippet forAuthorizationRequired
:Host Prompts User: The MCP Host processes the
preconditions_failed
response. If it understands theAuthorizationRequired
type (or other precondition types), it presents an appropriate interface to the user. ForAuthorizationRequired
, it explains that authorization is needed and provides a link (using theauthorizationUrl
) to grant permissions to the MCP Server.User Authorizes (OAuth2 Flow for
AuthorizationRequired
example): The User clicks the link. This initiates the standard OAuth2 authorization code grant flow with PKCE:a. User is redirected to the Authorization Server's
authorizationUrl
.b. User authenticates and grants consent on the Authorization Server.
c. Authorization Server redirects the User back to the MCP Server's
redirect_uri
(which was encoded within theauthorizationUrl
) with an authorizationcode
.MCP Server Handles OAuth Callback (for
AuthorizationRequired
example): The MCP Server's callback handler:a. Receives the authorization
code
and retrieves the PKCEcode_verifier
.b. Exchanges the
code
andcode_verifier
for an Access Token (and optionally a Refresh Token) from the Authorization Server.c. Securely stores the obtained token(s), associating them with the user's MCP session or user identity on the MCP Server. This satisfies the
AuthorizationRequired
precondition.Server Notifies Host of Satisfaction: After the precondition is satisfied (e.g., successfully obtaining and storing credentials), the MCP Server sends a
notifications/preconditions_satisfied
message to the MCP Host. This notification includes thepreconditionId
from the originalPrecondition
object.Example
notifications/preconditions_satisfied
message:Host Offers Retry: The MCP Host receives this notification. If the context is still relevant and the Host is not otherwise busy with a conflicting operation, it may present the user with an option to retry the original tool call that previously encountered the unmet precondition.
User Opts to Retry, Host Re-invokes Tool: If the user chooses to retry, the MCP Host uses its MCP Client to invoke the same tool again on the MCP Server.
Server Completes Operation: The MCP Server now finds that the previously unmet precondition is satisfied (e.g., it has the necessary stored credentials). It successfully executes the tool's business logic.
Host Receives Successful Outcome: The MCP Server returns a successful
ToolCallResult
to the MCP Host, and the Host presents the outcome to the user.Note on Subsequent Calls: For the
AuthorizationRequired
example, subsequent tool calls from the same user that require the same third-party credentials can leverage this pre-existing delegation of authorization without repeating the OAuth2 flow, as long as the stored tokens are valid and cover the required scopes. Similar logic would apply to other types of satisfied preconditions.Sequence Diagram (Illustrating
AuthorizationRequired
Precondition Flow)Scope
Beta Was this translation helpful? Give feedback.
All reactions