Skip to content

Fix MCP Inspector auto-opening browser when using aspire run #789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 7, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 6, 2025

The MCP Inspector integration was automatically opening a browser when running aspire run due to the MCP_AUTO_OPEN_ENABLED environment variable defaulting to true in the underlying npm package.

This change adds the environment variable MCP_AUTO_OPEN_ENABLED=false to the MCP Inspector resource configuration to prevent automatic browser opening during development workflows.

Changes Made

  • Added .WithEnvironment("MCP_AUTO_OPEN_ENABLED", "false") to the AddMcpInspector method in McpInspectorResourceBuilderExtensions.cs
  • Added test validation to ensure the environment variable is correctly set
  • Added required using statement for Aspire.Hosting.ApplicationModel

Testing

The existing test AddMcpInspectorWithDefaultsAddsResource has been enhanced to verify that the MCP_AUTO_OPEN_ENABLED environment variable is properly set to "false".

Fixes #788.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dnceng.pkgs.visualstudio.com
    • Triggering command: dotnet build src/CommunityToolkit.Aspire.Hosting.McpInspector/ (dns block)
    • Triggering command: dotnet test tests/CommunityToolkit.Aspire.Hosting.McpInspector.Tests/ --verbosity normal (dns block)
    • Triggering command: dotnet workload install aspire (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] MCP Inspector auto-opens browser with aspire run Fix MCP Inspector auto-opening browser when using aspire run Aug 6, 2025
@Copilot Copilot AI requested a review from aaronpowell August 6, 2025 02:47
Copilot finished work on behalf of aaronpowell August 6, 2025 02:47
@aaronpowell aaronpowell marked this pull request as ready for review August 6, 2025 03:10
@Copilot Copilot AI review requested due to automatic review settings August 6, 2025 03:10
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where the MCP Inspector integration was automatically opening a browser during aspire run due to the underlying npm package's default behavior. The solution adds an environment variable to disable this auto-opening functionality.

  • Adds MCP_AUTO_OPEN_ENABLED=false environment variable to prevent automatic browser opening
  • Enhances existing test to validate the environment variable is properly configured
  • Adds required using statement for test validation

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/CommunityToolkit.Aspire.Hosting.McpInspector/McpInspectorResourceBuilderExtensions.cs Adds environment variable to disable auto-opening browser
tests/CommunityToolkit.Aspire.Hosting.McpInspector.Tests/McpInspectorResourceBuilderExtensionsTests.cs Adds test validation and required using statement
Comments suppressed due to low confidence (1)

tests/CommunityToolkit.Aspire.Hosting.McpInspector.Tests/McpInspectorResourceBuilderExtensionsTests.cs:35

  • The variable inspectorResource is not defined in this scope. It should be inspector.Resource to match the existing pattern in the test.
        var envAnnotations = inspectorResource.Annotations.OfType<EnvironmentVariableAnnotation>();

Copy link
Contributor

github-actions bot commented Aug 7, 2025

Code Coverage

Package Line Rate Branch Rate Complexity Health
CommunityToolkit.Aspire.EventStore 100% 100% 46
CommunityToolkit.Aspire.GoFeatureFlag 100% 97% 74
CommunityToolkit.Aspire.Hosting.ActiveMQ 79% 40% 100
CommunityToolkit.Aspire.Hosting.ActiveMQ.MassTransit 1% 0% 14
CommunityToolkit.Aspire.Hosting.Adminer 73% 50% 20
CommunityToolkit.Aspire.Hosting.Azure.Dapr 66% 50% 832
CommunityToolkit.Aspire.Hosting.Azure.Dapr.Redis 97% 88% 36
CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder 100% 100% 22
CommunityToolkit.Aspire.Hosting.Bun 82% 71% 54
CommunityToolkit.Aspire.Hosting.Dapr 62% 51% 728
CommunityToolkit.Aspire.Hosting.DbGate 94% 50% 18
CommunityToolkit.Aspire.Hosting.Deno 84% 75% 72
CommunityToolkit.Aspire.Hosting.EventStore 94% 100% 18
CommunityToolkit.Aspire.Hosting.GoFeatureFlag 93% 50% 18
CommunityToolkit.Aspire.Hosting.Golang 87% 70% 28
CommunityToolkit.Aspire.Hosting.Java 69% 72% 120
CommunityToolkit.Aspire.Hosting.k6 58% 12% 20
CommunityToolkit.Aspire.Hosting.LavinMQ 78% 50% 18
CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit 1% 0% 14
CommunityToolkit.Aspire.Hosting.MailPit 91% 50% 14
CommunityToolkit.Aspire.Hosting.McpInspector 91% 48% 98
CommunityToolkit.Aspire.Hosting.Meilisearch 73% 57% 50
CommunityToolkit.Aspire.Hosting.Minio 93% 75% 48
CommunityToolkit.Aspire.Hosting.MongoDB.Extensions 96% 83% 36
CommunityToolkit.Aspire.Hosting.MySql.Extensions 100% 88% 78
CommunityToolkit.Aspire.Hosting.Ngrok 52% 35% 82
CommunityToolkit.Aspire.Hosting.NodeJS.Extensions 47% 52% 136
CommunityToolkit.Aspire.Hosting.Ollama 67% 70% 174
CommunityToolkit.Aspire.Hosting.PapercutSmtp 92% 50% 10
CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions 99% 89% 84
CommunityToolkit.Aspire.Hosting.Python.Extensions 68% 55% 90
CommunityToolkit.Aspire.Hosting.RavenDB 63% 49% 136
CommunityToolkit.Aspire.Hosting.Redis.Extensions 100% 71% 48
CommunityToolkit.Aspire.Hosting.Rust 94% 83% 16
CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects 76% 64% 154
CommunityToolkit.Aspire.Hosting.Sqlite 99% 89% 42
CommunityToolkit.Aspire.Hosting.SqlServer.Extensions 100% 87% 78
CommunityToolkit.Aspire.Hosting.SurrealDb 71% 54% 152
CommunityToolkit.Aspire.MassTransit.RabbitMQ 100% 100% 30
CommunityToolkit.Aspire.Meilisearch 97% 92% 68
CommunityToolkit.Aspire.Microsoft.Data.Sqlite 89% 85% 52
CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite 50% 50% 88
CommunityToolkit.Aspire.Minio.Client 73% 59% 88
CommunityToolkit.Aspire.OllamaSharp 74% 69% 120
CommunityToolkit.Aspire.RavenDB.Client 60% 53% 237
CommunityToolkit.Aspire.SurrealDb 96% 90% 56
Summary 72% (7237 / 10091) 60% (2251 / 3774) 4517

Minimum allowed line rate is 60%

@aaronpowell aaronpowell merged commit 17828ee into main Aug 7, 2025
99 of 100 checks passed
@aaronpowell aaronpowell deleted the copilot/fix-788 branch August 7, 2025 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MCP Inspector auto-opens browser with aspire run
2 participants