DH

dave-hillier/refactor-mcp

Analytics & monitoring

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

94 stars 21 forks Качество 71 Тренд 23MPL-2.0

dave-hillier/refactor-mcp - кандидат на сервер MCP, импортированный из https://github.com/dave-hillier/refactor-mcp.

Обзор

dave-hillier/refactor-mcp - кандидат на сервер MCP, импортированный из https://github.com/dave-hillier/refactor-mcp.

Обзор (машинный перевод)

RefactorMCP предоставляет инструменты рефакторинга на основе Roslyn для C# с тремя входами Точки: интерфейс командной строки, постоянный демон, который сохраняет решение Загрузка и сервер протокола Model Context.

Все три отправки через один и тот же инструмент диспетчер и сеанс, поэтому инструмент ведет себя так же, как и называется.

##Установка

RefactorMCP публикуется в NuGet как инструмент .NET. Требуется .NET SDK (9.0 или SDK). позже) на машине, поскольку решения загружаются через MSBuild.

Это приводит к тому, что они идут по пути. Чтобы подать его клиенту MCP, зарегистрируйтесь. [[Т1]] с аргументом [[Т2]], например:

Приведенные ниже примеры выполняются из источника с помощью ‘dotnet run --project’. RefactorMCP.ConsoleApp — ; with the tool installed, refactor-mcp’ берет свое место.

Использование

Опции названы в честь параметров инструмента --method-names для [5], [T6] может быть отброшен --file для filePath, и Все, что осталось, позиционируется в порядке параметров. --no-daemon Вместо этого в процессе вызова. Демон останавливается через десять минут без При этом он может быть либо изменен, либо изменен, либо изменен, либо изменен. [12], [13] или [14], чтобы никогда не истекать.

Эта страница переведена автоматически. Технические детали смотрите в оригинале.

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

Открыть полный README на GitHub

Установка

This server does not publish a one-line install command.

Open the repository installation guide Новичок в MCP? Начните с руководства на mcpskill.org →

Конфигурация

{ "mcpServers": { "refactor-mcp": { "command": "refactor-mcp", "args": ["mcp"] } } }