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
| Name | Type | Required | Description |
|---|---|---|---|
| packageId | string | Yes | NuGet package ID to rewrite. |
| targetVersion | string | Yes | Target version to write into matching declarations. |
| projectName | string | No | Optional project name filter. |
| promoteToCentralPackageManagement | boolean | No | When 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 |
| applyChanges | boolean | No | Apply changes to disk. Default is true; pass false for a preview. Default: true |
| includeDiff | boolean | No | Include a unified diff in the response. Default is true. Default: true |
| maxDiffChars | number | No | Maximum unified diff characters to return. Default is 50000. Use 0 for unlimited. Default: 50000 |
| includePerFileDiff | boolean | No | Include 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 |
| pathStyle | string | No | Path style: 'absolute' (default) or 'relative' (to solution root). Default: "absolute" |
| responseDetail | string | No | compact 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
{
"packageId": "Newtonsoft.Json",
"targetVersion": "13.0.4",
"applyChanges": false
}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
}
}
}{
"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
{
"packageId": "Newtonsoft.Json",
"targetVersion": "13.0.4",
"promoteToCentralPackageManagement": true,
"applyChanges": false
}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
{
"packageId": "Newtonsoft.Json",
"targetVersion": "13.0.4",
"projectName": "MyProject"
}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.