
用于 Roslyn 驱动的 C# 重构操作的模型上下文协议服务器
概览
让像Claude这样的AI助手安全地重构你的C#代码库,使用驱动Visual Studio的Roslyn编译器平台。 Roslyn MCP 服务器是一款模型上下文协议(MCP)服务器,面向 AI 助手和其他 MCP 客户端。它集成了 37 个重构操作、5 个代码导航工具、6 个分析和指标工具、5 个代码生成工具和 13 个代码转换工具——为您的 AI 提供深度代码智能、全面的重构和现代 C# 语法转换,并支持全解决方案的引用跟踪和预览。 ——重构、导航、分析、生成和转换工具,最全面的Roslyn MCP服务器——应用前准确查看变化——如果任何文件写入失败,所有更改都被恢复——重命名和移动会在整个解决方案中传播——dotnet工具安装——g:RoslynMcp.Server,无需复制库——适用于Windows、Linux和macOS 创建一个 .mcp 文件。
概述(AI 翻译)
让像Claude这样的AI助手安全地重构你的C#代码库,使用驱动Visual Studio的Roslyn编译器平台。
Roslyn MCP 服务器是一款模型上下文协议(MCP)服务器,向 AI 助手和其他 MCP 客户端展示 66 个 Roslyn 驱动的工具。它结合了 37 个重构操作、5 个代码导航工具、6 个分析和指标工具、5 个代码生成工具和 13 个代码转换工具——为您的 AI 提供深度代码智能、全面的重构和现代 C# 语法转换,并支持全解决方案的引用跟踪和预览。
目录
- 为什么是RoslynMcpServer?
- 先决条件
- 快速入门
- 独立CLI
- 配置
- 可用工具
- 预览模式
- 故障排除
- NuGet 库
- 贡献
- 许可证
为什么是RoslynMcpServer?
- 66 个工具——重构、导航、分析、生成和转换工具,最全面的 Roslyn MCP 服务器
- 每个操作的预览模式——在应用前准确查看会发生什么变化
- 原子文件写入带回滚 ——如果任何文件写入失败,所有更改都会被恢复
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Roslyn MCP Server
Let AI assistants like Claude safely refactor your C# codebase using the same Roslyn compiler platform that powers Visual Studio.
Roslyn MCP Server is a Model Context Protocol (MCP) server that exposes 66 Roslyn-powered tools to AI assistants and other MCP clients. It combines 37 refactoring operations, 5 code navigation tools, 6 analysis and metrics tools, 5 code generation tools, and 13 code conversion tools – giving your AI deep code intelligence, comprehensive refactoring, and modern C# syntax transformations with full solution-wide reference tracking and preview support.
Table of Contents
- Why RoslynMcpServer?
- Prerequisites
- Quick Start
- Standalone CLI
- Configuration
- Available Tools
- Preview Mode
- Troubleshooting
- NuGet Libraries
- Contributing
- License
Why RoslynMcpServer?
- 66 tools – refactoring, navigation, analysis, generation, and conversion tools, the most comprehensive Roslyn MCP server available
- Preview mode on every operation – see exactly what will change before applying
- Atomic file writes with rollback – if any file write fails, all changes are reverted
- Solution-wide reference updates – renames and moves propagate across your entire solution
- Single command install –
dotnet tool install -g RoslynMcp.Server, no repo cloning needed - Cross-platform – works on Windows, Linux, and macOS
Prerequisites
Before installing, make sure you have:
- .NET 9.0 SDK or later – Download here
- A C# solution (
.slnor.slnx) or project (.csproj) to work with
Verify your .NET SDK version:
dotnet --version
The output should be 9.0.x or higher.
Quick Start
1. Install
dotnet tool install -g RoslynMcp.Server
2. Configure
Create a .mcp.json file in your project root (for Claude Code):
{
"mcpServers": {
"roslyn-refactor": {
"type": "stdio",
"command": "roslyn-mcp",
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"roslyn-refactor": {
"type": "stdio",
"command": "roslyn-mcp",
"args": []
}
}
}