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.
- 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
- 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
- .NET 8.0 SDK or later
- csharp-ls - The C# Language Server
Install csharp-ls globally:
dotnet tool install --global csharp-lsgit clone https://github.com/HYMMA/csharp-lsp-mcp.git
cd csharp-lsp-mcp/csharp-lsp-mcp/src/CSharpLspMcp
dotnet build -c Releasedotnet tool install --global CSharpLspMcpAdd 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"
}
}
}Add to your Claude Desktop configuration:
{
"mcpServers": {
"csharp": {
"command": "csharp-lsp-mcp",
"args": []
}
}
}Once configured, the MCP server provides the following tools to your AI assistant:
Before using C# tools, set the workspace directory:
Use csharp_set_workspace with path: "C:/path/to/your/solution"
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.
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
| Tool | Description |
|---|---|
csharp_set_workspace |
Set the solution/project directory (restarts LSP if workspace changes) |
csharp_stop |
Stop the LSP server to release file locks for rebuilding |
csharp_diagnostics |
Get compiler errors and warnings |
csharp_hover |
Get type info at a position |
csharp_completions |
Get IntelliSense completions |
csharp_definition |
Go to definition |
csharp_references |
Find all references |
csharp_symbols |
Get document symbols |
csharp_code_actions |
Get available code actions |
csharp_rename |
Preview symbol rename |
xaml_validate |
Validate XAML for errors |
xaml_bindings |
Extract data bindings |
xaml_resources |
List resource references |
xaml_names |
List x:Name declarations |
xaml_structure |
Show element tree |
xaml_find_binding_errors |
Find binding errors |
xaml_extract_viewmodel |
Generate ViewModel from bindings |
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
┌─────────────────┐ MCP Protocol ┌──────────────────┐
│ Claude / LLM │◄────────────────────►│ csharp-lsp-mcp │
└─────────────────┘ └────────┬─────────┘
│
┌──────────────┴──────────────┐
│ │
┌─────▼─────┐ ┌───────▼───────┐
│ csharp-ls │ │ XAML Parser │
│ (LSP) │ │ (built-in) │
└─────┬─────┘ └───────────────┘
│
┌─────▼─────┐
│ Roslyn │
│ Compiler │
└───────────┘
# 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 ./publishWe welcome contributions! Please see CONTRIBUTING.md for guidelines.
See CHANGELOG.md for a history of changes.
This project is licensed under the MIT License - see the LICENSE file for details.
- Model Context Protocol - The protocol specification
- csharp-ls - The C# Language Server
- Microsoft MCP C# SDK - The official C# SDK for MCP
- Claude Code - Anthropic's CLI for Claude
- MCP Servers - Official MCP server implementations