Skip to content

Add quickstart for minimal MCP Server using .NET and publish to NuGet #47007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 34 commits into
base: main
Choose a base branch
from

Conversation

JonDouglas
Copy link
Contributor

@JonDouglas JonDouglas commented Jun 30, 2025

Summary

Adds a quickstart of creating a minimal MCP server with a predefined mcpserver template, consuming it locally, and publishing it to NuGet and consuming it from the package ID as well using dotnet tool exec.


Internal previews

📄 File 🔗 Preview link
docs/ai/quickstarts/build-mcp-server.md docs/ai/quickstarts/build-mcp-server
docs/ai/toc.yml docs/ai/toc

@JonDouglas JonDouglas requested a review from joelverhagen June 30, 2025 16:19
@JonDouglas JonDouglas requested review from gewarren, alexwolfmsft and a team as code owners June 30, 2025 16:19
@dotnetrepoman dotnetrepoman bot added this to the June 2025 milestone Jun 30, 2025
1. In a terminal window, install the `dotnet new mcpserver` template:

```bash
dotnet new install Microsoft.Extensions.AI.Templates::9.6.0-preview.2.25310.2
Copy link
Member

@joelverhagen joelverhagen Jun 30, 2025

Choose a reason for hiding this comment

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

TODO: update to the correct package version
(we don't know it yet)

Copy link
Member

Choose a reason for hiding this comment

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

For reference, the draft template is here: dotnet/extensions#6547

Copy link
Contributor

@gewarren gewarren left a comment

Choose a reason for hiding this comment

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

This seems to duplicate a lot of what's in the other MCP server quickstart. Can we combine them, or perhaps require the other one as a prerequisite of a quickstart that only deals with publishing the MCP server to NuGet?

@JonDouglas
Copy link
Contributor Author

This seems to duplicate a lot of what's in the other MCP server quickstart. Can we combine them, or perhaps require the other one as a prerequisite of a quickstart that only deals with publishing the MCP server to NuGet?

i'm not sure what the best approach is! either works.


## Discover MCP servers on NuGet.org

1. Search for your MCP Server package on [NuGet.org](https://www.nuget.org/packages?packagetype=mcpserver).
Copy link
Member

Choose a reason for hiding this comment

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

TODO: add screenshots from NuGet.org

@joelverhagen
Copy link
Member

This seems to duplicate a lot of what's in the other MCP server quickstart. Can we combine them, or perhaps require the other one as a prerequisite of a quickstart that only deals with publishing the MCP server to NuGet?

i'm not sure what the best approach is! either works.

@alexwolfmsft, @timheuer, and I met and we decide to try merging the two documents. I have updated the PR accordingly.

Copy link
Contributor

@gewarren gewarren left a comment

Choose a reason for hiding this comment

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

Thanks for combining them, I like this better!


1. Update the tool code to use an environment variable. Add another tool method after the `GetRandomNumber` method in `Tools/RandomNumberTools.cs`:

```csharp
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you put the code in a separate file and reference it like this?

:::code language="csharp" source="snippets/mcp-server/program.cs" :::

Copy link
Member

Choose a reason for hiding this comment

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

@gewarren will do! I will put just the method (as I have here) not the whole file and see how it looks. LMK if that's wrong.


:::image type="content" source="../media/mcp/available-tools.png" alt-text="A screenshot showing the available MCP tools.":::
1. Select the **Select tools** icon to verify your **SampleMcpServer** is available with the sample tool listed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the get random number tool installed with the template?

Copy link
Member

Choose a reason for hiding this comment

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

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants