An MCP (Model Context Protocol) server for .NET workspaces. It gives coding agents compiler-accurate symbol navigation, source-generator attribution, Avalonia/MAUI XAML queries, and a restricted Workspace Edit surface (rename / diagnostic fix / code refactoring). It is not a generic file writer, shell, or LSP proxy.
Package id on NuGet: Skymly.DotNetMcp (CLI command remains dotnet-mcp). Requires .NET 10+.
- Load
.sln/.slnx/.slnf/ SDK-style.csproj/.vbproj/.fsproj - C# and VB.NET via Roslyn; F# via an FCS stack beside the Roslyn snapshot
- Resolve a name to a checksummed
SymbolHandle, then go to definition, members, references, implementations, callers, type hierarchy - Attribute handwritten vs source-generated members (generator assembly + type + version)
- Project diagnostics; list generators / generated sources / generator diagnostics; list
dynamicinvocations - Avalonia
.axamland MAUI.xaml: class, xmlns,x:Name, compiled-binding path, XAML diagnostics - Restricted writes: preview then apply for rename, diagnostic fix (including project Fix all), and code refactoring
- Generic write / patch / create / delete file tools
- Shell, process, HTTP, or package-download tools
- WPF / WinUI XAML
- F# source-generator attribution, F# diagnostic fix, or F# code refactoring
- Extract-method / change-signature UIs
- Opening untrusted repositories safely —
workspace_openruns MSBuild evaluation and project analyzers/generators
Tool names are locked by a snapshot test. Domain vocabulary: CONTEXT.md.
Trusted roots are required. The process working directory is never an implicit sandbox.
On Windows, separate multiple roots with ;. You can also set DOTNET_MCP_TRUSTED_ROOTS.
The NuGet package Skymly.DotNetMcp is not published yet. Use a source build or a local pack until it is.
dotnet run --project src/DotNetMcp.Server -- --roots /path/to/repoMCP client (stdio), from a clone of this repo:
{
"mcpServers": {
"dotnet-mcp": {
"command": "dotnet",
"args": ["run", "--project", "src/DotNetMcp.Server", "--", "--roots", "/path/to/repo"]
}
}
}dotnet pack src/DotNetMcp.Server -c Release -o ./artifacts
dotnet tool exec --source ./artifacts --yes Skymly.DotNetMcp -- --roots /path/to/repoOnce Skymly.DotNetMcp is on nuget.org, dnx can become the preferred install path again:
dnx Skymly.DotNetMcp --yes -- --roots /path/to/repoEquivalent after publish: dotnet tool exec Skymly.DotNetMcp --yes -- --roots /path/to/repo, or dotnet tool install -g Skymly.DotNetMcp then dotnet-mcp --roots /path/to/repo.
stdio only. Framework-dependent .NET tool; NativeAOT is not required.
Typical agent loop: workspace_open (returns immediately) → poll workspace_status until ready → symbol_resolve → navigation / attribution. Prefer a .slnf or a single project for a large solution.
| Group | Tools |
|---|---|
| Workspace | workspace_open · workspace_status · workspace_list_projects · workspace_check_drift |
| Diagnostic fix | diagnostics_list_fixes · diagnostics_preview_fix · diagnostics_apply_fix |
| Symbol | symbol_resolve · symbol_summary · symbol_goto_definition · symbol_members · symbol_find_references · symbol_find_implementations · symbol_find_callers · symbol_type_hierarchy · symbol_attribution · symbol_preview_rename · symbol_apply_rename · symbol_list_refactorings · symbol_preview_refactoring · symbol_apply_refactoring |
| Project | project_diagnostics · project_list_generators · project_list_generated_sources · project_list_generator_diagnostics · project_list_dynamic_invocations |
| XAML | xaml_resolve_class · xaml_list_xmlns · xaml_resolve_name · xaml_resolve_binding · xaml_diagnostics |
- Trusted roots — every path is canonicalized (including parent reparse points). Unresolvable links fail closed. Loaded project graphs and apply-paths are re-checked. Configure
--rootsorDOTNET_MCP_TRUSTED_ROOTS. - Open means execute — loading a solution runs MSBuild and referenced analyzers / source generators. Do not point this server at untrusted trees.
.slnfproject entries are checked before MSBuild opens them;.sln/.slnx/ single-project graphs are checked after load, so an out-of-rootProjectReferenceis evaluated before it is rejected. - Default read + named writes — only rename / diagnostic fix / refactoring preview-apply. No generic write, command, or network tools.
- Audit — local process logs (stderr under stdio). Tool name and path metadata only; no source text; no telemetry. Disable with
DOTNET_MCP_AUDIT=0.
See ADR-0004.
List/scan tools honor a soft time budget (ADR-0003): they return partial results + nextCursor instead of hanging past the common ~60s client tools/call cap. Progress notifications are not a keepalive.
| Environment variable | Default | Use |
|---|---|---|
DOTNET_MCP_BUDGET_SINGLE_PROJECT_MS |
5000 | Single-project compile (e.g. project_diagnostics) |
DOTNET_MCP_BUDGET_FIND_REFS_SCOPED_MS |
5000 | Scoped find-references |
DOTNET_MCP_BUDGET_FIND_REFS_ENTIRE_MS |
20000 | Entire-solution find-references |
DOTNET_MCP_BUDGET_BATCH_DIAGNOSTICS_MS |
15000 | Reserved batch diagnostics |
DOTNET_MCP_BUDGET_FIXALL_PROJECT_MS |
15000 | Project Fix all; over budget fails the preview |
Invalid values fall back to the defaults.
workspace_open never blocks the MCP request. Clients that do not opt into MCP Tasks should poll workspace_status. Details: spikes/s3-mcp-long-running/CONCLUSIONS.md.
Product and tests target net10.0. Fixtures include net8.0 / net9.0 projects (needed for MsBuildWorkspaceIntegrationTests).
dotnet restore DotNetMcp.slnx
dotnet build DotNetMcp.slnx -c Release --no-restore
dotnet test DotNetMcp.slnx -c Release --no-buildCI: .github/workflows/ci.yml (Ubuntu and Windows; product SDK via global.json 10.0.x roll-forward, fixture SDKs 8.0.x/9.0.x, pack + McpServer metadata check).
Product benches: docs/perf/benchmark.md.
dotnet run --project benches/DotNetMcp.Bench -c Release -- --suite fixtures
dotnet run --project benches/DotNetMcp.Bench -c Release -- --suite smokeThis repo uses mattpocock/skills; see AGENTS.md and docs/agents/.
面向 Agent 的 .NET MCP 服务器:C# / VB / F# 符号导航、源生成器归因、Avalonia/MAUI XAML、以及受限 Workspace Edit(rename / Diagnostic fix / Code Refactoring)。不是通用写文件、shell 或 LSP 代理。
NuGet 包 id 为 Skymly.DotNetMcp(命令名仍是 dotnet-mcp)。必须通过 --roots 或 DOTNET_MCP_TRUSTED_ROOTS 配置受信根,不再默认使用进程工作目录。workspace_open 会运行 MSBuild 与 analyzer/源生成器,不要对不受信任的仓库使用。
安装(包尚未上架,请先源码运行或本地 pack):
dotnet run --project src/DotNetMcp.Server -- --roots /path/to/repoNuGet 上架后可用:dnx Skymly.DotNetMcp --yes -- --roots /path/to/repo。