microsoft/aspire · error · McpProtocolException

InternalError

InternalError

Error message

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

What it means

Thrown by ListTracesTool.CallToolAsync when the HTTP request to the dashboard traces endpoint fails with HttpRequestException. In direct mode the dashboard API's error message is surfaced; otherwise 'Failed to fetch traces: <ex.Message>'. Code InternalError (-32603).

Solutions

  1. Verify the AppHost/dashboard is running and the apiBaseUrl responds (e.g. curl).
  2. Restart the AppHost and retry to obtain fresh dashboard URLs and token.
  3. Check proxy/firewall/DNS configuration for the dashboard endpoint.
  4. Inspect the CLI log line 'Failed to fetch traces from Dashboard API' for the underlying exception detail.
Defensive patterns

Strategy: retry

Validate before calling

// Health-check the dashboard API before listing traces
using var probe = await httpClient.GetAsync(apiBaseUrl, HttpCompletionOption.ResponseHeadersRead, ct);
if (!probe.IsSuccessStatusCode) { /* refresh dashboard info first */ }

Try / catch

try
{
    await ListTracesAsync();
}
catch (McpProtocolException ex) when (ex.Message.StartsWith("Failed to fetch traces"))
{
    // Refresh dashboard URLs/token (stale after restart) and retry once
    await RefreshDashboardInfoAsync();
    await ListTracesAsync();
}

Prevention

When it happens

Trigger: Calling the list-traces MCP tool while the dashboard API is unreachable, the apiBaseUrl/token are stale, or the non-direct (proxied) connection throws HttpRequestException.

Common situations: Dashboard stopped or port reassigned; stale connection info after AppHost restart; corporate proxy blocking the telemetry endpoint; Docker/network isolation preventing localhost dashboard access.

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/6b0425f8b06dc2f9. Report an issue: GitHub.

Appendix: source

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

                {limitMessage}

                # TRACES DATA

                {tracesData}
                """;

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

View on GitHub (pinned to 25830f84bd)