Skip to content

Commit f6574c0

Browse files
committed
Revise the mcp server template README
1 parent 4717976 commit f6574c0

File tree

1 file changed

+46
-35
lines changed
  • src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp

1 file changed

+46
-35
lines changed
Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 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,59 +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
18-
19-
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.
17+
## Developing locally
2018

21-
The configuration uses the following server definition:
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`.
2220

2321
```json
2422
{
25-
"McpServer-CSharp": {
26-
"type": "stdio",
27-
"command": "dnx",
28-
"args": [
29-
"<your package ID here>",
30-
"--version",
31-
"<your package version here>",
32-
"--yes"
33-
]
23+
"servers": {
24+
"McpServer-CSharp": {
25+
"type": "stdio",
26+
"command": "dotnet",
27+
"args": [
28+
"run",
29+
"--project",
30+
"<PATH TO PROJECT DIRECTORY>"
31+
]
32+
}
3433
}
3534
}
3635
```
3736

38-
### IDE-Specific Configuration
37+
## Testing the MCP Server
3938

40-
- **VS Code**: Add the above configuration to your VS Code user settings under a `"mcp"``"servers"` section. See [Use MCP servers in VS Code (Preview)](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) for more information.
41-
- **Visual Studio**: Add the above configuration to your Visual Studio MCP settings under a `"servers"` section. See [Use MCP servers in Visual Studio (Preview)](https://learn.microsoft.com/visualstudio/ide/mcp-servers) for more information.
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.
4240

43-
### Testing the MCP Server
41+
## Publishing to NuGet.org
4442

45-
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.
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`
4645

47-
## Developing locally
46+
## Using the MCP Server from NuGet.org
4847

49-
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`.
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.
49+
50+
- **VS Code**: Create a `.vscode/mcp.json` file
51+
- **Visual Studio**: Create a `<SOLUTIONDIR>\.mcp.json` file
5052

51-
The configuration uses the following server definition:
53+
For both VS Code and Visual Studio, the configuration file uses the following server definition:
5254

5355
```json
5456
{
55-
"McpServer-CSharp": {
56-
"type": "stdio",
57-
"command": "dotnet",
58-
"args": [
59-
"run",
60-
"--project",
61-
"<PATH TO PROJECT DIRECTORY>"
62-
]
57+
"servers": {
58+
"McpServer-CSharp": {
59+
"type": "stdio",
60+
"command": "dnx",
61+
"args": [
62+
"<your package ID here>",
63+
"--version",
64+
"<your package version here>",
65+
"--yes"
66+
]
67+
}
6368
}
6469
}
6570
```
6671

67-
### IDE-Specific Configuration
72+
## More information
73+
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:
6881

69-
- **VS Code**:
70-
- For workspace settings, create a `.vscode/mcp.json` file in your project directory with the above configuration under a `"servers"` section
71-
- For user settings, add the above configuration under a `"mcp"``"servers"` section with the full path to the project directory
72-
- **Visual Studio**: Add the above configuration to your Visual Studio MCP settings under a `"servers"` section. You can use either a relative or full path to the project directory.
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)