From a4ba77f8356700c7fc9a9d618bb928b008ea81cf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 9 Jul 2025 18:31:46 +0000 Subject: [PATCH 01/12] Initial plan From bef503f33b5a50ced4a36796a0284811f46a727c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 9 Jul 2025 18:39:44 +0000 Subject: [PATCH 02/12] Add VS IDE-specific README and update template configuration Co-authored-by: timheuer <4821+timheuer@users.noreply.github.com> --- .../.template.config/template.json | 21 +++++ .../McpServer-CSharp/README.VisualStudio.md | 82 +++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.VisualStudio.md diff --git a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/.template.config/template.json b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/.template.config/template.json index 1fdc9128e81..9e53ce23c80 100644 --- a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/.template.config/template.json +++ b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/.template.config/template.json @@ -23,6 +23,27 @@ "binding": "HostIdentifier" } }, + "sources": [{ + "source": "./", + "target": "./", + "modifiers": [ + { + "condition": "(hostIdentifier == \"dotnetcli\" || hostIdentifier == \"dotnetcli-preview\")", + "exclude": [ + "README.VisualStudio.md" + ] + }, + { + "condition": "(hostIdentifier != \"dotnetcli\" && hostIdentifier != \"dotnetcli-preview\")", + "exclude": [ + "README.md" + ], + "rename": { + "README.VisualStudio.md": "README.md" + } + } + ] + }], "primaryOutputs": [ { "path": "./README.md" diff --git a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.VisualStudio.md b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.VisualStudio.md new file mode 100644 index 00000000000..138edd2f74f --- /dev/null +++ b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.VisualStudio.md @@ -0,0 +1,82 @@ +# MCP Server + +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. + +See [aka.ms/nuget/mcp/guide](https://aka.ms/nuget/mcp/guide) for the full guide. + +## Checklist before publishing to NuGet.org + +- Test the MCP server locally using the steps below. +- Update the package metadata in the .csproj file, in particular the ``. +- Update `.mcp/server.json` to declare your MCP server's inputs. + - See [configuring inputs](https://aka.ms/nuget/mcp/guide/configuring-inputs) for more details. +- Pack the project using `dotnet pack`. + +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). + +## Using the MCP Server in Visual Studio + +Once the MCP server package is published to NuGet.org, you can use the following Visual Studio configuration to download and install the MCP server package. See [Use MCP servers in Visual Studio (Preview)](https://learn.microsoft.com/visualstudio/ide/copilot/chat/mcp-servers) for more information about using MCP servers in Visual Studio. + +```json +{ + "mcp": { + "servers": { + "McpServer-CSharp": { + "type": "stdio", + "command": "dnx", + "args": [ + "", + "--version", + "", + "--yes" + ] + } + } + } +} +``` + +Now you can ask GitHub 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. + +## Developing locally in Visual Studio + +To test this MCP server from source code (locally) without using a built MCP server package, you can configure Visual Studio to use your local project. + +In Visual Studio, open the MCP settings and add the following configuration: + +```json +{ + "servers": { + "McpServer-CSharp": { + "type": "stdio", + "command": "dotnet", + "args": [ + "run", + "--project", + "" + ] + } + } +} +``` + +Alternatively, you can use the full path to your project: + +```json +{ + "mcp": { + "servers": { + "McpServer-CSharp": { + "type": "stdio", + "command": "dotnet", + "args": [ + "run", + "--project", + "" + ] + } + } + } +} +``` \ No newline at end of file From 14f0e9e573a1e3aa7861abad039cf960522924b0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 10 Jul 2025 17:19:13 +0000 Subject: [PATCH 03/12] Update to single README with both VS Code and Visual Studio sections Co-authored-by: jeffhandley <1031940+jeffhandley@users.noreply.github.com> --- .../.template.config/template.json | 21 ----- .../McpServer-CSharp/README.VisualStudio.md | 82 ------------------- .../src/McpServer/McpServer-CSharp/README.md | 67 +++++++++++++++ 3 files changed, 67 insertions(+), 103 deletions(-) delete mode 100644 src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.VisualStudio.md diff --git a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/.template.config/template.json b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/.template.config/template.json index 9e53ce23c80..1fdc9128e81 100644 --- a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/.template.config/template.json +++ b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/.template.config/template.json @@ -23,27 +23,6 @@ "binding": "HostIdentifier" } }, - "sources": [{ - "source": "./", - "target": "./", - "modifiers": [ - { - "condition": "(hostIdentifier == \"dotnetcli\" || hostIdentifier == \"dotnetcli-preview\")", - "exclude": [ - "README.VisualStudio.md" - ] - }, - { - "condition": "(hostIdentifier != \"dotnetcli\" && hostIdentifier != \"dotnetcli-preview\")", - "exclude": [ - "README.md" - ], - "rename": { - "README.VisualStudio.md": "README.md" - } - } - ] - }], "primaryOutputs": [ { "path": "./README.md" diff --git a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.VisualStudio.md b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.VisualStudio.md deleted file mode 100644 index 138edd2f74f..00000000000 --- a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.VisualStudio.md +++ /dev/null @@ -1,82 +0,0 @@ -# MCP Server - -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. - -See [aka.ms/nuget/mcp/guide](https://aka.ms/nuget/mcp/guide) for the full guide. - -## Checklist before publishing to NuGet.org - -- Test the MCP server locally using the steps below. -- Update the package metadata in the .csproj file, in particular the ``. -- Update `.mcp/server.json` to declare your MCP server's inputs. - - See [configuring inputs](https://aka.ms/nuget/mcp/guide/configuring-inputs) for more details. -- Pack the project using `dotnet pack`. - -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). - -## Using the MCP Server in Visual Studio - -Once the MCP server package is published to NuGet.org, you can use the following Visual Studio configuration to download and install the MCP server package. See [Use MCP servers in Visual Studio (Preview)](https://learn.microsoft.com/visualstudio/ide/copilot/chat/mcp-servers) for more information about using MCP servers in Visual Studio. - -```json -{ - "mcp": { - "servers": { - "McpServer-CSharp": { - "type": "stdio", - "command": "dnx", - "args": [ - "", - "--version", - "", - "--yes" - ] - } - } - } -} -``` - -Now you can ask GitHub 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. - -## Developing locally in Visual Studio - -To test this MCP server from source code (locally) without using a built MCP server package, you can configure Visual Studio to use your local project. - -In Visual Studio, open the MCP settings and add the following configuration: - -```json -{ - "servers": { - "McpServer-CSharp": { - "type": "stdio", - "command": "dotnet", - "args": [ - "run", - "--project", - "" - ] - } - } -} -``` - -Alternatively, you can use the full path to your project: - -```json -{ - "mcp": { - "servers": { - "McpServer-CSharp": { - "type": "stdio", - "command": "dotnet", - "args": [ - "run", - "--project", - "" - ] - } - } - } -} -``` \ No newline at end of file diff --git a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md index 50091888ad8..21200bce8e2 100644 --- a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md +++ b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md @@ -39,6 +39,31 @@ Once the MCP server package is published to NuGet.org, you can use the following 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. +## Using the MCP Server in Visual Studio + +Once the MCP server package is published to NuGet.org, you can use the following Visual Studio configuration to download and install the MCP server package. See [Use MCP servers in Visual Studio (Preview)](https://learn.microsoft.com/visualstudio/ide/copilot/chat/mcp-servers) for more information about using MCP servers in Visual Studio. + +```json +{ + "mcp": { + "servers": { + "McpServer-CSharp": { + "type": "stdio", + "command": "dnx", + "args": [ + "", + "--version", + "", + "--yes" + ] + } + } + } +} +``` + +Now you can ask GitHub 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. + ## Developing locally in VS Code 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: @@ -78,3 +103,45 @@ Alternatively, you can configure your VS Code user settings to use your local pr } } ``` + +## Developing locally in Visual Studio + +To test this MCP server from source code (locally) without using a built MCP server package, you can configure Visual Studio to use your local project. + +In Visual Studio, open the MCP settings and add the following configuration: + +```json +{ + "servers": { + "McpServer-CSharp": { + "type": "stdio", + "command": "dotnet", + "args": [ + "run", + "--project", + "" + ] + } + } +} +``` + +Alternatively, you can use the full path to your project: + +```json +{ + "mcp": { + "servers": { + "McpServer-CSharp": { + "type": "stdio", + "command": "dotnet", + "args": [ + "run", + "--project", + "" + ] + } + } + } +} +``` From 41d54bc2b91c77b39cb9eebd2edb2ac4782ab29f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 10 Jul 2025 17:40:10 +0000 Subject: [PATCH 04/12] Fix Visual Studio MCP documentation URL Co-authored-by: timheuer <4821+timheuer@users.noreply.github.com> --- .../src/McpServer/McpServer-CSharp/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md index 21200bce8e2..330e9338d9e 100644 --- a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md +++ b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md @@ -41,7 +41,7 @@ Now you can ask Copilot Chat for a random number, for example, `Give me 3 random ## Using the MCP Server in Visual Studio -Once the MCP server package is published to NuGet.org, you can use the following Visual Studio configuration to download and install the MCP server package. See [Use MCP servers in Visual Studio (Preview)](https://learn.microsoft.com/visualstudio/ide/copilot/chat/mcp-servers) for more information about using MCP servers in Visual Studio. +Once the MCP server package is published to NuGet.org, you can use the following Visual Studio configuration to download and install the MCP server package. See [Use MCP servers in Visual Studio (Preview)](https://learn.microsoft.com/visualstudio/ide/mcp-servers) for more information about using MCP servers in Visual Studio. ```json { From c6cf703af4ca4134b529ef5e40151a7d10256e36 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 10 Jul 2025 17:44:45 +0000 Subject: [PATCH 05/12] Fix Visual Studio MCP JSON configuration format Co-authored-by: timheuer <4821+timheuer@users.noreply.github.com> --- .../src/McpServer/McpServer-CSharp/README.md | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md index 330e9338d9e..2c5f9e55b24 100644 --- a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md +++ b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md @@ -45,18 +45,16 @@ Once the MCP server package is published to NuGet.org, you can use the following ```json { - "mcp": { - "servers": { - "McpServer-CSharp": { - "type": "stdio", - "command": "dnx", - "args": [ - "", - "--version", - "", - "--yes" - ] - } + "servers": { + "McpServer-CSharp": { + "type": "stdio", + "command": "dnx", + "args": [ + "", + "--version", + "", + "--yes" + ] } } } @@ -130,17 +128,15 @@ Alternatively, you can use the full path to your project: ```json { - "mcp": { - "servers": { - "McpServer-CSharp": { - "type": "stdio", - "command": "dotnet", - "args": [ - "run", - "--project", - "" - ] - } + "servers": { + "McpServer-CSharp": { + "type": "stdio", + "command": "dotnet", + "args": [ + "run", + "--project", + "" + ] } } } From 387d9ab8a97911e0bb32cdcb85db611dcdb110cd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 10 Jul 2025 17:49:46 +0000 Subject: [PATCH 06/12] Restructure README to reduce repetition between VS Code and Visual Studio sections Co-authored-by: jeffhandley <1031940+jeffhandley@users.noreply.github.com> --- .../src/McpServer/McpServer-CSharp/README.md | 52 +++++++------------ 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md index 2c5f9e55b24..6032788ec68 100644 --- a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md +++ b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md @@ -14,9 +14,13 @@ See [aka.ms/nuget/mcp/guide](https://aka.ms/nuget/mcp/guide) for the full guide. 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). -## Using the MCP Server in VS Code +## Using the MCP Server -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. +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 similar configurations with the `dnx` command to download and install the MCP server package from NuGet.org. + +### VS Code Configuration + +Add the following to your VS Code user settings. See [Use MCP servers in VS Code (Preview)](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) for more information. ```json { @@ -37,11 +41,9 @@ Once the MCP server package is published to NuGet.org, you can use the following } ``` -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. - -## Using the MCP Server in Visual Studio +### Visual Studio Configuration -Once the MCP server package is published to NuGet.org, you can use the following Visual Studio configuration to download and install the MCP server package. See [Use MCP servers in Visual Studio (Preview)](https://learn.microsoft.com/visualstudio/ide/mcp-servers) for more information about using MCP servers in Visual Studio. +Add the following to your Visual Studio MCP settings. See [Use MCP servers in Visual Studio (Preview)](https://learn.microsoft.com/visualstudio/ide/mcp-servers) for more information. ```json { @@ -60,11 +62,17 @@ Once the MCP server package is published to NuGet.org, you can use the following } ``` -Now you can ask GitHub 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. +### Testing the MCP Server + +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. + +## Developing locally + +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`. -## Developing locally in VS Code +### VS Code Configuration -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: +Create a `.vscode/mcp.json` file (workspace settings) in your project directory: ```json { @@ -82,7 +90,7 @@ To test this MCP server from source code (locally) without using a built MCP ser } ``` -Alternatively, you can configure your VS Code user settings to use your local project: +Alternatively, configure your VS Code user settings with the full path: ```json { @@ -102,9 +110,7 @@ Alternatively, you can configure your VS Code user settings to use your local pr } ``` -## Developing locally in Visual Studio - -To test this MCP server from source code (locally) without using a built MCP server package, you can configure Visual Studio to use your local project. +### Visual Studio Configuration In Visual Studio, open the MCP settings and add the following configuration: @@ -117,25 +123,7 @@ In Visual Studio, open the MCP settings and add the following configuration: "args": [ "run", "--project", - "" - ] - } - } -} -``` - -Alternatively, you can use the full path to your project: - -```json -{ - "servers": { - "McpServer-CSharp": { - "type": "stdio", - "command": "dotnet", - "args": [ - "run", - "--project", - "" + "" ] } } From 4717976862439f008da554100052dfe887807650 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 05:44:07 +0000 Subject: [PATCH 07/12] Eliminate repetitive JSON configuration in README by consolidating server definitions Co-authored-by: jeffhandley <1031940+jeffhandley@users.noreply.github.com> --- .../src/McpServer/McpServer-CSharp/README.md | 115 +++++------------- 1 file changed, 28 insertions(+), 87 deletions(-) diff --git a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md index 6032788ec68..b1dd1eff5b3 100644 --- a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md +++ b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md @@ -16,51 +16,29 @@ The `bin/Release` directory will contain the package file (.nupkg), which can be ## Using the MCP Server -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 similar configurations with the `dnx` command to download and install the MCP server package from NuGet.org. +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. -### VS Code Configuration - -Add the following to your VS Code user settings. See [Use MCP servers in VS Code (Preview)](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) for more information. +The configuration uses the following server definition: ```json { - "mcp": { - "servers": { - "McpServer-CSharp": { - "type": "stdio", - "command": "dnx", - "args": [ - "", - "--version", - "", - "--yes" - ] - } - } + "McpServer-CSharp": { + "type": "stdio", + "command": "dnx", + "args": [ + "", + "--version", + "", + "--yes" + ] } } ``` -### Visual Studio Configuration +### IDE-Specific Configuration -Add the following to your Visual Studio MCP settings. See [Use MCP servers in Visual Studio (Preview)](https://learn.microsoft.com/visualstudio/ide/mcp-servers) for more information. - -```json -{ - "servers": { - "McpServer-CSharp": { - "type": "stdio", - "command": "dnx", - "args": [ - "", - "--version", - "", - "--yes" - ] - } - } -} -``` +- **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. +- **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. ### Testing the MCP Server @@ -70,62 +48,25 @@ Once configured, you can ask Copilot Chat for a random number, for example, `Giv 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`. -### VS Code Configuration - -Create a `.vscode/mcp.json` file (workspace settings) in your project directory: +The configuration uses the following server definition: ```json { - "servers": { - "McpServer-CSharp": { - "type": "stdio", - "command": "dotnet", - "args": [ - "run", - "--project", - "" - ] - } + "McpServer-CSharp": { + "type": "stdio", + "command": "dotnet", + "args": [ + "run", + "--project", + "" + ] } } ``` -Alternatively, configure your VS Code user settings with the full path: +### IDE-Specific Configuration -```json -{ - "mcp": { - "servers": { - "McpServer-CSharp": { - "type": "stdio", - "command": "dotnet", - "args": [ - "run", - "--project", - "" - ] - } - } - } -} -``` - -### Visual Studio Configuration - -In Visual Studio, open the MCP settings and add the following configuration: - -```json -{ - "servers": { - "McpServer-CSharp": { - "type": "stdio", - "command": "dotnet", - "args": [ - "run", - "--project", - "" - ] - } - } -} -``` +- **VS Code**: + - For workspace settings, create a `.vscode/mcp.json` file in your project directory with the above configuration under a `"servers"` section + - For user settings, add the above configuration under a `"mcp"` → `"servers"` section with the full path to the project directory +- **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. From f6574c03f3207ba62dd27872200fa524182154ec Mon Sep 17 00:00:00 2001 From: Jeff Handley Date: Sun, 13 Jul 2025 23:20:33 -0700 Subject: [PATCH 08/12] Revise the mcp server template README --- .../src/McpServer/McpServer-CSharp/README.md | 81 +++++++++++-------- 1 file changed, 46 insertions(+), 35 deletions(-) diff --git a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md index b1dd1eff5b3..81197a8ca9d 100644 --- a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md +++ b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md @@ -1,6 +1,6 @@ # MCP Server -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. +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. See [aka.ms/nuget/mcp/guide](https://aka.ms/nuget/mcp/guide) for the full guide. @@ -14,59 +14,70 @@ See [aka.ms/nuget/mcp/guide](https://aka.ms/nuget/mcp/guide) for the full guide. 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). -## Using the MCP Server - -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. +## Developing locally -The configuration uses the following server definition: +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`. ```json { - "McpServer-CSharp": { - "type": "stdio", - "command": "dnx", - "args": [ - "", - "--version", - "", - "--yes" - ] + "servers": { + "McpServer-CSharp": { + "type": "stdio", + "command": "dotnet", + "args": [ + "run", + "--project", + "" + ] + } } } ``` -### IDE-Specific Configuration +## Testing the MCP Server -- **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. -- **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. +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. -### Testing the MCP Server +## Publishing to NuGet.org -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. +1. Run `dotnet pack -c Release` to create the NuGet package +2. Publish to NuGet.org with `dotnet nuget push bin/Release/*.nupkg --api-key --source https://api.nuget.org/v3/index.json` -## Developing locally +## Using the MCP Server from NuGet.org -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`. +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. + +- **VS Code**: Create a `.vscode/mcp.json` file +- **Visual Studio**: Create a `\.mcp.json` file -The configuration uses the following server definition: +For both VS Code and Visual Studio, the configuration file uses the following server definition: ```json { - "McpServer-CSharp": { - "type": "stdio", - "command": "dotnet", - "args": [ - "run", - "--project", - "" - ] + "servers": { + "McpServer-CSharp": { + "type": "stdio", + "command": "dnx", + "args": [ + "", + "--version", + "", + "--yes" + ] + } } } ``` -### IDE-Specific Configuration +## More information + +.NET MCP servers use the [ModelContextProtocol](https://www.nuget.org/packages/ModelContextProtocol) C# SDK. For more information about MCP: + +- [Official Documentation](https://modelcontextprotocol.io/) +- [Protocol Specification](https://spec.modelcontextprotocol.io/) +- [GitHub Organization](https://github.com/modelcontextprotocol) + +Refer to the VS Code or Visual Studio documentation for more information on configuring and using MCP servers: -- **VS Code**: - - For workspace settings, create a `.vscode/mcp.json` file in your project directory with the above configuration under a `"servers"` section - - For user settings, add the above configuration under a `"mcp"` → `"servers"` section with the full path to the project directory -- **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. +- [Use MCP servers in VS Code (Preview)](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) +- [Use MCP servers in Visual Studio (Preview)](https://learn.microsoft.com/visualstudio/ide/mcp-servers) From 5dd0f872cf4cc276b1582b20c24d1aababfbe89c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 14:36:49 +0000 Subject: [PATCH 09/12] Update MCP template README paths and sync snapshot with source template Co-authored-by: joelverhagen <94054+joelverhagen@users.noreply.github.com> --- .../src/McpServer/McpServer-CSharp/README.md | 4 +- .../mcpserver/README.md | 87 ++++++++++--------- 2 files changed, 47 insertions(+), 44 deletions(-) diff --git a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md index 81197a8ca9d..4ca7a675857 100644 --- a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md +++ b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md @@ -47,8 +47,8 @@ Once configured, you can ask Copilot Chat for a random number, for example, `Giv 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. -- **VS Code**: Create a `.vscode/mcp.json` file -- **Visual Studio**: Create a `\.mcp.json` file +- **VS Code**: Create a `/.vscode/mcp.json` file +- **Visual Studio**: Create a `\.mcp.json` file For both VS Code and Visual Studio, the configuration file uses the following server definition: diff --git a/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Snapshots/mcpserver.Basic.verified/mcpserver/README.md b/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Snapshots/mcpserver.Basic.verified/mcpserver/README.md index 5c00a3bf669..4ca7a675857 100644 --- a/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Snapshots/mcpserver.Basic.verified/mcpserver/README.md +++ b/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Snapshots/mcpserver.Basic.verified/mcpserver/README.md @@ -1,6 +1,6 @@ -# MCP Server +# MCP Server -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. +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. See [aka.ms/nuget/mcp/guide](https://aka.ms/nuget/mcp/guide) for the full guide. @@ -14,67 +14,70 @@ See [aka.ms/nuget/mcp/guide](https://aka.ms/nuget/mcp/guide) for the full guide. 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). -## Using the MCP Server in VS Code +## Developing locally -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. +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`. ```json { - "mcp": { - "servers": { - "mcpserver": { - "type": "stdio", - "command": "dnx", - "args": [ - "", - "--version", - "", - "--yes" - ] - } + "servers": { + "McpServer-CSharp": { + "type": "stdio", + "command": "dotnet", + "args": [ + "run", + "--project", + "" + ] } } } ``` -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. +## Testing the MCP Server + +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. + +## Publishing to NuGet.org + +1. Run `dotnet pack -c Release` to create the NuGet package +2. Publish to NuGet.org with `dotnet nuget push bin/Release/*.nupkg --api-key --source https://api.nuget.org/v3/index.json` + +## Using the MCP Server from NuGet.org + +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. -## Developing locally in VS Code +- **VS Code**: Create a `/.vscode/mcp.json` file +- **Visual Studio**: Create a `\.mcp.json` file -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: +For both VS Code and Visual Studio, the configuration file uses the following server definition: ```json { "servers": { - "mcpserver": { + "McpServer-CSharp": { "type": "stdio", - "command": "dotnet", + "command": "dnx", "args": [ - "run", - "--project", - "" + "", + "--version", + "", + "--yes" ] } } } ``` -Alternatively, you can configure your VS Code user settings to use your local project: +## More information -```json -{ - "mcp": { - "servers": { - "mcpserver": { - "type": "stdio", - "command": "dotnet", - "args": [ - "run", - "--project", - "" - ] - } - } - } -} -``` +.NET MCP servers use the [ModelContextProtocol](https://www.nuget.org/packages/ModelContextProtocol) C# SDK. For more information about MCP: + +- [Official Documentation](https://modelcontextprotocol.io/) +- [Protocol Specification](https://spec.modelcontextprotocol.io/) +- [GitHub Organization](https://github.com/modelcontextprotocol) + +Refer to the VS Code or Visual Studio documentation for more information on configuring and using MCP servers: + +- [Use MCP servers in VS Code (Preview)](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) +- [Use MCP servers in Visual Studio (Preview)](https://learn.microsoft.com/visualstudio/ide/mcp-servers) From b63ed523b82173f0b00a071c6c910bc6a56712c5 Mon Sep 17 00:00:00 2001 From: Jeff Handley Date: Mon, 14 Jul 2025 11:38:29 -0700 Subject: [PATCH 10/12] Update mcpserver project template baseline --- .../mcpserver.Basic.verified/mcpserver/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Snapshots/mcpserver.Basic.verified/mcpserver/README.md b/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Snapshots/mcpserver.Basic.verified/mcpserver/README.md index 4ca7a675857..0e7e954dfb1 100644 --- a/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Snapshots/mcpserver.Basic.verified/mcpserver/README.md +++ b/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Snapshots/mcpserver.Basic.verified/mcpserver/README.md @@ -1,4 +1,4 @@ -# MCP Server +# MCP Server 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. @@ -21,7 +21,7 @@ To test this MCP server from source code (locally) without using a built MCP ser ```json { "servers": { - "McpServer-CSharp": { + "mcpserver": { "type": "stdio", "command": "dotnet", "args": [ @@ -36,7 +36,7 @@ To test this MCP server from source code (locally) without using a built MCP ser ## Testing the MCP Server -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. +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. ## Publishing to NuGet.org @@ -55,7 +55,7 @@ For both VS Code and Visual Studio, the configuration file uses the following se ```json { "servers": { - "McpServer-CSharp": { + "mcpserver": { "type": "stdio", "command": "dnx", "args": [ From dbf937be208fec11107e98c1cf25c5d077120ff2 Mon Sep 17 00:00:00 2001 From: Jeff Handley Date: Mon, 14 Jul 2025 22:12:03 -0700 Subject: [PATCH 11/12] Bump MEAI.Templates package to preview.3. --- .../Microsoft.Extensions.AI.Templates.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/Microsoft.Extensions.AI.Templates.csproj b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/Microsoft.Extensions.AI.Templates.csproj index 7784747028e..ab5ef554a3a 100644 --- a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/Microsoft.Extensions.AI.Templates.csproj +++ b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/Microsoft.Extensions.AI.Templates.csproj @@ -7,7 +7,7 @@ dotnet-new;templates;ai preview - 2 + 3 AI 0 0 From afeba291ff3ec842be2cf39f78127ca8ecf7908d Mon Sep 17 00:00:00 2001 From: Jeff Handley Date: Mon, 14 Jul 2025 22:12:23 -0700 Subject: [PATCH 12/12] Add feedback survey to mcpserver project template README --- .../src/McpServer/McpServer-CSharp/README.md | 2 ++ .../Snapshots/mcpserver.Basic.verified/mcpserver/README.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md index 4ca7a675857..cb11ac30eb5 100644 --- a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md +++ b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/McpServer/McpServer-CSharp/README.md @@ -4,6 +4,8 @@ This README was created using the C# MCP server project template. It demonstrate See [aka.ms/nuget/mcp/guide](https://aka.ms/nuget/mcp/guide) for the full guide. +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). + ## Checklist before publishing to NuGet.org - Test the MCP server locally using the steps below. diff --git a/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Snapshots/mcpserver.Basic.verified/mcpserver/README.md b/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Snapshots/mcpserver.Basic.verified/mcpserver/README.md index 0e7e954dfb1..a0bf0fc082d 100644 --- a/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Snapshots/mcpserver.Basic.verified/mcpserver/README.md +++ b/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Snapshots/mcpserver.Basic.verified/mcpserver/README.md @@ -4,6 +4,8 @@ This README was created using the C# MCP server project template. It demonstrate See [aka.ms/nuget/mcp/guide](https://aka.ms/nuget/mcp/guide) for the full guide. +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). + ## Checklist before publishing to NuGet.org - Test the MCP server locally using the steps below.