RoselineMCP
Expose Roslyn code analysis as an MCP server so AI assistants can analyze and fix C# quality issues directly.




Table of Contents
The Problem
C# codebases accumulate quality issues silently -- inconsistent naming, missing nullable annotations, unused usings, suboptimal patterns. Manual code reviews catch some, but Roslyn analyzers can catch them all automatically. The problem: setting up and running analyzers across large codebases is tedious, and the results are not easily actionable from an AI assistant workflow.
The Solution
RoselineMCP exposes Roslyn analysis as an MCP server so AI assistants can analyze and fix C# code quality issues directly. Connect it to Claude Desktop or any MCP-compatible client and get comprehensive diagnostics, automated fixes, and reviewable patches -- all without leaving your AI workflow.
// In your Claude Desktop config, just add:
{
"mcpServers": {
"roseline": {
"command": "roseline-mcp"
}
}
}
// Then ask Claude: "Analyze my solution at /path/to/MySolution.sln"
Features
Tech Stack
| Layer | Technology |
|---|
| Runtime | .NET 10.0 |
| Compiler Platform | Roslyn (Microsoft.CodeAnalysis) 5.3.0 |
| Analyzers | Roslynator 4.15.0 |
| MCP SDK | ModelContextProtocol 1.1.0 |
| Diff Engine | DiffPlex 1.9.0 |
| Build System | MSBuild 18.4.0 |
| Hosting | Microsoft.Extensions.Hosting 10.0.5 |
Getting Started
Prerequisites
- NuGet global tool: .NET 10.0 SDK or later
- Docker: Docker Desktop or Docker Engine
- Build from source: .NET 10.0 SDK + MSBuild (included with Visual Studio or .NET SDK)
- MCP client: Claude Desktop or any MCP-compatible client
Installation
Option 1 -- NuGet Global Tool (recommended)
Requires .NET 10.0 SDK or later.
dotnet tool install -g RoselineMCP
After installation, the roseline-mcp command is available globally.
Claude Desktop configuration (NuGet global tool)
Add to your Claude Desktop configuration file (claude_desktop_config.json):
{
"mcpServers": {
"roseline": {
"command": "roseline-mcp"
}
}
}
Config file location:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
Option 2 -- Docker
No SDK required. Works on any platform with Docker installed.
docker run -i --rm phmatray/roseline-mcp:latest
Claude Desktop configuration (Docker)
{
"mcpServers": {
"roseline": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"phmatray/roseline-mcp:latest"
]
}
}
}
Note: The -i flag is required for stdio transport. The --rm flag removes the container after the session ends.
Option 3 -- Build from Source
git clone https://github.com/Atypical-Consulting/RoselineMCP.git
cd RoselineMCP
dotnet build
dotnet test
Claude Desktop configuration (build from source)
{
"mcpServers": {
"roseline": {
"command": "dotnet",
"args": ["run", "--project", "/path/to/RoselineMCP/RoselineMCP.csproj"]
}
}
}
Available Tools
1. AnalyzeSolution
Analyzes an entire C# solution for diagnostics.
analyzeSolution({
pathOrGit: "/path/to/solution.sln",
includePattern: "*.Core", // Optional: Include only matching projects
excludePattern: "*.Tests", // Optional: Exclude matching projects
severity: "warning", // Optional: Minimum severity (error|warning|info)
maxDiagnostics: 100 // Optional: Maximum diagnostics to return
})
2. ListDiagnostics
Gets detailed diagnostics for a specific project.
listDiagnostics({
project: "MyProject.csproj",
ids: ["CS0168", "CS0219"], // Optional: Filter by diagnostic IDs
files: ["**/Controllers/*"], // Optional: Filter by file patterns
max: 50 // Optional: Maximum results
})
3. ApplyFixes
Applies automated code fixes for specified diagnostics.
applyFixes({
project: "MyProject.csproj",
ids: ["CS0168", "RCS1001"], // Diagnostic IDs to fix
previewOnly: true // Optional: Generate patch without applying
})
4. CreatePatch
Generates a unified diff between two text versions.
createPatch({
before: "original code",
after: "modified code",
fileName: "Example.cs" // Optional: For display in diff
})
Supported Analyzers
RoselineMCP includes support for:
- Roslyn Analyzers -- Built-in C# compiler diagnostics
- Roslynator -- 500+ analyzers, refactorings, and fixes for C#
- StyleCop Analyzers -- Code style and consistency rules
- Custom Analyzers -- Any Roslyn-based analyzer in your solution
Examples
Analyzing a Solution
# Using with an MCP client
mcp call analyzeSolution '{
"pathOrGit": "/Users/dev/MyProject/MyProject.sln",
"severity": "warning",
"maxDiagnostics": 50
}'
Response:
{
"solution": "MyProject.sln",
"projects": 5,
"diagnosticSummary": {
"error": 2,
"warning": 15,
"info": 28
},
"topDiagnostics": [
{
"id": "CS0168",
"severity": "warning",
"message": "The variable 'ex' is declared but never used",
"file": "Program.cs",
"line": 42
}
]
}
Applying Fixes
mcp call applyFixes '{
"project": "MyProject.Core.csproj",
"ids": ["CS0168", "RCS1001"],
"previewOnly": true
}'
Response includes a unified diff patch showing all changes that would be applied.
Configuration
Environment Variables
ROSELINE_LOG_LEVEL: Set logging level (Debug, Information, Warning, Error)
ASPNETCORE_ENVIRONMENT: Set environment (Development, Production)
appsettings.json
Configure logging and other settings:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"RoselineMCP": "Debug"
}
}
}
Architecture
RoselineMCP uses stdio transport β this is an intentional design decision. The server runs as a local process launched by the MCP client (Claude Desktop, AI agents), communicates over stdin/stdout, and exits when the client disconnects. This makes it perfectly suited for distribution as a NuGet global tool (dotnet tool install -g RoselineMCP) or Docker image β no port binding, no HTTP server, no infrastructure to manage.
βββββββββββββββββββββββ
β MCP Client β
β (Claude Desktop, β
β AI Assistants) β
ββββββββββ¬βββββββββββββ
β MCP Protocol (stdio)
βΌ
βββββββββββββββββββββββ
β RoselineMCP β
β MCP Server β
β β
β βββββββββββββββββ β
β β Tool Layer β β
β β (Analyze, β β
β β Fix, Patch) β β
β βββββββββ¬ββββββββ β
β βΌ β
β βββββββββββββββββ β
β β Service Layer β β
β β (Workspace, β β
β β Diagnostics) β β
β βββββββββ¬ββββββββ β
β βΌ β
β βββββββββββββββββ β
β β Roslyn + β β
β β Roslynator β β
β β Analyzers β β
β βββββββββββββββββ β
βββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββ
β C# Source Code β
β (.sln / .csproj) β
βββββββββββββββββββββββ
Project Structure
RoselineMCP/
βββ RoselineMCP/
β βββ Interfaces/ # Service interfaces
β βββ Services/ # Core business logic
β βββ Tools/ # MCP tool implementations
β βββ Models/ # Data transfer objects
β βββ Program.cs # Application entry point
βββ RoselineMCP.Tests/ # Unit tests
βββ .github/workflows/ # CI/CD pipelines
βββ Dockerfile # Container build
βββ RoselineMCP.sln # Solution file
Performance
- Workspace Caching -- MSBuild workspaces are reused when possible
- Parallel Analysis -- Projects analyzed concurrently
- Streaming Results -- Large result sets streamed to prevent memory issues
- Lazy Loading -- Diagnostics computed on-demand
Security
- No Code Execution -- Never executes code from analyzed projects
- Sandboxed Operations -- All changes made in temporary workspaces
- Path Validation -- Protection against path traversal attacks
- Read-Only by Default -- Explicit confirmation required for modifications
Troubleshooting
Common Issues
- MSBuild not found: Ensure .NET SDK is installed and in PATH
- Solution won't load: Check for missing NuGet packages, run
dotnet restore
- No diagnostics found: Verify analyzers are installed in the target project
- Permission denied: Ensure read access to solution files
Debug Logging
Enable detailed logging:
ROSELINE_LOG_LEVEL=Debug dotnet run --project RoselineMCP/RoselineMCP.csproj
Roadmap
Want to contribute? Pick any roadmap item and open a PR!
Stats
Contributing
Contributions are welcome! Please read CONTRIBUTING.md first.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature)
- Commit using conventional commits (
git commit -m 'feat: add amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
License
MIT Β© 2025 Atypical Consulting
Acknowledgments
Built with care by Atypical Consulting -- opinionated, production-grade open source.
