ByteAid.b4.Roslyn
0.3.0
dotnet tool install --global ByteAid.b4.Roslyn --version 0.3.0
dotnet new tool-manifest
dotnet tool install --local ByteAid.b4.Roslyn --version 0.3.0
#tool dotnet:?package=ByteAid.b4.Roslyn&version=0.3.0
nuke :add-package ByteAid.b4.Roslyn --version 0.3.0
b4.Roslyn
MCP (Model Context Protocol) server that lets AI agents work with .NET solutions efficiently through Roslyn: persistent in-memory semantic models, solution pre-compilation, code navigation, safe refactoring, diagnostics, file edits, builds and test execution — everything you would do with an IDE, over stdio (IPC).
Built on the official ModelContextProtocol C# SDK and .NET 10.
Install
dotnet tool install -g ByteAid.b4.Roslyn
This installs the b4-roslyn command. Optionally install the ByteAid.b4 dispatcher for the unified family entry point (b4 roslyn start → b4-roslyn start):
dotnet tool install -g ByteAid.b4
Start
cd path/to/your/repo
b4-roslyn start # or, with the dispatcher: b4 roslyn start
The server takes the current working directory as root and uses the single .sln/.slnx file found at that level as entry point. When there is more than one (or none), it fails asking for an explicit solution:
b4-roslyn start --solution MyApp.sln
The solution loads in the background at startup, and its semantic models stay alive in memory for the whole session — repeated queries are fast.
MCP client configuration
Claude Code:
claude mcp add b4-roslyn -- b4-roslyn start
Generic .mcp.json:
{
"mcpServers": {
"b4-roslyn": {
"command": "b4-roslyn",
"args": ["start"]
}
}
}
Tools
| Area | Tool | Purpose |
|---|---|---|
| Solution | solution_info |
Projects, references, load diagnostics |
reload_solution |
Discard memory state / switch solution | |
precompile |
Build all semantic models in memory; error/warning counts | |
project_structure |
Documents of a project | |
project_dependencies |
Project / package / assembly references | |
| Navigation | search_symbols |
Pattern search over declarations (camel-hump aware) |
goto_definition |
Definition by name or by file position | |
find_references |
All usages with source line text | |
find_implementations |
Interface implementations / derived types / overrides | |
symbol_documentation |
Signature + XML docs | |
file_outline |
Hierarchical types/members outline with line ranges | |
completions |
IntelliSense at a position | |
| Diagnostics | file_diagnostics |
Semantic errors/warnings of one file (overlay-aware) |
solution_diagnostics |
Compiler diagnostics of the whole solution | |
run_analyzers |
Compiler + referenced analyzers | |
| Editing | read_document |
Read content (line-numbered, overlay-aware) |
update_document |
Replace full file content in memory; returns diagnostics | |
replace_in_document |
Exact-match fragment replacement in memory | |
apply_text_edits |
Batch span-based edits in memory | |
create_document |
Add a new file to a project in memory | |
format_document |
Roslyn formatter | |
rename_symbol |
Solution-wide safe rename | |
save_changes |
Persist all in-memory changes to disk | |
discard_changes |
Drop in-memory changes, reload from disk | |
| Execution | build |
dotnet build (solution or project) |
run_tests |
dotnet test with optional --filter |
|
discover_tests |
Find xUnit/NUnit/MSTest methods without building |
Edit-validate-save workflow
Edits (update_document, replace_in_document, apply_text_edits, rename_symbol, format_document, create_document) are applied to an in-memory overlay and immediately return the resulting compiler diagnostics, so an agent can validate a change before touching disk. save_changes persists everything; discard_changes reverts. build/run_tests run against disk state and warn when unsaved overlay changes exist.
Notes
- Logs go to stderr; stdout is reserved for the MCP stdio protocol.
- Requires the .NET 10 SDK (project loading uses the MSBuild build host of the installed SDK).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.