CSharpLspMcp
MCP (Model Context Protocol) server providing C# and XAML language intelligence for AI assistants like Claude. Exposes IntelliSense, diagnostics, and code analysis through the standardized MCP protocol.
Ask AI about CSharpLspMcp
Powered by Claude Β· Grounded in docs
I know everything about CSharpLspMcp. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
csharp-lsp-mcp
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
- .NET 8.0 SDK or later
- 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
| 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 |
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
- Model Context Protocol - The protocol specification
- csharp-ls - The C# Language Server
- Microsoft MCP C# SDK - The official C# SDK for MCP
Related Projects
- Claude Code - Anthropic's CLI for Claude
- MCP Servers - Official MCP server implementations
