Install
$ agentstack add mcp-hymma-csharp-lsp-mcp ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
About
csharp-lsp-mcp
[](https://github.com/HYMMA/csharp-lsp-mcp/actions/workflows/build.yml) [](https://www.nuget.org/packages/CSharpLspMcp) [](https://www.nuget.org/packages/CSharpLspMcp) [](https://opensource.org/licenses/MIT) [](https://dotnet.microsoft.com/) [](https://modelcontextprotocol.io/) [](https://github.com/HYMMA/csharp-lsp-mcp/releases)
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](CONTRIBUTING.md) for guidelines.
Changelog
See [CHANGELOG.md](CHANGELOG.md) for a history of changes.
License
This project is licensed under the MIT License - see the [LICENSE](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
Source & license
This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: HYMMA
- Source: HYMMA/csharp-lsp-mcp
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.