You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
4
4
5
5
See [aka.ms/nuget/mcp/guide](https://aka.ms/nuget/mcp/guide) for the full guide.
6
6
@@ -14,59 +14,70 @@ See [aka.ms/nuget/mcp/guide](https://aka.ms/nuget/mcp/guide) for the full guide.
14
14
15
15
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).
16
16
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
20
18
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`.
22
20
23
21
```json
24
22
{
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
+
}
34
33
}
35
34
}
36
35
```
37
36
38
-
### IDE-Specific Configuration
37
+
##Testing the MCP Server
39
38
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.
42
40
43
-
### Testing the MCP Server
41
+
##Publishing to NuGet.org
44
42
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`
46
45
47
-
## Developing locally
46
+
## Using the MCP Server from NuGet.org
48
47
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
50
52
51
-
The configuration uses the following server definition:
53
+
For both VS Code and Visual Studio, the configuration file uses the following server definition:
52
54
53
55
```json
54
56
{
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
+
}
63
68
}
64
69
}
65
70
```
66
71
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:
Refer to the VS Code or Visual Studio documentation for more information on configuring and using MCP servers:
68
81
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