← Discover MCPs and Agents
c
MCPAI & MLGitHub

csharp-lsp-mcp

MCP server providing C# and XAML language intelligence for AI assistants like Claude

Links

README

From the repo.

csharp-lsp-mcp

Build NuGet NuGet Downloads License: MIT .NET MCP GitHub release

An MCP (Model Context Protocol) server that provides C# and XAML language intelligence for AI assistants like Claude. It bridges the gap between LLMs and .NET development by exposing IntelliSense, diagnostics, and code analysis through the standardized MCP protocol.

Features

C# Language Intelligence (via csharp-ls)

  • Diagnostics - Get compiler errors and warnings in real-time
  • Hover Information - View type information and documentation
  • IntelliSense Completions - Get context-aware code suggestions
  • Go to Definition - Navigate to symbol definitions
  • Find References - Locate all usages of a symbol
  • Document Symbols - List all symbols in a file
  • Code Actions - Access quick fixes and refactorings
  • Rename Preview - Preview symbol renames across the workspace
  • Stop/Restart - Stop the LSP server to release file locks before rebuilding

XAML Analysis (built-in)

  • Validation - Check XAML for errors and issues
  • Binding Analysis - Extract and analyze data bindings
  • Resource Inspection - List and verify resource references
  • Name Discovery - Find all x:Name declarations
  • Structure Visualization - View element tree hierarchy
  • Binding Error Detection - Identify binding problems
  • ViewModel Generation - Generate ViewModels from bindings

Prerequisites

  1. .NET 8.0 SDK or later
  2. csharp-ls - The C# Language Server

Install csharp-ls globally:

dotnet tool install --global csharp-ls

Installation

From Source

git clone https://github.com/HYMMA/csharp-lsp-mcp.git
cd csharp-lsp-mcp/csharp-lsp-mcp/src/CSharpLspMcp
dotnet build -c Release

From NuGet (coming soon)

dotnet tool install --global CSharpLspMcp

Configuration

Claude Code

Add to your ~/.claude.json:

{
  "mcpServers": {
    "csharp": {
      "command": "path/to/csharp-lsp-mcp.exe"
    }
  }
}

Or if installed as a global tool:

{
  "mcpServers": {
    "csharp": {
      "command": "csharp-lsp-mcp"
    }
  }
}

Claude Desktop

Add to your Claude Desktop configuration:

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

Usage

Once configured, the MCP server provides the following tools to your AI assistant:

Setting Up the Workspace

Before using C# tools, set the workspace directory:

Use csharp_set_workspace with path: "C:/path/to/your/solution"

Stopping the LSP for Rebuilds

The LSP server holds file locks on project DLLs. To rebuild your project, stop the server first:

Stop the C# LSP server so I can rebuild

After rebuilding, call csharp_set_workspace again to restart it. Switching workspaces via csharp_set_workspace automatically restarts the server.

Example Interactions

Get diagnostics for a file:

Check for errors in Program.cs

Get type information:

What type is the variable at line 15, column 10 in MyClass.cs?

Find all references:

Find all usages of the GetCustomer method

Analyze XAML bindings:

Show me all data bindings in MainWindow.xaml

Available Tools

ToolDescription
csharp_set_workspaceSet the solution/project directory (restarts LSP if workspace changes)
csharp_stopStop the LSP server to release file locks for rebuilding
csharp_diagnosticsGet compiler errors and warnings
csharp_hoverGet type info at a position
csharp_completionsGet IntelliSense completions
csharp_definitionGo to definition
csharp_referencesFind all references
csharp_symbolsGet document symbols
csharp_code_actionsGet available code actions
csharp_renamePreview symbol rename
xaml_validateValidate XAML for errors
xaml_bindingsExtract data bindings
xaml_resourcesList resource references
xaml_namesList x:Name declarations
xaml_structureShow element tree
xaml_find_binding_errorsFind binding errors
xaml_extract_viewmodelGenerate ViewModel from bindings

Command Line Options

csharp-lsp-mcp [OPTIONS]

OPTIONS:
    -h, --help      Show help message
    -v, --version   Show version information
    -V, --verbose   Enable verbose logging (to stderr)

ENVIRONMENT VARIABLES:
    MCP_DEBUG=1     Enable trace-level logging

Architecture

┌─────────────────┐     MCP Protocol      ┌──────────────────┐
│  Claude / LLM   │◄────────────────────►│  csharp-lsp-mcp  │
└─────────────────┘                       └────────┬─────────┘
                                                   │
                                    ┌──────────────┴──────────────┐
                                    │                             │
                              ┌─────▼─────┐               ┌───────▼───────┐
                              │ csharp-ls │               │  XAML Parser  │
                              │   (LSP)   │               │   (built-in)  │
                              └─────┬─────┘               └───────────────┘
                                    │
                              ┌─────▼─────┐
                              │  Roslyn   │
                              │ Compiler  │
                              └───────────┘

Building from Source

# Clone the repository
git clone https://github.com/HYMMA/csharp-lsp-mcp.git
cd csharp-lsp-mcp

# Build
cd csharp-lsp-mcp/src/CSharpLspMcp
dotnet build -c Release

# Run tests (if available)
dotnet test

# Create a release build
dotnet publish -c Release -o ./publish

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Changelog

See CHANGELOG.md for a history of changes.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Related Projects

Collected info

  • 23 stars
  • 8 forks
  • Language: C#
  • Source updated: 8/31/2026

Config for your environment

Replace {MCP_ENDPOINT_URL} with this MCP’s endpoint URL (from its repo or docs above). No API key — you connect directly.

Tool

OS

Config file: ~/.cursor/mcp.json

{
  "mcpServers": {
    "mcp-server": {
      "url": "{MCP_ENDPOINT_URL}"
    }
  }
}

Paste into mcpServers in the config file. Restart Cursor after saving.

If this MCP is also published on mcpchannel.ai, you can subscribe from Browse and use the gateway config there instead.