Skip to content

Commit 04223ed

Browse files
authored
Use latest template and schema (#49301)
1 parent cd08e70 commit 04223ed

File tree

4 files changed

+36
-20
lines changed

4 files changed

+36
-20
lines changed
-1.97 KB
Loading

docs/ai/quickstarts/build-mcp-server.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Quickstart - Create a minimal MCP server and publish to NuGet
33
description: Learn to create and connect to a minimal MCP server using C# and publish it to NuGet.
4-
ms.date: 07/02/2025
4+
ms.date: 10/20/2025
55
ms.topic: quickstart
66
author: alexwolfmsft
77
ms.author: alexwolf
@@ -23,7 +23,7 @@ In this quickstart, you create a minimal Model Context Protocol (MCP) server usi
2323

2424
## Create the project
2525

26-
1. In a terminal window, install the MCP Server template (version 9.7.0-preview.2.25356.2 or newer):
26+
1. In a terminal window, install the MCP Server template (version 9.10.0-preview.3.25513.3 or newer):
2727

2828
```bash
2929
dotnet new install Microsoft.Extensions.AI.Templates
@@ -35,6 +35,8 @@ In this quickstart, you create a minimal Model Context Protocol (MCP) server usi
3535
dotnet new mcpserver -n SampleMcpServer
3636
```
3737

38+
By default, this command creates a self-contained tool package targeting all of the most common platforms that .NET is supported on. To see more options, use `dotnet new mcpserver --help`.
39+
3840
1. Navigate to the `SampleMcpServer` directory:
3941

4042
```bash
@@ -125,7 +127,7 @@ In this example, you enhance the MCP server to use a configuration value set in
125127
"args": [
126128
"run",
127129
"--project",
128-
"<RELATIVE PATH TO PROJECT DIRECTORY>"
130+
"<relative-path-to-project-file>"
129131
],
130132
"env": {
131133
"WEATHER_CHOICES": "sunny,humid,freezing"
@@ -145,13 +147,13 @@ In this example, you enhance the MCP server to use a configuration value set in
145147

146148
1. Update the `.mcp/server.json` to declare your environment variable input. The `server.json` file schema is defined by the [MCP Registry project](https://github.com/modelcontextprotocol/registry/blob/main/docs/reference/server-json/generic-server-json.md) and is used by NuGet.org to generate VS Code MCP configuration.
147149

148-
- Use the `environment_variables` property to declare environment variables used by your app that will be set by the client using the MCP server (for example, VS Code).
150+
- Use the `environmentVariables` property to declare environment variables used by your app that will be set by the client using the MCP server (for example, VS Code).
149151

150-
- Use the `package_arguments` property to define CLI arguments that will be passed to your app. For more examples, see the [MCP Registry project](https://github.com/modelcontextprotocol/registry/blob/main/docs/reference/server-json/generic-server-json.md#examples).
152+
- Use the `packageArguments` property to define CLI arguments that will be passed to your app. For more examples, see the [MCP Registry project](https://github.com/modelcontextprotocol/registry/blob/main/docs/reference/server-json/generic-server-json.md#examples).
151153

152154
:::code language="json" source="snippets/mcp-server/.mcp/server.json":::
153155

154-
The only information used by NuGet.org in the `server.json` is the first `packages` array item with the `registry_name` value matching `nuget`. The other top-level properties aside from the `packages` property are currently unused and are intended for the upcoming central MCP Registry. You can leave the placeholder values until the MCP Registry is live and ready to accept MCP server entries.
156+
The only information used by NuGet.org in the `server.json` is the first `packages` array item with the `registryType` value matching `nuget`. The other top-level properties aside from the `packages` property are currently unused and are intended for the upcoming central MCP Registry. You can leave the placeholder values until the MCP Registry is live and ready to accept MCP server entries.
155157

156158
You can [test your MCP server again](#test-the-mcp-server) before moving forward.
157159

@@ -163,12 +165,16 @@ You can [test your MCP server again](#test-the-mcp-server) before moving forward
163165
dotnet pack -c Release
164166
```
165167

166-
1. Publish the package to NuGet:
168+
This command produces one tool package and several platform-specific packages based on the `<RuntimeIdentifiers>` list in `SampleMcpServer.csproj`.
169+
170+
1. Publish the packages to NuGet:
167171

168172
```bash
169173
dotnet nuget push bin/Release/*.nupkg --api-key <your-api-key> --source https://api.nuget.org/v3/index.json
170174
```
171175

176+
Be sure to publish all `.nupkg` files to ensure every supported platform can run the MCP server.
177+
172178
If you want to test the publishing flow before publishing to NuGet.org, you can register an account on the NuGet Gallery integration environment: [https://int.nugettest.org](https://int.nugettest.org). The `push` command would be modified to:
173179

174180
```bash
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
{
2-
"$schema": "https://modelcontextprotocol.io/schemas/draft/2025-07-09/server.json",
2+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-09-29/server.schema.json",
33
"description": "<your description here>",
44
"name": "io.github.<your GitHub username here>/<your repo name>",
5+
"version": "<your package version here>",
56
"packages": [
67
{
7-
"registry_name": "nuget",
8-
"name": "<your package ID here>",
8+
"registryType": "nuget",
9+
"registryBaseUrl": "https://api.nuget.org",
10+
"identifier": "<your package ID here>",
911
"version": "<your package version here>",
10-
"package_arguments": [],
11-
"environment_variables": [
12+
"transport": {
13+
"type": "stdio"
14+
},
15+
"packageArguments": [],
16+
"environmentVariables": [
1217
{
1318
"name": "WEATHER_CHOICES",
1419
"value": "{weather_choices}",
1520
"variables": {
1621
"weather_choices": {
1722
"description": "Comma separated list of weather descriptions to randomly select.",
18-
"is_required": true,
19-
"is_secret": false
23+
"isRequired": true,
24+
"isSecret": false
2025
}
2126
}
2227
}
@@ -26,8 +31,5 @@
2631
"repository": {
2732
"url": "https://github.com/<your GitHub username here>/<your repo name>",
2833
"source": "github"
29-
},
30-
"version_detail": {
31-
"version": "<your package version here>"
3234
}
3335
}

docs/ai/quickstarts/snippets/mcp-server/SampleMcpServer.csproj

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net10.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<RuntimeIdentifiers>win-x64;win-arm64;osx-arm64;linux-x64;linux-arm64;linux-musl-x64</RuntimeIdentifiers>
56
<OutputType>Exe</OutputType>
67
<Nullable>enable</Nullable>
78
<ImplicitUsings>enable</ImplicitUsings>
@@ -10,6 +11,13 @@
1011
<PackAsTool>true</PackAsTool>
1112
<PackageType>McpServer</PackageType>
1213

14+
<!-- Set up the MCP server to be a self-contained application that does not rely on a shared framework -->
15+
<SelfContained>true</SelfContained>
16+
<PublishSelfContained>true</PublishSelfContained>
17+
18+
<!-- Set up the MCP server to be a single file executable -->
19+
<PublishSingleFile>true</PublishSingleFile>
20+
1321
<!-- Set recommended package metadata -->
1422
<PackageReadmeFile>README.md</PackageReadmeFile>
1523
<PackageId>SampleMcpServer</PackageId>
@@ -25,8 +33,8 @@
2533
</ItemGroup>
2634

2735
<ItemGroup>
28-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0-preview.5.25277.114" />
29-
<PackageReference Include="ModelContextProtocol" Version="0.3.0-preview.2" />
36+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0-preview.6.25358.103" />
37+
<PackageReference Include="ModelContextProtocol" Version="0.4.0-preview.1" />
3038
</ItemGroup>
3139

3240
</Project>

0 commit comments

Comments
 (0)