Skip to content

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

Open
jeffhandley wants to merge 3 commits intodotnet:mainfrom
jeffhandley:jeffhandley/mcpserver-aspnetcore
Open

Transfer the MCP Server project template from extensions to aspnetcore#66260
jeffhandley wants to merge 3 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 on lines +117 to +122
using (var aspNetProcess = project.StartPublishedProjectAsync(hasListeningUri: false, usePublishedAppHost: nativeAot))
{
Assert.False(
aspNetProcess.Process.HasExited,
ErrorMessages.GetFailedProcessMessageOrEmpty("Run published project", project, aspNetProcess.Process));
}
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

The template defaults to self-contained + single-file publish, but this test only uses usePublishedAppHost when nativeAot is enabled. That means the default self-contained publish path is being executed via dotnet exec <dll> instead of the app host, so we’re not actually validating that the published single-file/self-contained output runs. Consider setting usePublishedAppHost based on whether the template publish is self-contained (in addition to native AOT).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Comment on lines +133 to +138
using (var aspNetProcess = project.StartPublishedProjectAsync(hasListeningUri: true, usePublishedAppHost: nativeAot))
{
Assert.False(
aspNetProcess.Process.HasExited,
ErrorMessages.GetFailedProcessMessageOrEmpty("Run published project", project, aspNetProcess.Process));
}
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

Same as above: the remote transport path publishes self-contained by default, but the published run uses usePublishedAppHost: nativeAot only. Running the published app via the app host when self-contained would better validate the template’s default publish configuration (self-contained/single-file).

Copilot uses AI. Check for mistakes.
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants