Skip to content

Conversation

joelverhagen
Copy link
Member

@joelverhagen joelverhagen commented Jun 26, 2025

This addresses #6518.

The conventions we're pushing for on NuGet are:

  1. PackAsTool
  2. McpServer package type (in addition to the default DotnetTool)
  3. Embed server.json (docs)
Commands I use to test locally
# build + install
.\build.cmd -pack -projects .\src\ProjectTemplates\Microsoft.Extensions.AI.Templates\Microsoft.Extensions.AI.Templates.csproj
dotnet new uninstall Microsoft.Extensions.AI.Templates
dotnet new install Microsoft.Extensions.AI.Templates::9.7.0-dev --add-source Q:\src\dotnet-extensions\artifacts\packages\Debug\Shipping

# clear test directory and run template
gci Q:\trash\2025-06-25\template-try-2\* -Recurse | Remove-Item -Force -Recurse -Confirm:$false
dotnet new mcpserver
dotnet build
dotnet pack

TODO (for me, before merge):

TODO (for me, after merge):

Open question (for repo owners/reviewers):

  • How do we ship this template?
    • Answer: as part of the existing AI templates with the chat template
  • How can this template be marked as "preview"?
    • Answer: it will be part of the Preview 6 release and have the associated marker
  • How do we keep the Hosting and MCP SDK dependency fresh?
    • We will assess during Preview 7 timeframe (follow-up PR?)

Screenshots:

VS IDE - light mode:
image

VS IDE - dark mode:
image

Microsoft Reviewers: Open in CodeFlow

@github-actions github-actions bot added the area-ai-templates Microsoft.Extensions.AI.Templates label Jun 26, 2025
Test commands:

BUILD + INSTALL
.\build.cmd -pack -projects .\src\ProjectTemplates\Microsoft.Extensions.AI.Templates\Microsoft.Extensions.AI.Templates.csproj; dotnet new uninstall Microsoft.Extensions.AI.Templates; dotnet new install Microsoft.Extensions.AI.Templates::9.7.0-dev --add-source Q:\src\dotnet-extensions\artifacts\packages\Debug\Shipping

IN A NEW DIR + TEST TEMPLATE:
gci Q:\trash\2025-06-25\template-try-2\* -Recurse | Remove-Item -Force -Recurse -Confirm:$false; dotnet new mcpserver; dotnet build; dotnet pack
joelverhagen and others added 8 commits June 26, 2025 16:50
…Server/McpServer-CSharp/Program.cs

Co-authored-by: Stephen Toub <[email protected]>
…Server/McpServer-CSharp/Program.cs

Co-authored-by: Stephen Toub <[email protected]>
…Server/McpServer-CSharp/Program.cs

Co-authored-by: Stephen Toub <[email protected]>
…Server/McpServer-CSharp/Program.cs

Co-authored-by: Stephen Toub <[email protected]>
…Server/McpServer-CSharp/McpServer-CSharp.csproj.in

Co-authored-by: Stephen Toub <[email protected]>
…Server/McpServer-CSharp/Program.cs

Co-authored-by: Stephen Toub <[email protected]>
@timheuer
Copy link
Member

I had created my own as I've been iterating on a few things https://github.com/timheuer/dotnet-mcp-server -- I think we should organize like the samples (Tools, etc.) rather than everything in Program.cs. Mine has some options to use http transport as well, arguable if that's needed in a v1, but easy to do.

@joelverhagen
Copy link
Member Author

I had created my own as I've been iterating on a few things https://github.com/timheuer/dotnet-mcp-server -- I think we should organize like the samples (Tools, etc.) rather than everything in Program.cs. Mine has some options to use http transport as well, arguable if that's needed in a v1, but easy to do.

I like the Program.cs since it's small and easy to wrap your head around. You can see without much code the whole thing work and have an idea of where to plug in your custom MCP logic. I agree mature organization (not to mention having resources, and prompts in addition to tools) are a good thing to cover somewhere.

Is there prior art for a "minimal" vs. "organized" template variants? Maybe we can call this one mcpserver-minimal or something and add a bigger one later?

I am trying to see if there's a lean thing we can release soon, and then layer improvements on after that. Preview 6 has everything we need for E2E (with dotnet tool exec) so I wanted something to ship at the same time or soon after Preview 6. Preview 7 or OOB could have more.

What do you think?

…Server/McpServer-CSharp/McpServer-CSharp.csproj.in
@timheuer
Copy link
Member

Maybe we can call this one mcpserver-minimal or something and add a bigger one later?

No, see my previous comment about templates -- we really should have one MCP template...if it doesn't match our samples, we should question which one is better and why. Templates should be our best practices as we codify them.

@joelverhagen joelverhagen changed the title [DRAFT] Create a project template for an MCP server Create a project template for an MCP server Jul 1, 2025
@joelverhagen joelverhagen marked this pull request as ready for review July 1, 2025 19:00
@joelverhagen joelverhagen requested a review from a team as a code owner July 1, 2025 19:00
@joelverhagen
Copy link
Member Author

@timheuer, @MackinnonBuck, @jeffhandley, @stephentoub - I believe this is ready for review!

Copy link
Member

@timheuer timheuer left a comment

Choose a reason for hiding this comment

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

made one suggestion to Joel in chat else looks good to me.

Copy link
Member

@MackinnonBuck MackinnonBuck left a comment

Choose a reason for hiding this comment

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

Looks great!

@joelverhagen joelverhagen merged commit c49b57b into main Jul 2, 2025
6 checks passed
@joelverhagen joelverhagen deleted the jver/mcp-template branch July 2, 2025 16:06
joperezr pushed a commit that referenced this pull request Jul 8, 2025
The conventions we're pushing for on NuGet are:

1. `PackAsTool`
2. `McpServer` package type (in addition to the default `DotnetTool`)
3. Embed server.json

This provides an `mcpserver` template as part of `Microsoft.Extensions.AI.Templates`. This currently only covers a local MCP server, with stdio transport.
@github-actions github-actions bot locked and limited conversation to collaborators Aug 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-ai-templates Microsoft.Extensions.AI.Templates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants