roslyn-mcp-pitfalls

roslyn-mcp-pitfalls is a cursor rule for Cursor from VuDZ/RoslynMcpServer. It costs 1,794 tokens per session, scanned A, original, MIT.

A set of rules recording known failure cases in a Roslyn MCP server, which gives agents tools for inspecting .NET code. It covers paths, code searches, assemblies, SDK selection, package checks, and test output.

In plain words
What is it for?
Use it while maintaining or debugging the MCP server and its .NET build, search, decompilation, and test tools.
Why use it?
It helps avoid regressions caused by scanning the wrong folder, choosing the wrong library, using the wrong .NET SDK, or misreading incomplete test results.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it while maintaining or debugging the MCP server and its .NET build, search, decompilation, and test tools.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/vudz/roslynmcpserver/roslyn-mcp-pitfalls
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/VuDZ/RoslynMcpServer

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for roslyn-mcp-pitfalls

README.md
[![agentmods](https://agentmods.dev/badge/rules/vudz/roslynmcpserver/roslyn-mcp-pitfalls/github.svg)](https://agentmods.dev/rules/vudz/roslynmcpserver/roslyn-mcp-pitfalls)
Your own site
<a href="https://agentmods.dev/rules/vudz/roslynmcpserver/roslyn-mcp-pitfalls"><img src="https://agentmods.dev/badge/rules/vudz/roslynmcpserver/roslyn-mcp-pitfalls/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for roslyn-mcp-pitfalls

Your own site · 80×15
<a href="https://agentmods.dev/rules/vudz/roslynmcpserver/roslyn-mcp-pitfalls"><img src="https://agentmods.dev/badge/rules/vudz/roslynmcpserver/roslyn-mcp-pitfalls.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 1,794 This file is loaded in full into every session.
When invoked 1,794 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.01794 $0.01794
Opus 5 $0.00897 $0.00897
Sonnet 5 $0.00359 $0.00359
Haiku 4.5 $0.00179 $0.00179

Measured yesterday against content hash e2f9e53480e8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-16, from the pricing page.

Security

Grade A, and why

roslyn-mcp-pitfalls scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/roslyn-mcp-pitfalls.mdc · 51 lines

How it starts

The opening of the file, as written. The whole thing — 51 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Known pitfalls (do not reintroduce)

  1. Relative paths vs CWD — Cursor often starts MCP with CWD = user home. Relative filePath without workspace resolve → wrong/missing files. Fix: ResolvePathAgainstWorkspace.

  2. search_code without directory — scanning from home hangs forever. Default to loaded workspace directory; default extension filter .cs; add scan timeout.

  3. get_code_skeleton vs decompile — agents pass assemblyName/typeName to file skeleton. Keep tools distinct; friendly error if path missing.

  4. Fuzzy assembly matchContains(name) picks wrong DLL. Exact {name}.dll + deps.json + NuGet/BCL fallback only.

  5. SDK mismatch silent0 Error(s) while wrong MSBuild (9.x vs 10.x pin). Detect and emit MCP_MSBUILD_SDK_MISMATCH; fix env before app code.

  6. NuGet audit invisible at -v:minimal — escalate restore/normal verbosity; parse embedded error NU####.

  7. VSTest “partial” on missing counters — requiring both Passed: and Failed: is wrong. Success often omits Failed:; .slnx/MSBuild VSTest fail output often omits Passed:. Infer the missing side (Failed/Skipped → 0, or Passed = Total − Failed − Skipped). Total-only without those lines stays unparsed.

  8. MSBuild bitness — 64-bit process + x86 SDK = BadImageFormat. Register matching MSBuild early.

  9. CWD = BaseDirectory — publish folder breaks tools; use ROSLYN_MCP_WORKSPACE instead.

  10. Hardcoded paths in docs — breaks other machines; resolve via IDE workspace / list_directory_tree.

  11. run_specific_test filter — never put Roslyn FullyQualifiedFormat (method ()) into FullyQualifiedName=; VSTest treats () as grouping. Prefer FullyQualifiedName~ with Ns.Type.Method (no parens). Do not prefix a leading . when the needle is already dotted (.Ns.Class does not appear inside Ns.Class).

  12. Fake/cached run_dotnet_build success — MCP has no result cache. False greens came from (a) MSBuild incremental/up-to-date skipping recompile → default --no-incremental; (b) probe lastExitCode overwritten by restore exit 0 after a failed build → effective exit = last build step only; (c) omitted -c on multi-config solutions. Always check metadata Configuration / NoIncremental.

  13. Publish locked by zombie MCP — Cursor may keep RoslynMcpServer.exe running after MCP disconnect; publish then fails with MSB3027 file locks. publish-and-verify.ps1 auto-kills repo/publish holders (opt out: -SkipKill), then reload MCP.

  14. apply_patch replaceAll hang — never rescan the inserted newString. If newString contains oldString (FooNs.Foos), while (IndexOf) grows the buffer forever, MCP never returns, logs stay empty. Advance searchFrom past each insert (same as string.Replace); log start/match/write with newContainsOld and elapsed ms.

  15. run_specific_test / run_dotnet_test without --no-build — a single dotnet test on a large .slnx dumps MSBuild warnings after (or instead of) the VSTest banner. Parser requires Passed! / Total tests: / Test Run Successful; exit 0 with only Time Elapsed / N Warning(s) becomes Status: partial + last 2KB of build footer. Split: dotnet build then dotnet test --no-build --no-restore; parse only the test process. Do not treat exit 0 as success and do not feed the build log to VstestOutputParser.

  16. VSTest duration not only ms — slow tests print [1 s] / [1 m 28 s]. A Passed/Failed regex that requires ms only reports no matching tests despite Total tests: 1 / Passed: 1. Accept ms|s|m|h (compound durations). Do not treat any [...] as duration.

  17. TargetFrameworks / missing CompileDirectory.Build.props with TargetFrameworks (even one TFM, or netstandard2.0;net10.0) makes design-time evaluation a CrossTargeting outer build: Build exists, Compile does not. load_workspace must pass targetFramework (inner TFM, e.g. net10.0). Do not treat this as SDK mismatch; dotnet build can still succeed. Dedicated failure lists TFMs from nearest props.

Read the full file on GitHub · 51 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday Changed · +4 lines · +260 tokens per session e2f9e53480e8
  2. 2d ago First seen · 47 lines · 1,534 tokens per session scan A 64101485ae6d

Subscribe to this mod's changes

roslyn-mcp-pitfalls is a cursor rule published in the GitHub repository VuDZ/RoslynMcpServer (7 stars, last pushed yesterday), licensed MIT. It adds 1,794 tokens to every session, about $0.0090 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-14.