Transfer the MCP Server project template from extensions to aspnetcore#66260
Transfer the MCP Server project template from extensions to aspnetcore#66260jeffhandley wants to merge 8 commits intodotnet:mainfrom
Conversation
Port the mcpserver template from dotnet/extensions into dotnet/aspnetcore as a new Microsoft.McpServer.ProjectTemplates template package. - Create McpServer.ProjectTemplates/ with template content (local/remote transports) - Add .csproj-in files with version placeholders for GenerateContent.targets - Add ModelContextProtocol/ModelContextProtocol.AspNetCore version tracking - Add McpServerTemplateTest covering local/remote, self-contained, and AOT flavors - Wire into AspNetCore.slnx and ProjectTemplates.slnf Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace modelcontextprotocol.github.io/csharp-sdk with csharp.sdk.modelcontextprotocol.io/ in both local and remote transport README templates. Remove references to the template and MCP Server usage being preview. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Split parameterized theories into individual ConditionalFact methods - Replace stale global AOT skip with SkipOnHelix for specific queues - Add template-baselines.json entries for local and remote transport - Add VerifyLaunchSettings for remote transport - Add run verification for remote transport (built + published) - Default args parameter to null in core method - Add skipRestore symbol and --no-restore CLI mapping to template config - Add NuGet restore post-action to template - Register McpServer.ProjectTemplates in TemplatePackageInstaller - Add .gitignore for generated .csproj files Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR brings the mcpserver project template into the aspnetcore repo so it can participate in the existing template-pack build/test infrastructure and dependency flow toward eventually bundling it in the .NET SDK.
Changes:
- Adds a new template pack project (
Microsoft.McpServer.ProjectTemplates) containing local (stdio) and remote (HTTP) MCP server template variants. - Wires the new template into the ProjectTemplates solution(s) and template test infrastructure (baselines + new E2E test).
- Introduces version plumbing for ModelContextProtocol packages and updates build exclusions for generated template project files.
Reviewed changes
Copilot reviewed 26 out of 27 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ProjectTemplates/test/Templates.Tests/Templates.Tests.csproj | Adds content + project reference so template tests can access/build the new template pack. |
| src/ProjectTemplates/test/Templates.Tests/template-baselines.json | Adds baselines for mcpserver local/remote variants. |
| src/ProjectTemplates/test/Templates.Tests/McpServerTemplateTest.cs | Adds E2E coverage for creating/publishing/running the new template variants (including AOT scenarios). |
| src/ProjectTemplates/Shared/TemplatePackageInstaller.cs | Includes the new template pack in the list of template packages installed for tests and updates expected package count. |
| src/ProjectTemplates/ProjectTemplates.slnf | Includes the new template pack project in the ProjectTemplates solution filter. |
| src/ProjectTemplates/McpServer.ProjectTemplates/Microsoft.McpServer.ProjectTemplates.csproj | New template pack project that generates the variant-specific .csproj files from .csproj.in inputs. |
| src/ProjectTemplates/McpServer.ProjectTemplates/*.csproj.in | Defines generated project files for local/remote template variants with optional self-contained / AOT publishing settings. |
| src/ProjectTemplates/McpServer.ProjectTemplates/content/** | Adds the actual template content (template.json, host configs, README/Program files, launchSettings/http file, tool sample, icon). |
| src/ProjectTemplates/McpServer.ProjectTemplates/.gitignore | Ignores generated project files emitted during template-pack build. |
| eng/Versions.props | Adds ModelContextProtocol package version properties used during template content generation. |
| eng/Dependencies.props | Adds ModelContextProtocol packages to latest-package tracking. |
| eng/Build.props | Excludes generated template project files under the new template pack from general repo globbing. |
| AspNetCore.slnx | Adds the new template pack project to the main solution. |
| "AI", | ||
| "MCP" | ||
| ], | ||
| "identity": "Microsoft.McpServer.ProjectTemplates.McpServer.CSharp", |
There was a problem hiding this comment.
How does this template handle precedence? We usually have a value that we update w/ every major version so that the net12.0 version will take precedence over the net11.0 version, etc:
There was a problem hiding this comment.
Oh, nice; thanks. Here's what would be fantastic but I don't know if it can be achieved. Can you advise?
net12.0version takes precedence overnet11.0versionnet11.0version takes precedence overnet10.0version
- The intent is to get this into the May servicing release of the SDK again
net10.0
net10.0version takes precedence over the OOB Microsoft.McpServer.ProjectTemplates package- However, if needed, have the ability to release an updated OOB Microsoft.McpServer.ProjectTemplates package that could take precedence over the SDK versions, with the ability to then bump the precedence in the subsequent SDK update that includes that version, for the SDK versions to take precedence again.
There was a problem hiding this comment.
I'm not sure how that would work - someone from dotnet/templating might know more about the specifics
There was a problem hiding this comment.
I'm not going to block on that ideal behavior. But I added the precedence and I also found that I needed to suffix the package name with the version number (.11.0) like the other templates do.
There was a problem hiding this comment.
I believe precedence is still missing
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
…le RID before restore Add preRestoreAction callback to Project.RunDotNetNewAsync to allow template tests to modify the generated csproj between template creation and restore. MCP Server self-contained tests use this to replace the 6-RID RuntimeIdentifiers with a single RuntimeIdentifier matching the current platform, avoiding NU1102 restore failures in CI where runtime packages for all RIDs are unavailable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Self-contained template restore requires RID-specific runtime packages at version 11.0.0-ci which are unavailable on CI feeds. The single-RID replacement approach didn't fix this since even one RID still needs the unavailable package. Instead, skip default (self-contained) tests on Helix and rely on the --self-contained false variants for CI coverage. Reverts the preRestoreAction parameter added to RunDotNetNewAsync since it is no longer needed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
NativeAOT implies SelfContained in the template, hitting the same NU1102 runtime package resolution failure as the default self-contained tests. Remove the queue filter so NativeAOT tests skip on all Helix queues, not just NativeAotNotSupportedHelixQueues. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The ultimate goal is to include the
mcpserverproject template in the .NET SDK. To accomplish this, we will:The aspnetcore repo is a good fit for this because:
mcpservertemplate offers a "remote" transport option that uses ModelContextProtocol.AspNetCore and the ASP.NET Core ref packSee also: Add Microsoft.McpServer.ProjectTemplates as BundledTemplate (dotnet/sdk#53802)