Prashant PatilI built an MCP server that gives Claude surgical access to your C# codebase — locally,...
If you've ever watched Claude hallucinate a NuGet API that hasn't existed since .NET 6, or burned your entire context window just loading a few service classes — this is for you.
AI coding tools have three silent killers in .NET:
dotnet-mcp-server is a self-hosted MCP server that exposes your C# codebase as structured tools. Claude never gets a raw file dump — it calls exactly what it needs, one class at a time, one method at a time.
Claude ──► ngrok ──► dotnet-mcp-server ──► Roslyn ──► Your C# source
│
├── Redis (AST cache, ~300ms warmup)
└── NuGet (reflects actual installed DLLs)
Token cost comparison:
| What you're doing | Raw dump | This server |
|---|---|---|
| Explore a class | ~2,000 tokens | ~400 tokens |
| Fetch one method | ~2,000 tokens | ~120 tokens |
| Explore a NuGet namespace | ~6,000 tokens | ~250 tokens |
Roslyn parses your .cs files once, serializes the AST metadata to Redis, and serves every subsequent call in milliseconds. A FileSystemWatcher debounces file saves (300ms) and evicts/rewrites only the changed file — so Claude always sees your current code, never stale.
analyze_c_sharp_file returns structured metadata: DI constructor graphs, method signatures with line ranges, attributes, XML docs, public/private toggle. fetch_method_implementation returns exact method bodies with line numbers Claude uses directly in edit_lines patch operations.
This one's different. When you ask "how do I use this method", it doesn't use training data. It:
.nupkg for the exact version in your .csproj
MetadataLoadContext (binary inspection — never executed)No training cutoff. No hallucinated overloads. No deprecated methods that still "work" in Claude's memory.
Claude can write files — but with: per-file semaphore locking, atomic batch-move validation, path sandboxing to project root (traversal structurally impossible), and permanent blocks on bin/, obj/, .git/, and any file matching secret/token patterns.
analyze_method_call_graph tells you every caller (file, class, line) before you touch a signature. The difference between a safe refactor and a CI failure at 11pm.
Register all your microservices. Every tool scopes to projectName. Claude can skeleton one service, read a method from another, edit a third — in one conversation.
Your source code never leaves your machine. Claude receives structured metadata — class names, method signatures, line ranges. Not your business logic. Not your algorithms. Not your customer data.
For anyone in finance, healthcare, or any regulated industry — this isn't a nice-to-have.
.NET 10 · Roslyn · Redis · ModelContextProtocol · NuGet.Protocol · MetadataLoadContext · ngrok (SSE transport)
22 MCP tools total: code analysis, file ops, NuGet exploration, dotnet CLI (clean + build with structured diagnostics).
git clone https://github.com/patilprashant6792-official/dotnet-mcp-server
cd dotnet-mcp-server/LocalMcpServer
dotnet run
Then spin up Redis, expose with ngrok, add the /sse URL to Claude.ai → Settings → Connectors. Full setup in the README.
Once the server is running, open the web UI:
http://localhost:5000/config.html
OR
http://your ngrok link/config.html
Add your project paths here — name, root path, description. Config persists in Redis so you register once and it survives restarts.
If you've hit any of these walls — drop a comment. Curious what .NET patterns people are trying to get Claude to reason about.