-
Notifications
You must be signed in to change notification settings - Fork 154
Support alternative package managers in MCP Inspector integration #1009
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
Support alternative package managers in MCP Inspector integration #1009
Conversation
Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
|
@copilot this doesn't really fit with the API design of Aspire, instead refer to https://aspire.dev/whats-new/aspire-13/#package-manager-flexibility on how JavaScript apps can work with different package managers and adapt to that |
…thYarn() and .WithPnpm() methods Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
Refactored in commit 3915676 to follow the Aspire API design pattern. Users can now chain var inspector = builder.AddMcpInspector("inspector")
.WithYarn()
.WithMcpServer(mcpServer);This is consistent with how other JavaScript resources work in Aspire. The implementation uses the SDK's |
…re time to setup stuff on CI
Minimum allowed line rate is |
There was a problem hiding this 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 adds support for alternative JavaScript package managers (yarn and pnpm) to the MCP Inspector integration, addressing issue #1008. The implementation follows a simpler approach than the Nx/Turborepo pattern by directly manipulating the command and arguments rather than using package manager annotations, which is appropriate given that MCP Inspector is a leaf resource without child apps.
Key Changes:
- Added
WithYarn()andWithPnpm()extension methods for configuring package manager - Modified
McpInspectorResourceto store package name for dynamic argument configuration - Updated argument generation logic to use
dlxfor yarn/pnpm and-yfor npm/npx - Added comprehensive test coverage for new package manager functionality
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| src/CommunityToolkit.Aspire.Hosting.McpInspector/McpInspectorResource.cs | Added packageName constructor parameter to support dynamic command configuration; property stores npm package name |
| src/CommunityToolkit.Aspire.Hosting.McpInspector/McpInspectorResourceBuilderExtensions.cs | Added WithYarn() and WithPnpm() methods; refactored to use WithInspectorArgs for dynamic argument generation based on package manager |
| tests/CommunityToolkit.Aspire.Hosting.McpInspector.Tests/McpInspectorResourceBuilderExtensionsTests.cs | Added 6 new tests covering package manager command setup and argument generation for npm, yarn, and pnpm |
| src/CommunityToolkit.Aspire.Hosting.McpInspector/README.md | Added documentation section explaining alternative package manager usage with code examples; fixed typo in ClientPort default value |
| .devcontainer/devcontainer.json | Configured node feature to disable yarn installation via apt |
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
| "ghcr.io/devcontainers/features/docker-in-docker:2": {}, | ||
| "ghcr.io/devcontainers/features/node:latest": {}, | ||
| "ghcr.io/devcontainers/features/node:latest": { | ||
| "installYarnUsingApt": false, |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing comma after false should be removed. JSON doesn't allow trailing commas in object properties.
| "installYarnUsingApt": false, | |
| "installYarnUsingApt": false |
| /// <param name="name">The name of the resource.</param> | ||
| public class McpInspectorResource(string name) : JavaScriptAppResource(name, "npx", "") | ||
| /// <param name="packageName">The npm package name for the MCP Inspector.</param> | ||
| public class McpInspectorResource(string name, string packageName) : JavaScriptAppResource(name, "npx", "") |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a required packageName parameter to the constructor is a breaking change for anyone directly instantiating McpInspectorResource. Consider making the parameter optional with a default value (e.g., string packageName = "@modelcontextprotocol/inspector@" + InspectorVersion) or providing a constructor overload to maintain backward compatibility.
| public class McpInspectorResource(string name, string packageName) : JavaScriptAppResource(name, "npx", "") | |
| public class McpInspectorResource(string name, string packageName = "@modelcontextprotocol/inspector@" + InspectorVersion) : JavaScriptAppResource(name, "npx", "") |
| var appBuilder = DistributedApplication.CreateBuilder(); | ||
|
|
||
| // Act | ||
| var inspector = appBuilder.AddMcpInspector("inspector"); |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call to obsolete method AddMcpInspector.
| var inspector = appBuilder.AddMcpInspector("inspector"); | |
| var inspector = appBuilder.AddMcpInspectorResource("inspector"); |
| var appBuilder = DistributedApplication.CreateBuilder(); | ||
|
|
||
| // Act | ||
| var inspector = appBuilder.AddMcpInspector("inspector") |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call to obsolete method AddMcpInspector.
| var appBuilder = DistributedApplication.CreateBuilder(); | ||
|
|
||
| // Act | ||
| var inspector = appBuilder.AddMcpInspector("inspector") |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call to obsolete method AddMcpInspector.
| var appBuilder = DistributedApplication.CreateBuilder(); | ||
|
|
||
| // Act | ||
| var inspector = appBuilder.AddMcpInspector("inspector") |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assignment to inspector is useless, since its value is never read.
| var inspector = appBuilder.AddMcpInspector("inspector") | |
| appBuilder.AddMcpInspector("inspector") |
| var appBuilder = DistributedApplication.CreateBuilder(); | ||
|
|
||
| // Act | ||
| var inspector = appBuilder.AddMcpInspector("inspector") |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assignment to inspector is useless, since its value is never read.
| var inspector = appBuilder.AddMcpInspector("inspector") | |
| appBuilder.AddMcpInspector("inspector") |
| var inspector = appBuilder.AddMcpInspector("inspector", options => | ||
| { | ||
| options.InspectorVersion = "0.15.0"; | ||
| }) | ||
| .WithYarn(); |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assignment to inspector is useless, since its value is never read.
| var inspector = appBuilder.AddMcpInspector("inspector", options => | ||
| { | ||
| options.InspectorVersion = "0.15.0"; | ||
| }) | ||
| .WithPnpm(); |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assignment to inspector is useless, since its value is never read.
| var inspector = appBuilder.AddMcpInspector("inspector", options => | ||
| { | ||
| options.InspectorVersion = "0.15.0"; | ||
| }); |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assignment to inspector is useless, since its value is never read.
Closes #1008
MCP Inspector hardcodes
npxfor running the inspector. This PR adds support forpnpm dlxandyarn dlxvia.WithYarn()and.WithPnpm()extension methods, consistent with how other JavaScript integrations in Aspire handle package manager selection.Changes
McpInspectorResource: Updated to store package name for runtime argument configurationMcpInspectorResourceBuilderExtensions:WithInspectorArgsto dynamically set args based on package manager annotation (dlxfor yarn/pnpm,-yfor npm)WithYarn()andWithPnpm()extension methods that configure the package manager and commandUsage
PR Checklist
Other information
.WithYarn()and.WithPnpm()methods.WithYarn()or.WithPnpm()after creating the resource, consistent with how other JavaScript resources work in AspireOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.