RefactorMCP
Automated refactoring tools for C# code transformation using Roslyn.
RefactorMCP
RefactorMCP is a Model Context Protocol server that exposes Roslyn-based refactoring tools for C#.
Usage
Run the console application directly or host it as an MCP server:
dotnet run --project RefactorMCP.ConsoleApp
For usage examples see EXAMPLES.md.
Available Refactorings
- Extract Method – create a new method from selected code and replace the original with a call (expression-bodied methods are not supported).
- Introduce Field/Parameter/Variable – turn expressions into new members; fails if a field already exists.
- Convert to Static – make instance methods static using parameters or an instance argument.
- Move Static Method – relocate a static method and keep a wrapper in the original class.
- Move Instance Method – move one or more instance methods to another class and delegate from the source. If a moved method no longer accesses instance members, it is made static automatically. Provide a
methodNameslist along with optionalconstructor-injectionsandparameter-injectionsto control dependencies. - Move Multiple Methods (instance) – move several methods and keep them as instance members of the target class. The source instance is injected via the constructor when required.
- Move Multiple Methods (static) – move multiple methods and convert them to static, adding a
thisparameter. - Make Static Then Move – convert an instance method to static and relocate it to another class in one step.
- Move Type to Separate File – move a top-level type into its own file named after the type.
- Make Field Readonly – move initialization into constructors and mark the field readonly.
- Transform Setter to Init – convert property setters to init-only and initialize in constructors.
- Constructor Injection – convert method parameters to constructor-injected fields or properties.
- Safe Delete – remove fields or variables only after dependency checks.
- Extract Class – create a new class from selected members and compose it with the original.
- Inline Method – replace calls with the method body and delete the original.
- Extract Decorator – create a decorator class that delegates to an existing method.
- Create Adapter – generate an adapter class wrapping an existing method.
- Add Observer – introduce an event and raise it from a method.
- Use Interface – change a method parameter type to one of its implemented interfaces.
- List Tools – display all available refactoring tools as kebab-case names.
Metrics and summaries are also available via the metrics:// and summary:// resource schemes.
Contributing
- Run
dotnet testto ensure all tests pass. - Format the code with
dotnet formatbefore opening a pull request.
License
Licensed under the Mozilla Public License 2.0.
Related Servers
Scout Monitoring MCP
sponsorPut performance and error data directly in the hands of your AI assistant.
Alpha Vantage MCP Server
sponsorAccess financial market data: realtime & historical stock, ETF, options, forex, crypto, commodities, fundamentals, technical indicators, & more
UML-MCP-Server
Generate various UML diagrams from natural language or PlantUML code. Returns PlantUML code, image URLs, and saves diagrams locally.
fastMCP4J
Fast lightweight Java MCP server framework - Build Model Context Protocol servers with minimal boilerplate and full TypeScript SDK compatibility
Sugar
Autonomous AI development system for Claude Code with task queue management and workflow automation.
Factifai MCP Server
An MCP server for Factifai, enabling integration with any MCP-compatible AI tool to create and retrieve test results asynchronously.
HED MCP Server
An MCP server for Hierarchical Event Descriptors (HED) that automates sidecar creation and annotation for BIDS event files using LLMs.
WordPress MCP
A Python MCP server for interacting with a local WordPress instance.
302AI Custom MCP Server
A customizable MCP service with flexible tool selection and configuration. Requires a 302AI API key.
OpenZeppelin MCP Servers
Model Context Protocol Servers Repository for OpenZeppelin Products
WireMCP
Empowers LLMs with real-time network traffic analysis using tshark. Requires Wireshark's tshark to be installed.
MCP Server for iOS Simulator
An MCP server that enables LLMs to interact with iOS simulators through natural language commands.