
dave-hillier/refactor-mcp 是从 https://github.com/dave-hillier/refactor-mcp. 导入的 MCP 服务器候选人。
概览
dave-hillier/refactor-mcp 是从 https://github.com/dave-hillier/refactor-mcp. 导入的 MCP 服务器候选人。
概述(AI 翻译)
RefactorMCP 展示了基于 Roslyn 的 C# 重构工具,涵盖三项 点:命令行界面,一个保留解决方案的驻留守护进程 加载,以及一个模型上下文协议服务器。
这三个工具都通过同一个工具调度器和会话进行调度,所以是一个工具 无论叫什么名字,行为都一样。
安装
RefactorMCP 作为 .NET 工具发布到 NuGet。它需要一个 .NET SDK(9.0 或 后来)在机器上,因为解是通过MSBuild加载的。
这会将refactor-mcp放入路径。要向MCP客户端提供,注册
命令 refactor-mcp 带有参数 mcp,例如:
下面的示例是从源代码运行,‘dotnet run --project
RefactorMCP.ConsoleApp --[; with the tool installed, refactor-mcp’ 的
地方。
用途
选项以工具参数命名([--method-names
methodNames),可以省略尾随的Path(--file代替filePath),以及
剩余的部分按参数顺序进行位置排序。--no-daemon 执行调用
而是在呼叫过程中。守护进程在十分钟后停止,没有
请求,或者在被要求时使用 stop;[serve --idle-timeout 改变了
(30s、1h或0永不过期)。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
RefactorMCP
RefactorMCP exposes Roslyn-based refactoring tools for C# over three entry points: a command line interface, a resident daemon that keeps a solution loaded, and a Model Context Protocol server.
All three dispatch through the same tool dispatcher and session, so a tool behaves the same however it is called.
Install
RefactorMCP is published to NuGet as a .NET tool. It needs a .NET SDK (9.0 or later) on the machine, since solutions are loaded through MSBuild.
dotnet tool install --global RefactorMCP
This puts refactor-mcp on the path. To serve it to an MCP client, register
the command refactor-mcp with the argument mcp, for example:
{
"mcpServers": {
"refactor-mcp": { "command": "refactor-mcp", "args": ["mcp"] }
}
}
The examples below run from source with dotnet run --project RefactorMCP.ConsoleApp --; with the tool installed, refactor-mcp takes its
place.
Usage
# Run a refactoring. Tool commands go to the daemon for that solution, which is
# started on demand, so only the first call pays the MSBuild load.
dotnet run --project RefactorMCP.ConsoleApp -- extract-method \
--solution ./RefactorMCP.sln --file ./src/Foo.cs \
--selection-range 10:5-20:6 --method-name ComputeTotal
# The same call with JSON parameters, for scripting.
dotnet run --project RefactorMCP.ConsoleApp -- --json extract-method \
'{"solutionPath":"./RefactorMCP.sln","filePath":"./src/Foo.cs","selectionRange":"10:5-20:6","methodName":"ComputeTotal"}'
# Discover the tools, and what each one takes.
dotnet run --project RefactorMCP.ConsoleApp -- list-tools --verbose
dotnet run --project RefactorMCP.ConsoleApp -- extract-method --help
# Keep a solution loaded and serve calls from it.
dotnet run --project RefactorMCP.ConsoleApp -- serve --solution ./RefactorMCP.sln
dotnet run --project RefactorMCP.ConsoleApp -- status
dotnet run --project RefactorMCP.ConsoleApp -- stop --all
# Serve the tools over MCP on stdio.
dotnet run --project RefactorMCP.ConsoleApp -- mcp
Options are named after the tool’s parameters (--method-names for
methodNames), a trailing Path may be dropped (--file for filePath), and
anything left over is positional in parameter order. --no-daemon runs a call
in the calling process instead. The daemon stops after ten minutes without a
request, or when asked to with stop; serve --idle-timeout changes that
(30s, 1h, or 0 to never expire).
A daemon follows the files it has loaded, so edits made in an editor are picked up rather than refactored on top of stale text: an edited file is replaced in place, and a change to a project file reloads the solution before the next call.
Once built, the executable can be called directly
(RefactorMCP.ConsoleApp/bin/Debug/net9.0/RefactorMCP.ConsoleApp), which skips
the build check dotnet run performs.
For usage examples see EXAMPLES.md.
Tools
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"refactor-mcp": { "command": "refactor-mcp", "args": ["mcp"] }
}
}