Skip to content

Transfer the MCP Server project template from extensions to aspnetcore#66260

Merged
jeffhandley merged 9 commits intodotnet:mainfrom
jeffhandley:jeffhandley/mcpserver-aspnetcore
Apr 28, 2026
Merged

Transfer the MCP Server project template from extensions to aspnetcore#66260
jeffhandley merged 9 commits intodotnet:mainfrom
jeffhandley:jeffhandley/mcpserver-aspnetcore

Conversation

@jeffhandley
Copy link
Copy Markdown
Member

@jeffhandley jeffhandley commented Apr 10, 2026

The ultimate goal is to include the mcpserver project template in the .NET SDK. To accomplish this, we will:

  1. Move the template project from the dotnet/extensions repo into the aspnetcore repo
  2. Add the template to dotnet/sdk as an additional Bundled Template

The aspnetcore repo is a good fit for this because:

  1. The mcpserver template offers a "remote" transport option that uses ModelContextProtocol.AspNetCore and the ASP.NET Core ref pack
  2. The aspnetcore repo is already part of dependency flow into the SDK
  3. The aspnetcore repo is already part of the VMR (the extensions repo is not)
  4. The aspnetcore repo already includes other project templates that get added into the SDK as Bundled Templates
  5. There's good project template testing infrastructure to reuse

See also: Add Microsoft.McpServer.ProjectTemplates as BundledTemplate (dotnet/sdk#53802)

jeffhandley and others added 3 commits April 10, 2026 00:53
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>
@jeffhandley jeffhandley requested a review from baronfel April 10, 2026 08:37
@jeffhandley jeffhandley requested review from a team and wtgodbe as code owners April 10, 2026 08:37
Copilot AI review requested due to automatic review settings April 10, 2026 08:37
@github-actions github-actions Bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Apr 10, 2026
Copy link
Copy Markdown
Contributor

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 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.

Comment thread src/ProjectTemplates/test/Templates.Tests/McpServerTemplateTest.cs
Comment thread src/ProjectTemplates/test/Templates.Tests/McpServerTemplateTest.cs
Copy link
Copy Markdown
Member

@wtgodbe wtgodbe left a comment

Choose a reason for hiding this comment

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

LGTM modulo a few questions

Comment thread eng/Versions.props
…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>
jeffhandley and others added 3 commits April 26, 2026 23:21
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>
@SamMonoRT
Copy link
Copy Markdown
Member

@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?

@wtgodbe
Copy link
Copy Markdown
Member

wtgodbe commented Apr 28, 2026

/backport to release/11.0-preview4

@github-actions
Copy link
Copy Markdown
Contributor

Started backporting to release/11.0-preview4 (link to workflow run)

@github-actions
Copy link
Copy Markdown
Contributor

@wtgodbe backporting to release/11.0-preview4 failed, the patch most likely resulted in conflicts. Please backport manually!

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

Link to workflow output

@jeffhandley
Copy link
Copy Markdown
Member Author

/ba-g Unrelated test failure

@jeffhandley jeffhandley merged commit 6b63b0e into dotnet:main Apr 28, 2026
30 of 32 checks passed
@dotnet-policy-service dotnet-policy-service Bot added this to the 11.0-preview5 milestone Apr 28, 2026
@jeffhandley jeffhandley deleted the jeffhandley/mcpserver-aspnetcore branch April 28, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-templates pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants