Skip to content

Commit 5dd0f87

Browse files
Copilotjoelverhagen
andcommitted
Update MCP template README paths and sync snapshot with source template
Co-authored-by: joelverhagen <94054+joelverhagen@users.noreply.github.com>
1 parent f6574c0 commit 5dd0f87

File tree

2 files changed

+47
-44
lines changed
  • src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp
  • test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Snapshots/mcpserver.Basic.verified/mcpserver

2 files changed

+47
-44
lines changed

src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ Once configured, you can ask Copilot Chat for a random number, for example, `Giv
4747

4848
Once the MCP server package is published to NuGet.org, you can configure it in your preferred IDE. Both VS Code and Visual Studio use the `dnx` command to download and install the MCP server package from NuGet.org.
4949

50-
- **VS Code**: Create a `.vscode/mcp.json` file
51-
- **Visual Studio**: Create a `<SOLUTIONDIR>\.mcp.json` file
50+
- **VS Code**: Create a `<WORKSPACE DIRECTORY>/.vscode/mcp.json` file
51+
- **Visual Studio**: Create a `<SOLUTION DIRECTORY>\.mcp.json` file
5252

5353
For both VS Code and Visual Studio, the configuration file uses the following server definition:
5454

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# MCP Server
1+
# MCP Server
22

3-
This README was created using the C# MCP server template project. It demonstrates how you can easily create an MCP server using C# and then package it in a NuGet package.
3+
This README was created using the C# MCP server project template. It demonstrates how you can easily create an MCP server using C# and publish it as a NuGet package.
44

55
See [aka.ms/nuget/mcp/guide](https://aka.ms/nuget/mcp/guide) for the full guide.
66

@@ -14,67 +14,70 @@ See [aka.ms/nuget/mcp/guide](https://aka.ms/nuget/mcp/guide) for the full guide.
1414

1515
The `bin/Release` directory will contain the package file (.nupkg), which can be [published to NuGet.org](https://learn.microsoft.com/nuget/nuget-org/publish-a-package).
1616

17-
## Using the MCP Server in VS Code
17+
## Developing locally
1818

19-
Once the MCP server package is published to NuGet.org, you can use the following VS Code user configuration to download and install the MCP server package. See [Use MCP servers in VS Code (Preview)](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) for more information about using MCP servers in VS Code.
19+
To test this MCP server from source code (locally) without using a built MCP server package, you can configure your IDE to run the project directly using `dotnet run`.
2020

2121
```json
2222
{
23-
"mcp": {
24-
"servers": {
25-
"mcpserver": {
26-
"type": "stdio",
27-
"command": "dnx",
28-
"args": [
29-
"<your package ID here>",
30-
"--version",
31-
"<your package version here>",
32-
"--yes"
33-
]
34-
}
23+
"servers": {
24+
"McpServer-CSharp": {
25+
"type": "stdio",
26+
"command": "dotnet",
27+
"args": [
28+
"run",
29+
"--project",
30+
"<PATH TO PROJECT DIRECTORY>"
31+
]
3532
}
3633
}
3734
}
3835
```
3936

40-
Now you can ask Copilot Chat for a random number, for example, `Give me 3 random numbers`. It should prompt you to use the `get_random_number` tool on the `mcpserver` MCP server and show you the results.
37+
## Testing the MCP Server
38+
39+
Once configured, you can ask Copilot Chat for a random number, for example, `Give me 3 random numbers`. It should prompt you to use the `get_random_number` tool on the `McpServer-CSharp` MCP server and show you the results.
40+
41+
## Publishing to NuGet.org
42+
43+
1. Run `dotnet pack -c Release` to create the NuGet package
44+
2. Publish to NuGet.org with `dotnet nuget push bin/Release/*.nupkg --api-key <your-api-key> --source https://api.nuget.org/v3/index.json`
45+
46+
## Using the MCP Server from NuGet.org
47+
48+
Once the MCP server package is published to NuGet.org, you can configure it in your preferred IDE. Both VS Code and Visual Studio use the `dnx` command to download and install the MCP server package from NuGet.org.
4149

42-
## Developing locally in VS Code
50+
- **VS Code**: Create a `<WORKSPACE DIRECTORY>/.vscode/mcp.json` file
51+
- **Visual Studio**: Create a `<SOLUTION DIRECTORY>\.mcp.json` file
4352

44-
To test this MCP server from source code (locally) without using a built MCP server package, create a `.vscode/mcp.json` file (a VS Code workspace settings file) in your project directory and add the following configuration:
53+
For both VS Code and Visual Studio, the configuration file uses the following server definition:
4554

4655
```json
4756
{
4857
"servers": {
49-
"mcpserver": {
58+
"McpServer-CSharp": {
5059
"type": "stdio",
51-
"command": "dotnet",
60+
"command": "dnx",
5261
"args": [
53-
"run",
54-
"--project",
55-
"<RELATIVE PATH TO PROJECT DIRECTORY>"
62+
"<your package ID here>",
63+
"--version",
64+
"<your package version here>",
65+
"--yes"
5666
]
5767
}
5868
}
5969
}
6070
```
6171

62-
Alternatively, you can configure your VS Code user settings to use your local project:
72+
## More information
6373

64-
```json
65-
{
66-
"mcp": {
67-
"servers": {
68-
"mcpserver": {
69-
"type": "stdio",
70-
"command": "dotnet",
71-
"args": [
72-
"run",
73-
"--project",
74-
"<FULL PATH TO PROJECT DIRECTORY>"
75-
]
76-
}
77-
}
78-
}
79-
}
80-
```
74+
.NET MCP servers use the [ModelContextProtocol](https://www.nuget.org/packages/ModelContextProtocol) C# SDK. For more information about MCP:
75+
76+
- [Official Documentation](https://modelcontextprotocol.io/)
77+
- [Protocol Specification](https://spec.modelcontextprotocol.io/)
78+
- [GitHub Organization](https://github.com/modelcontextprotocol)
79+
80+
Refer to the VS Code or Visual Studio documentation for more information on configuring and using MCP servers:
81+
82+
- [Use MCP servers in VS Code (Preview)](https://code.visualstudio.com/docs/copilot/chat/mcp-servers)
83+
- [Use MCP servers in Visual Studio (Preview)](https://learn.microsoft.com/visualstudio/ide/mcp-servers)

0 commit comments

Comments
 (0)