microsoft/aspire · error · McpProtocolException

InternalError

InternalError

Error message

{errorMessage: 'Failed to fetch structured logs: {ex.Message}' or dashboard API error message}

What it means

Thrown by ListStructuredLogsTool.CallToolAsync when the HTTP request to the Dashboard telemetry API fails with HttpRequestException. In direct-connection mode the error message is fetched from the dashboard API error helper; otherwise it becomes 'Failed to fetch structured logs: <ex.Message>'. Code is InternalError (-32603).

Solutions

  1. Verify the dashboard URL is reachable (curl the apiBaseUrl) and the AppHost is running.
  2. Restart the AppHost and retry so fresh dashboard URLs/token are obtained.
  3. Check proxy/firewall/DNS settings blocking the dashboard endpoint.
  4. Inspect the logged HttpRequestException ('Failed to fetch structured logs from Dashboard API') for the underlying socket/TLS error.
Defensive patterns

Strategy: retry

Validate before calling

// Verify the dashboard API endpoint answers before fetching logs
using var ping = await httpClient.GetAsync($"{apiBaseUrl}", HttpCompletionOption.ResponseHeadersRead, ct);
if (!ping.IsSuccessStatusCode) { /* refresh dashboard info or restart AppHost */ }

Try / catch

try
{
    await ListStructuredLogsAsync();
}
catch (McpProtocolException ex) when (ex.Message.StartsWith("Failed to fetch structured logs"))
{
    // Re-fetch dashboard info (URLs/token may be stale) and retry once
    await RefreshDashboardInfoAsync();
    await ListStructuredLogsAsync();
}

Prevention

When it happens

Trigger: The GET to the dashboard structured-logs endpoint throws HttpRequestException — dashboard not reachable, wrong apiBaseUrl, TLS failure, or the proxied (non-direct) connection dropped mid-request.

Common situations: Dashboard port changed or app restarted between discovery and the call; firewall/proxy blocking the dashboard URL; API token/endpoint stale after AppHost restart; container networking prevents reaching the dashboard base URL.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/e80c3490f1b7cdd6. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Cli/Mcp/Tools/ListStructuredLogsTool.cs:141

                {limitMessage}

                # STRUCTURED LOGS DATA

                {logsData}
                """;

            return new CallToolResult
            {
                Content = [new TextContentBlock { Text = text }]
            };
        }
        catch (HttpRequestException ex)
        {
            logger.LogError(ex, "Failed to fetch structured logs from Dashboard API");
            var errorMessage = dashboardInfoProvider.IsDirectConnection
                ? await TelemetryCommandHelpers.GetDashboardApiErrorMessageAsync(ex, apiBaseUrl, httpClientFactory, logger, cancellationToken)
                : $"Failed to fetch structured logs: {ex.Message}";
            throw new McpProtocolException(errorMessage, McpErrorCode.InternalError);
        }
    }
}

View on GitHub (pinned to 25830f84bd)