Use this file to discover all available pages before exploring further.
Elicitation enables MCP servers to request additional information from users during tool execution. This is essential for interactive scenarios like OAuth authentication, payment processing, or collecting sensitive credentials.
URL mode is used for OAuth flows, payment processing, or when credentials must be entered on a trusted server page:
static async ValueTask<ElicitResult> HandleUrlElicitationAsync( ElicitRequestParams request, CancellationToken cancellationToken){ Console.WriteLine("\n" + request.Message); Console.WriteLine($"URL: {request.Url}"); Console.WriteLine($"Elicitation ID: {request.ElicitationId}"); Console.WriteLine(); // Show security warning Console.WriteLine("⚠️ Security Warning:"); Console.WriteLine("This will open a URL in your browser."); Console.WriteLine($"Please verify this is a trusted source: {new Uri(request.Url!).Host}"); Console.WriteLine(); // Get user consent Console.Write("Do you want to open this URL? (y/n): "); var consent = Console.ReadLine(); if (consent?.Trim().Equals("y", StringComparison.OrdinalIgnoreCase) == true) { // Open URL in browser Process.Start(new ProcessStartInfo(request.Url!) { UseShellExecute = true }); Console.WriteLine("\nWaiting for you to complete the interaction..."); Console.WriteLine("Press Enter when done."); Console.ReadLine(); return new ElicitResult { Action = "accept" }; } else { Console.WriteLine("User declined to open URL."); return new ElicitResult { Action = "decline" }; }}
static async ValueTask<ElicitResult> HandleFormElicitationAsync( ElicitRequestParams? request, CancellationToken cancellationToken){ if (request?.RequestedSchema?.Properties is null) { return new ElicitResult { Action = "reject" }; } Console.WriteLine(); Console.WriteLine(request.Message ?? "Please provide the following information:"); Console.WriteLine(); var content = new Dictionary<string, object?>(); foreach (var (name, schema) in request.RequestedSchema.Properties) { var description = schema.Description ?? name; Console.Write($"{description}: "); // Show default if available if (schema.Default is not null) { Console.Write($"[{schema.Default}] "); } var input = Console.ReadLine(); // Use default if input is empty if (string.IsNullOrWhiteSpace(input) && schema.Default is not null) { content[name] = schema.Default; } else if (!string.IsNullOrWhiteSpace(input)) { // Parse based on schema type content[name] = schema switch { ElicitRequestParams.NumberSchema => double.Parse(input), ElicitRequestParams.BooleanSchema => bool.Parse(input), _ => input }; } } return new ElicitResult { Action = "accept", Content = content };}
Servers can send completion notifications when URL interactions finish:
await using var handler = client.RegisterNotificationHandler( NotificationMethods.ElicitationCompleteNotification, async (notification, cancellationToken) => { var payload = notification.Params?.Deserialize< ElicitationCompleteNotificationParams >(McpJsonUtilities.DefaultOptions); if (payload is not null) { Console.WriteLine( $"Elicitation {payload.ElicitationId} completed!" ); // Signal that retry can proceed } });