apply_code_action
Apply a C# code action (refactoring or fix) by title, discovered via get_code_actions. Preview diff by default, or apply changes to disk with preview=false.
Instructions
Apply a code action (refactoring or fix) by its title. Use get_code_actions first to discover available actions. Defaults to preview mode (returns diff without writing files). Set preview=false to apply changes to disk.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"filePath": "<filePath>",
"line": "<line>",
"column": "<column>",
"actionTitle": "<actionTitle>"
},
"name": "apply_code_action"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| line | Yes | Line number (1-based) | |
| column | Yes | Column number (1-based) | |
| endLine | No | End line for text selection (1-based, optional) | |
| preview | No | Preview only — return diff without writing to disk (default: true) | |
| filePath | Yes | Full path to the C# source file | |
| endColumn | No | End column for text selection (1-based, optional) | |
| actionTitle | Yes | Exact title of the code action to apply (from get_code_actions) |