- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 177
 
Add support for stamping version on server.json for MCP servers with 0.0.0-placeholder replacement #1270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for stamping version on server.json for MCP servers with 0.0.0-placeholder replacement #1270
Conversation
Co-authored-by: AArnott <3548+AArnott@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot please make the requested changes.
        
          
                src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.targets
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                test/Nerdbank.GitVersioning.Tests/BuildIntegrationManagedTests.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
      …, implement recursive __VERSION__ replacement, and improve tests Co-authored-by: AArnott <3548+AArnott@users.noreply.github.com>
          
 All requested changes have been implemented and tested. Updated MSBuild conditions, converted to namespace statements, implemented recursive VERSION replacement, improved tests, and addressed all feedback. Fixed in commit 412e26c. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
 If you need me to access, download, or install something from one of these locations, you can either: 
  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot please make these changes
        
          
                test/Nerdbank.GitVersioning.Tests/BuildIntegrationManagedTests.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
      …nt for 0.0.0-placeholder, revert BuildIntegrationTests.cs using statement Co-authored-by: AArnott <3548+AArnott@users.noreply.github.com>
          
 All requested changes have been implemented: 
 Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
 If you need me to access, download, or install something from one of these locations, you can either: 
  | 
    
| 
           This looks great!  | 
    
Addresses #xxx by adding automatic version stamping for MCP server.json files when
PackageType=McpServeris specified in MSBuild projects.Problem
MCP (Model Context Protocol) server projects need their server.json files to be versioned consistently with their NuGet packages. Previously, developers had to manually handle this with hacky CI flows:
nbgvto get the version numberserver.template.jsontoserver.jsonSolution
This PR introduces automatic server.json version stamping that integrates seamlessly with Nerdbank.GitVersioning's existing build process:
New MSBuild Integration
NBGV_StampMcpServerJsonruns before packaging whenPackageType=McpServerStampMcpServerJsonhandles simple string replacement with proper error handlingHow it Works
<PackageType>McpServer</PackageType>server.jsonfile"0.0.0-placeholder"with the computed NBGV versionserver.jsonfrom packaging and includes the versioned oneExample
Original server.json:
{ "$schema": "https://modelcontextprotocol.io/schemas/draft/2025-07-09/server.json", "description": "Sample .NET MCP Server", "name": "io.github.example/samplemcpserver", "version": "0.0.0-placeholder", "packages": [ { "registry_type": "nuget", "identifier": "Example.McpServer", "version": "0.0.0-placeholder", "transport": { "type": "stdio" } } ] }After NBGV processing:
{ "$schema": "https://modelcontextprotocol.io/schemas/draft/2025-07-09/server.json", "description": "Sample .NET MCP Server", "name": "io.github.example/samplemcpserver", "version": "1.2.3-alpha.4+branch.feature", "packages": [ { "registry_type": "nuget", "identifier": "Example.McpServer", "version": "1.2.3-alpha.4+branch.feature", "transport": { "type": "stdio" } } ] }Testing
0.0.0-placeholdervalues are replaced with the actual versionThis eliminates the need for manual version management in CI pipelines and ensures MCP server metadata stays in sync with package versions automatically, using a simple and efficient string replacement approach.
Fixes #1269
Fixes #1269
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.