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
7
+
Please note that this template is currently in an early preview stage. If you have feedback, please take a [brief survey](http://aka.ms/dotnet-mcp-template-survey).
8
+
7
9
## Checklist before publishing to NuGet.org
8
10
9
11
- Test the MCP server locally using the steps below.
@@ -14,67 +16,70 @@ See [aka.ms/nuget/mcp/guide](https://aka.ms/nuget/mcp/guide) for the full guide.
14
16
15
17
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
18
17
-
## Using the MCP Server in VS Code
19
+
## Developing locally
18
20
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.
21
+
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`.
20
22
21
23
```json
22
24
{
23
-
"mcp": {
24
-
"servers": {
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
-
]
34
-
}
25
+
"servers": {
26
+
"McpServer-CSharp": {
27
+
"type": "stdio",
28
+
"command": "dotnet",
29
+
"args": [
30
+
"run",
31
+
"--project",
32
+
"<PATH TO PROJECT DIRECTORY>"
33
+
]
35
34
}
36
35
}
37
36
}
38
37
```
39
38
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-CSharp` MCP server and show you the results.
39
+
## Testing the MCP Server
40
+
41
+
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
+
43
+
## Publishing to NuGet.org
44
+
45
+
1. Run `dotnet pack -c Release` to create the NuGet package
46
+
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`
47
+
48
+
## Using the MCP Server from NuGet.org
41
49
42
-
## Developing locally in VS Code
50
+
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.
43
51
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:
52
+
-**VS Code**: Create a `<WORKSPACE DIRECTORY>/.vscode/mcp.json` file
53
+
-**Visual Studio**: Create a `<SOLUTION DIRECTORY>\.mcp.json` file
54
+
55
+
For both VS Code and Visual Studio, the configuration file uses the following server definition:
45
56
46
57
```json
47
58
{
48
59
"servers": {
49
60
"McpServer-CSharp": {
50
61
"type": "stdio",
51
-
"command": "dotnet",
62
+
"command": "dnx",
52
63
"args": [
53
-
"run",
54
-
"--project",
55
-
"<RELATIVE PATH TO PROJECT DIRECTORY>"
64
+
"<your package ID here>",
65
+
"--version",
66
+
"<your package version here>",
67
+
"--yes"
56
68
]
57
69
}
58
70
}
59
71
}
60
72
```
61
73
62
-
Alternatively, you can configure your VS Code user settings to use your local project:
74
+
## More information
63
75
64
-
```json
65
-
{
66
-
"mcp": {
67
-
"servers": {
68
-
"McpServer-CSharp": {
69
-
"type": "stdio",
70
-
"command": "dotnet",
71
-
"args": [
72
-
"run",
73
-
"--project",
74
-
"<FULL PATH TO PROJECT DIRECTORY>"
75
-
]
76
-
}
77
-
}
78
-
}
79
-
}
80
-
```
76
+
.NET MCP servers use the [ModelContextProtocol](https://www.nuget.org/packages/ModelContextProtocol) C# SDK. For more information about MCP:
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
7
+
Please note that this template is currently in an early preview stage. If you have feedback, please take a [brief survey](http://aka.ms/dotnet-mcp-template-survey).
8
+
7
9
## Checklist before publishing to NuGet.org
8
10
9
11
- Test the MCP server locally using the steps below.
@@ -14,67 +16,70 @@ See [aka.ms/nuget/mcp/guide](https://aka.ms/nuget/mcp/guide) for the full guide.
14
16
15
17
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
18
17
-
## Using the MCP Server in VS Code
19
+
## Developing locally
18
20
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.
21
+
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`.
20
22
21
23
```json
22
24
{
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
-
}
25
+
"servers": {
26
+
"mcpserver": {
27
+
"type": "stdio",
28
+
"command": "dotnet",
29
+
"args": [
30
+
"run",
31
+
"--project",
32
+
"<PATH TO PROJECT DIRECTORY>"
33
+
]
35
34
}
36
35
}
37
36
}
38
37
```
39
38
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.
39
+
## Testing the MCP Server
40
+
41
+
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` MCP server and show you the results.
42
+
43
+
## Publishing to NuGet.org
44
+
45
+
1. Run `dotnet pack -c Release` to create the NuGet package
46
+
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`
47
+
48
+
## Using the MCP Server from NuGet.org
41
49
42
-
## Developing locally in VS Code
50
+
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.
43
51
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:
52
+
-**VS Code**: Create a `<WORKSPACE DIRECTORY>/.vscode/mcp.json` file
53
+
-**Visual Studio**: Create a `<SOLUTION DIRECTORY>\.mcp.json` file
54
+
55
+
For both VS Code and Visual Studio, the configuration file uses the following server definition:
45
56
46
57
```json
47
58
{
48
59
"servers": {
49
60
"mcpserver": {
50
61
"type": "stdio",
51
-
"command": "dotnet",
62
+
"command": "dnx",
52
63
"args": [
53
-
"run",
54
-
"--project",
55
-
"<RELATIVE PATH TO PROJECT DIRECTORY>"
64
+
"<your package ID here>",
65
+
"--version",
66
+
"<your package version here>",
67
+
"--yes"
56
68
]
57
69
}
58
70
}
59
71
}
60
72
```
61
73
62
-
Alternatively, you can configure your VS Code user settings to use your local project:
74
+
## More information
63
75
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
-
```
76
+
.NET MCP servers use the [ModelContextProtocol](https://www.nuget.org/packages/ModelContextProtocol) C# SDK. For more information about MCP:
0 commit comments