Browse documentation

consolidate_package_version

[external]

Rewrites one package to a target version across supported PackageReference, packages.config, and legacy package-folder HintPath declarations. Set applyChanges=false for a preview diff.

Before you use this tool

Writes files by default. An authorized, unambiguous edit with a clear scope can apply directly. Set applyChanges: false for a preview without file writes. Preview when the user requests inspection only, the scope is unclear, or a broad refactor needs inspection.

Try it locally in the Glider playground

Parameters

NameTypeRequiredDescription
packageIdstringYesNuGet package ID to rewrite.
targetVersionstringYesTarget version to write into matching declarations.
projectNamestringNoOptional project name filter.
promoteToCentralPackageManagementbooleanNoWhen true, promotes matching SDK-style PackageReference declarations into Directory.Packages.props and removes inline version declarations. Legacy package styles stay unchanged in this mode. Default: false
applyChangesbooleanNoApply changes to disk. Default is true; pass false for a preview. Default: true
includeDiffbooleanNoInclude a unified diff in the response. Default is true. Default: true
maxDiffCharsnumberNoMaximum unified diff characters to return. Default is 50000. Use 0 for unlimited. Default: 50000
includePerFileDiffbooleanNoInclude diffs in changedFiles independently of includeDiff. File paths and counts remain available when false. Development builds after 13.4.0 default to false; released 13.4.0 defaults to true. Follow the installed schema. Default: false
pathStylestringNoPath style: 'absolute' (default) or 'relative' (to solution root). Default: "absolute"
responseDetailstringNocompact returns results and actionable state. full adds diagnostic metadata under responseDiagnostics. Default: "compact"

Examples

Replace sample paths and symbol keys with values from your workspace.

Preview version alignment for one package

Arguments
{
  "packageId": "Newtonsoft.Json",
  "targetVersion": "13.0.4",
  "applyChanges": false
}
Full MCP request
Full MCP request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "consolidate_package_version",
    "arguments": {
      "packageId": "Newtonsoft.Json",
      "targetVersion": "13.0.4",
      "applyChanges": false
    }
  }
}
Illustrative response
{
  "success": true,
  "packageId": "Newtonsoft.Json",
  "targetVersion": "13.0.4",
  "promoteToCentralPackageManagement": true,
  "preview": false,
  "applied": true,
  "changed": true,
  "centralPackageFilePath": "/path/to/Directory.Packages.props",
  "filesChanged": 2,
  "declarationCount": 3,
  "unifiedDiff": "...",
  "changedFiles": [
    {
      "filePath": "/path/to/MyProject.csproj",
      "changeCount": 2
    },
    {
      "filePath": "/path/to/Directory.Packages.props",
      "changeCount": 1
    }
  ]
}

Preview SDK-style promotion into central package management

Arguments
{
  "packageId": "Newtonsoft.Json",
  "targetVersion": "13.0.4",
  "promoteToCentralPackageManagement": true,
  "applyChanges": false
}
Full MCP request
Full MCP request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "consolidate_package_version",
    "arguments": {
      "packageId": "Newtonsoft.Json",
      "targetVersion": "13.0.4",
      "promoteToCentralPackageManagement": true,
      "applyChanges": false
    }
  }
}

Rewrite a scoped package version

Arguments
{
  "packageId": "Newtonsoft.Json",
  "targetVersion": "13.0.4",
  "projectName": "MyProject"
}
Full MCP request
Full MCP request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "consolidate_package_version",
    "arguments": {
      "packageId": "Newtonsoft.Json",
      "targetVersion": "13.0.4",
      "projectName": "MyProject"
    }
  }
}

Response Notes

Returns a unified diff and file metadata for supported package declaration rewrites. A preview (applyChanges=false) leads with preview:true and reports wouldChange/filesThatWouldChange instead of the past-tense counts below.

Unreleased development builds after 13.4.0 return one unified diff by default; the example uses that contract. Follow the installed schema for supported parameters and defaults. Set includeDiff=false for compact output, with includePerFileDiff=false where supported. Set includePerFileDiff=true only when separate file diffs are needed; it works independently of includeDiff. These controls preserve application state, file metadata, counts, and any diagnostics, errors, conflicts, or limits the tool reports. Results use top-level fields with success. Compact is the default; full adds responseDiagnostics. Both modes retain errors, coverage, partial state, and recovery advice.