Transfer the MCP Server project template from extensions to aspnetcore#66260
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. |
…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>
|
@wtgodbe @jeffhandley --- this needs to be backported to the Preview 4 branch --- given a tight deadline to get this in prior to code complete later today -- should we backport/ open a PR in Preview 4 branch also and watch CI runs? |
|
/backport to release/11.0-preview4 |
|
Started backporting to |
|
@wtgodbe backporting to git am output$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Add McpServer project template package
Using index info to reconstruct a base tree...
M AspNetCore.slnx
M eng/Dependencies.props
M eng/Versions.props
Falling back to patching base and 3-way merge...
Auto-merging AspNetCore.slnx
Auto-merging eng/Dependencies.props
Auto-merging eng/Versions.props
Applying: Update MCP Server docs link and preview references
Applying: Align McpServerTemplateTest with aspnetcore test patterns
Using index info to reconstruct a base tree...
M src/ProjectTemplates/test/Templates.Tests/template-baselines.json
Falling back to patching base and 3-way merge...
Auto-merging src/ProjectTemplates/test/Templates.Tests/template-baselines.json
CONFLICT (content): Merge conflict in src/ProjectTemplates/test/Templates.Tests/template-baselines.json
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0003 Align McpServerTemplateTest with aspnetcore test patterns
Error: The process '/usr/bin/git' failed with exit code 128 |
|
/ba-g Unrelated test failure |
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)