Browse documentation

move_type

[refactoring]

Moves a type to another file or namespace and updates supported references.

Before you use this tool

Writes files by default. Set applyChanges: false to preview the diff. Inspect the diff before application. Types with multiple source declarations, enums, and delegates are unsupported. Ambiguous names return candidate keys without edits. Stale keys fail. Preview before applying.

Try it locally in the Glider playground

Parameters

NameTypeRequiredDescription
symbolKeystringNoSource class, struct, interface, or record key. Requires one source declaration. Do not combine with typeName or projectName.
typeNamestringNoUnique simple or fully qualified type name. Provide this or symbolKey.
targetFilePathstringNoOptional target file path.
targetNamespacestringNoOptional target namespace.
projectNamestringNoOptional project name to limit symbol search.
applyChangesbooleanNoIf true (default), applies changes to disk. If false, returns a preview diff. Default: true
formatAfterbooleanNoFormat changed documents after the move. Default is false. Default: false
organizeUsingsAfterbooleanNoOrganize usings in changed documents after the move. Default is false. Default: false
includeDiffbooleanNoInclude unified diff in response. Default is true. Default: true
maxDiffCharsnumberNoMax diff characters. Use 0 for unlimited. Default is 50000. Default: 50000
includePerFileDiffbooleanNoInclude per-file diffs in changedFiles. Default is true. Default: true
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 a type move to a new namespace

Arguments
{
  "typeName": "MyClass",
  "targetNamespace": "MyApp.Utils",
  "applyChanges": false
}
Full MCP request
Full MCP request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "move_type",
    "arguments": {
      "typeName": "MyClass",
      "targetNamespace": "MyApp.Utils",
      "applyChanges": false
    }
  }
}
Illustrative response
{
  "success": true,
  "symbolName": "MyClass",
  "symbolKind": "Class",
  "sourceLocation": "/path/to/OldFile.cs",
  "targetLocation": "/path/to/NewFile.cs",
  "filesChanged": 3,
  "filesCreated": 1,
  "applied": false,
  "unifiedDiff": "...",
  "workspaceUpdate": null
}

Preview a discovered type move

Arguments
{
  "symbolKey": "<type key from search_symbols>",
  "targetFilePath": "/path/to/NewFile.cs",
  "applyChanges": false
}
Full MCP request
Full MCP request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "move_type",
    "arguments": {
      "symbolKey": "<type key from search_symbols>",
      "targetFilePath": "/path/to/NewFile.cs",
      "applyChanges": false
    }
  }
}

Response Notes

An applied refactor keeps the line endings each file already has. A file that mixes LF and CRLF is written with the ending it uses most. The unified diff normalizes both sides to LF, so it shows the edit and not the endings.

Returns a unified diff. Types with multiple source declarations, enums, and delegates are unsupported. Ambiguous names return candidates with symbolKey fields, without edits. Stale keys fail. After apply, workspaceUpdate reports whether the new file belongs to a project. A reloaded_not_included result means no project compiles the new file. Results use top-level fields with success. Compact is the default; full adds responseDiagnostics. Both modes retain errors, coverage, partial state, and recovery advice.