MCP ExplorerExplorer

Roslyn Mcp

@egorpavlikhinon 10 months ago
2 MIT
FreeCommunity
AI Systems
#ai#llm#mcp#mcp-server#roslyn
A MCP server for C# code analysis using Roslyn, validating files and finding symbol references.

Overview

What is Roslyn Mcp

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

Use cases

Use cases for roslyn-mcp include validating C# files before deployment, ensuring code quality by running analyzers, and locating symbol references during code refactoring.

How to use

To use roslyn-mcp, first build the project and run the application using ‘dotnet run’. The server will start and listen for MCP commands via standard I/O. You can validate a C# file or find usages of a symbol by using the provided commands.

Key features

Key features of roslyn-mcp include code validation for syntax errors and semantic issues, symbol reference finding across projects, project context analysis, and support for Microsoft recommended code analyzers.

Where to use

roslyn-mcp can be used in software development environments where C# is the primary programming language, particularly in .NET projects that require static code analysis and validation.

Content

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

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers