June 4, 2026
MCP for .NET: give your AI agent real tools (2026)
What the Model Context Protocol is, why a Roslyn-aware MCP server matters for C#, which servers to use, and how to wire up .mcp.json for Claude Code, Cursor, and Copilot.
The Model Context Protocol (MCP) is an open standard that lets AI coding agents use real tools (your filesystem, Git, a database, a language server) instead of guessing from text. For .NET developers the payoff is specific: an MCP server that understands your C# solution through Roslyn gives the agent the compiler’s view of your code, so it can rename safely and find real call sites instead of doing a string search. This guide explains what MCP is, which servers matter for a .NET project, and how to wire them up.
What is MCP?
MCP is an open protocol, introduced by Anthropic and now broadly adopted, that standardizes how an AI agent connects to external tools and data. Instead of every tool inventing its own integration, a tool exposes an MCP “server,” and any MCP-capable client (Claude Code, Cursor, Copilot, and others) can use it. Think of it as a USB-C port for agents: one standard, many tools.
A server can expose three things: tools (actions the agent can call, like running a query), resources (data it can read, like a file or a schema), and prompts (reusable templates). For day-to-day .NET work, tools and resources are what matter.
Why does MCP matter for .NET specifically?
Without MCP, an agent reasons about your code as text. It greps. That works for small changes and breaks down on a large C# solution where the same method name appears in ten places and only the types tell you which one you mean.
With a Roslyn-aware MCP server, the agent gets the semantic model of your solution: symbols, references, types, the real call graph. That is the difference between “find the string Save” and “find every caller of OrderService.Save.” On a big, strongly typed codebase, that semantic understanding is exactly the .NET advantage an agent should be using.
Which MCP servers should a .NET project use?
A practical baseline:
- Filesystem - scoped read and write to the repo. The agent’s hands.
- Git - history, diffs, blame, staged changes, so the agent can reason about what changed and why.
- A Roslyn-aware C# server - the semantic model of the solution (symbols, references, types). The .NET-specific win.
- Postgres (or your database) - read the schema before writing a query instead of guessing column names.
You do not need more than this to start. Add servers when you have a concrete need, not speculatively.
How do you configure MCP for Claude Code?
Claude Code reads a .mcp.json at the repo root automatically. A minimal config that works out of the box:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
},
"git": {
"command": "uvx",
"args": ["mcp-server-git", "--repository", "."]
}
}
}
For the C# semantic layer, add a Roslyn-powered server pointed at your .sln or .slnx. A solid community option is SharpTools (kooshi/SharpToolsMCP), a Roslyn-based MCP server for analyzing and editing C# solutions. Follow its README to add it to .mcp.json.
For Cursor and Copilot, point their MCP settings at the same servers. The protocol is the same; only the client config location differs.
A working example
Our free starter ships a .mcp.json plus notes on adding the Roslyn server, wired to a real (if minimal) .NET 10 solution: github.com/Khavel/dotnet-claude-starter. Clone it to see the config in context, then copy the shape into your own repo.
FAQ
Do I need MCP to use Claude Code with .NET? No. Claude Code works without it. MCP makes the agent meaningfully better on larger solutions, especially the Roslyn-aware server. Start with filesystem and git, then add the C# server when you notice the agent guessing.
Is MCP specific to Claude Code? No. MCP is an open standard. The same servers work with Cursor, Copilot, and other MCP-capable clients.
Does the Postgres server need production credentials? Use a read-only connection to a dev or staging database. The agent reads the schema; it should not need write access or production data to help you write a query.
How is this different from just opening files in the editor? Opening files gives the agent text. An MCP server gives it tools and, with Roslyn, the compiler’s understanding of the solution rather than a text search.
Building a production .NET SaaS, agent-first?
This is the setup; Sharpyard is the production kit built on it. A .NET 10 and Angular SaaS starter with auth, multi-tenancy, billing, and the agent operating layer (CLAUDE.md, the MCP config, contract tests) wired throughout. Join the waitlist for the founding price.
Related: Claude Code for .NET developers.
The full AI-native .NET SaaS starter kit.
Join the waitlist