{"record":{"id":"b27770badbb7c15c","repo":"microsoft/aspire","slug":"32603-no-aspire-apphost-is-currently-running-to-use-aspire","errorCode":"-32603","errorMessage":"No Aspire AppHost is currently running. To use Aspire MCP tools, you must first start an Aspire application by running 'aspire start' in your AppHost project directory. Once the application is running, the MCP tools will be able to connect to the dashboard and execute commands.","messagePattern":"No Aspire AppHost is currently running\\. To use Aspire MCP tools, you must first start an Aspire application by running 'aspire start' in your AppHost project directory\\. Once the application is running, the MCP tools will be able to connect to the dashboard and execute commands\\.","errorType":"error_code","errorClass":"McpProtocolException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Cli/Mcp/Tools/McpToolHelpers.cs","lineNumber":24,"sourceCode":"using System.Web;\nusing Aspire.Cli.Backchannel;\nusing Aspire.Dashboard.Model;\nusing Microsoft.Extensions.Logging;\nusing Microsoft.Extensions.Logging.Abstractions;\nusing ModelContextProtocol;\nusing ModelContextProtocol.Protocol;\n\nnamespace Aspire.Cli.Mcp.Tools;\n\ninternal static class McpToolHelpers\n{\n    public static async Task<(string apiToken, string apiBaseUrl, string? dashboardBaseUrl)> GetDashboardInfoAsync(IAuxiliaryBackchannelMonitor auxiliaryBackchannelMonitor, ILogger logger, CancellationToken cancellationToken)\n    {\n        var connection = await AppHostConnectionHelper.GetSelectedConnectionAsync(auxiliaryBackchannelMonitor, logger, cancellationToken).ConfigureAwait(false);\n        if (connection is null)\n        {\n            logger.LogWarning(\"No Aspire AppHost is currently running\");\n            throw new McpProtocolException(McpErrorMessages.NoAppHostRunning, McpErrorCode.InternalError);\n        }\n\n        var dashboardInfo = await connection.GetDashboardInfoV2Async(cancellationToken).ConfigureAwait(false);\n        if (dashboardInfo?.ApiBaseUrl is null || dashboardInfo.ApiToken is null)\n        {\n            logger.LogWarning(\"Dashboard API is not available\");\n            throw new McpProtocolException(McpErrorMessages.DashboardNotAvailable, McpErrorCode.InternalError);\n        }\n\n        var apiBaseUrl = NormalizeDashboardUrl(dashboardInfo.ApiBaseUrl);\n        var dashboardBaseUrl = StripLoginPath(dashboardInfo.DashboardUrls.FirstOrDefault());\n\n        return (dashboardInfo.ApiToken, apiBaseUrl, dashboardBaseUrl);\n    }\n\n    /// <summary>\n    /// Strips the <c>/login</c> path segment (and any query string) from a dashboard URL\n    /// returned by the AppHost. Other path segments are preserved.","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Cli/Mcp/Tools/McpToolHelpers.cs#L6-L42","documentation":"Thrown by McpToolHelpers.GetDashboardInfoAsync when no live AppHost connection is available (GetSelectedConnectionAsync returned null); the shared McpErrorMessages.NoAppHostRunning message is thrown as McpProtocolException with McpErrorCode.InternalError (-32603). This helper backs the telemetry tools' dashboard API discovery.","triggerScenarios":"Any telemetry MCP tool that calls GetDashboardInfoAsync running without an active 'aspire start' session, after the AppHost exited, or with no backchannel connection selected in the monitor.","commonSituations":"MCP client started before the app; AppHost crashed or was stopped; session/environment mismatch (different directory, user, or machine); connection dropped and never re-established.","solutions":["Run 'aspire start' in the AppHost project directory, then retry the tool call.","Confirm the AppHost process is alive and restart it if needed.","Reconnect the CLI session so the auxiliary backchannel monitor selects a connection.","Ensure the MCP client and AppHost share the same environment/session."],"exampleFix":"// before: assume dashboard info always available\nvar (token, baseUrl, _) = await McpToolHelpers.GetDashboardInfoAsync(monitor, logger, ct);\n// after: pre-check connection and start app if missing\nif (await AppHostConnectionHelper.GetSelectedConnectionAsync(monitor, logger, ct) is null)\n{\n    throw new InvalidOperationException(\"Start the AppHost with 'aspire start' before calling telemetry tools.\");\n}\nvar (token, baseUrl, _) = await McpToolHelpers.GetDashboardInfoAsync(monitor, logger, ct);","handlingStrategy":"try-catch","validationCode":"var connection = await AppHostConnectionHelper.GetSelectedConnectionAsync(monitor, logger, ct);\nif (connection is null)\n{\n    // AppHost not running: require 'aspire start' before dashboard info can be resolved\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var (token, baseUrl, dashboardUrl) = await McpToolHelpers.GetDashboardInfoAsync(monitor, logger, ct);\n}\ncatch (McpProtocolException ex) when (ex.Message.Contains(\"No Aspire AppHost is currently running\"))\n{\n    // Guide the user to run 'aspire start' in the AppHost project directory\n}","preventionTips":["Ensure 'aspire start' is active before calling any telemetry MCP tool.","Detect AppHost shutdown events and re-gate tool availability.","Keep the MCP client and AppHost in the same project directory and session.","Reconnect the auxiliary backchannel after AppHost restarts."],"tags":["mcp","apphost","connection","telemetry","aspire-cli"],"backgroundTag":"no-apphost-running","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}