DotnetTemplates icon indicating copy to clipboard operation
DotnetTemplates copied to clipboard

Add MCP (Model Context Protocol) configuration to all templates with --no-ai option

Open Copilot opened this issue 4 months ago • 5 comments

Overview

This PR adds Model Context Protocol (MCP) configuration files to all four templates (WPF, Console, Avalonia, and NuGet) to enhance AI-assisted development capabilities. A new --no-ai parameter allows users to opt-out of including these files.

Changes

Added .vscode/mcp.json Files

Each template now includes a .vscode/mcp.json configuration file with two MCP servers:

{
  "mcpServers": {
    "context7": {
      "command": "npx",
      "args": ["-y", "@upstash/context7-mcp"]
    },
    "msdocs": {
      "command": "npx",
      "args": ["-y", "@microsoft/mcp-server-docs"]
    }
  }
}
  • context7: Provides semantic code search and contextual understanding of your codebase
  • msdocs: Enables direct access to Microsoft documentation from AI assistants

The configuration file is placed in the .vscode directory to be recognized by Visual Studio and VS Code.

New --no-ai Parameter

Added a new optional parameter to all templates:

Parameter Description Default
--no-ai Exclude AI configuration files (.vscode/mcp.json) false

Usage example:

# Include .vscode/mcp.json (default behavior)
dotnet new keboo.wpf --name MyApp

# Exclude .vscode/mcp.json
dotnet new keboo.wpf --name MyApp --no-ai true

Documentation Updates

All template README files have been updated with:

  • The new --no-ai parameter in the parameters table
  • Usage examples demonstrating the parameter
  • A new "AI Configuration (Model Context Protocol)" section in Key Features explaining the functionality
  • Links to IDE documentation:

Benefits

  • Enhanced AI assistance: Developers using MCP-compatible AI tools get immediate access to semantic code search and Microsoft documentation
  • IDE integration: Native support in Visual Studio and VS Code through the .vscode/mcp.json configuration
  • Opt-in friendly: Default behavior includes the files, but they can be easily excluded
  • Zero impact: The mcp.json file is configuration-only and doesn't affect build, test, or runtime behavior
  • Consistent pattern: Follows the existing template parameter conventions (--sln, --no-tests, etc.)

Testing

All templates have been tested with both default behavior and --no-ai true:

  • ✅ WPF template (with and without --no-ai)
  • ✅ Console template (with and without --no-ai)
  • ✅ NuGet template (with and without --no-ai)
  • ✅ Avalonia template (with and without --no-ai)

Verified that .vscode/mcp.json is correctly included by default and properly excluded when --no-ai true is specified.

Fixes Keboo/DotnetTemplates#388

Original prompt

This section details on the original issue you should resolve

<issue_title>Add mcp.json file to all templates</issue_title> <issue_description>Include context7, and MS Docs MCPs https://github.com/mcp

Include a new --no-ai switch that will exclude this file from the template when specified (defaults to false)</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes Keboo/DotnetTemplates#388

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Oct 06 '25 14:10 Copilot

@copilot The files should end up in .vscode/mcp.json within each of the templates.

Update the README on each of the templates mentioning this as a feature. Include the following links Visual Studio VS Code

Keboo avatar Oct 06 '25 17:10 Keboo

@copilot The files should end up in .vscode/mcp.json within each of the templates.

Update the README on each of the templates mentioning this as a feature. ...

Updated in commit e0a3e8d. The mcp.json files are now located at .vscode/mcp.json in each template, and all documentation has been updated with the requested Visual Studio and VS Code links.

Copilot avatar Oct 06 '25 18:10 Copilot

@copilot fix the comments

Keboo avatar Oct 08 '25 00:10 Keboo

@copilot fix the comments

Could you clarify what comments need to be fixed? The mcp.json files are currently in standard JSON format (which doesn't support comments). Would you like me to:

  1. Add explanatory comments by converting to JSONC format?
  2. Add code comments somewhere else in the templates?
  3. Fix something specific in the documentation?

Copilot avatar Oct 08 '25 00:10 Copilot

Could you clarify what comments need to be fixed? The mcp.json files are currently in standard JSON format (which doesn't support comments). Would you like me to:

@copilot this comment

https://github.com/Keboo/DotnetTemplates/pull/389#discussion_r2411560772

Keboo avatar Oct 08 '25 00:10 Keboo