ER

egorpavlikhin/roslyn-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

32 stars 5 forks 质量 34 趋势 11

一款模型上下文协议(MCP)服务器,利用 Roslyn 编译器平台提供 C# 代码分析能力。

概览

一个模型上下文协议(MCP)服务器,利用 Roslyn 编译器平台提供 C# 代码分析能力。该工具帮助验证 C# 文件、寻找符号引用,并在 .NET 项目上下文中执行静态代码分析。 - : 分析 C# 文件中的语法错误、语义问题和编译器警告 - : 查找项目中符号的所有使用情况 - : 在项目上下文中验证文件 - : 运行 Microsoft 推荐的代码分析器 - ValidateFile:使用 Roslyn 验证 C# 文件并运行代码分析器- FindUsages:查找指定位置符号的所有引用 1. 构建项目 2.运行应用程序时有以下条件:3. 服务器将启动并监听通过标准I/O接收MCP命令 - .NET SDK - MSBuild 工具 - Roslyn 分析器用的 NuGet 包(如有自动加载) - 使用Microsoft。

概述(AI 翻译)

概述

一个模型上下文协议(MCP)服务器,利用 Roslyn 编译器平台提供 C# 代码分析能力。该工具帮助验证 C# 文件、寻找符号引用,并在 .NET 项目上下文中执行静态代码分析。

特色

  • 代码验证:分析C#文件中的语法错误、语义问题和编译器警告
  • 符号引用查找:查找项目中符号的所有用法
  • 项目上下文分析:在项目上下文中验证文件
  • 代码分析器支持:运行Microsoft推荐的代码分析器

工具

  • ValidateFile:使用 Roslyn 验证 C# 文件并运行代码分析器
  • FindUsages:查找指定位置符号的所有引用

示例配置

示例提示

开始

  1. 建设项目

  2. 运行应用程序:

  3. 服务器将通过标准I/O启动并监听MCP命令

要求

  • .NET SDK
  • MSBuild 工具
  • 用于Roslyn分析仪的NuGet软件包(如有自动加载)

示例用法

验证 C# 文件:

查找符号的所有用法:

技术细节

  • 使用“Microsoft”。

本页由 AI 翻译,技术细节请以原文为准。

README

Roslyn Code Analysis MCP Server

Overview

A Model Context Protocol (MCP) server that provides C# code analysis capabilities using the Roslyn compiler platform. This tool helps validate C# files, find symbol references, and perform static code analysis within the context of a .NET project.

Features

  • Code Validation: Analyze C# files for syntax errors, semantic issues, and compiler warnings
  • Symbol Reference Finding: Locate all usages of a symbol across a project
  • Project Context Analysis: Validate files within their project context
  • Code Analyzer Support: Run Microsoft recommended code analyzers

Tools

  • ValidateFile: Validates a C# file using Roslyn and runs code analyzers
  • FindUsages: Finds all references to a symbol at a specified position

Example config

{
    "servers": {
        "RoslynMCP": {
            "type": "stdio",
            "command": "dotnet",
            "args": [
                "run",
                "--no-build",
                "--project",
                "E:/Source/roslyn-mcp/RoslynMCP/RoslynMCP/RoslynMCP.csproj"
            ]
        }
    }
}

Example prompt

When done implementing changes, run these validation steps as human will not accept work unless these are done:
- Always use Roslyn validation tool on C# (.cs) files

Getting Started

  1. Build the project
  2. Run the application with:
    dotnet run
    
  3. The server will start and listen for MCP commands via standard I/O

Requirements

  • .NET SDK
  • MSBuild tools
  • NuGet packages for Roslyn analyzers (automatically loaded if available)

Example Usage

Validate a C# file:

ValidateFile --filePath="/path/to/your/file.cs" --runAnalyzers=true

Find all usages of a symbol:

FindUsages --filePath="/path/to/your/file.cs" --line=10 --column=15

Technical Details

  • Uses Microsoft.CodeAnalysis libraries for code analysis
  • Integrates with MSBuild to load full project context
  • Supports standard diagnostic analyzers
  • Includes detailed output with syntax, semantic, and analyzer diagnostics
在 GitHub 查看完整 README

安装

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

Open the repository installation guide 新手?先看 mcpskill.org 教程 →