Support alternative package managers in MCP Inspector integration#1009
Support alternative package managers in MCP Inspector integration#1009aaronpowell merged 7 commits intomainfrom
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.
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, |
There was a problem hiding this comment.
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", "") |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
Call to obsolete method AddMcpInspector.
| var appBuilder = DistributedApplication.CreateBuilder(); | ||
|
|
||
| // Act | ||
| var inspector = appBuilder.AddMcpInspector("inspector") |
There was a problem hiding this comment.
Call to obsolete method AddMcpInspector.
| var appBuilder = DistributedApplication.CreateBuilder(); | ||
|
|
||
| // Act | ||
| var inspector = appBuilder.AddMcpInspector("inspector") |
| var appBuilder = DistributedApplication.CreateBuilder(); | ||
|
|
||
| // Act | ||
| var inspector = appBuilder.AddMcpInspector("inspector") |
| var inspector = appBuilder.AddMcpInspector("inspector", options => | ||
| { | ||
| options.InspectorVersion = "0.15.0"; | ||
| }) | ||
| .WithYarn(); |
| var inspector = appBuilder.AddMcpInspector("inspector", options => | ||
| { | ||
| options.InspectorVersion = "0.15.0"; | ||
| }) | ||
| .WithPnpm(); |
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.