MCPcopy Index your code
hub / github.com/modelcontextprotocol/python-sdk / elicit_url

Method elicit_url

src/mcp/server/mcpserver/context.py:151–184  ·  view source on GitHub ↗

Request URL mode elicitation from the client. This directs the user to an external URL for out-of-band interactions that must not pass through the MCP client. Use this for: - Collecting sensitive credentials (API keys, passwords) - OAuth authorization flows with thir

(
        self,
        message: str,
        url: str,
        elicitation_id: str,
    )

Source from the content-addressed store, hash-verified

149 )
150
151 async def elicit_url(
152 self,
153 message: str,
154 url: str,
155 elicitation_id: str,
156 ) -> UrlElicitationResult:
157 """Request URL mode elicitation from the client.
158
159 This directs the user to an external URL for out-of-band interactions
160 that must not pass through the MCP client. Use this for:
161 - Collecting sensitive credentials (API keys, passwords)
162 - OAuth authorization flows with third-party services
163 - Payment and subscription flows
164 - Any interaction where data should not pass through the LLM context
165
166 The response indicates whether the user consented to navigate to the URL.
167 The actual interaction happens out-of-band. When the elicitation completes,
168 call `ctx.session.send_elicit_complete(elicitation_id)` to notify the client.
169
170 Args:
171 message: Human-readable explanation of why the interaction is needed
172 url: The URL the user should navigate to
173 elicitation_id: Unique identifier for tracking this elicitation
174
175 Returns:
176 UrlElicitationResult indicating accept, decline, or cancel
177 """
178 return await elicit_url(
179 session=self.request_context.session,
180 message=message,
181 url=url,
182 elicitation_id=elicitation_id,
183 related_request_id=self.request_id,
184 )
185
186 @deprecated("The logging capability is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
187 async def log(

Callers

nothing calls this directly

Calls 1

elicit_urlFunction · 0.90

Tested by

no test coverage detected