DotnetCodingContextMCP 0.2.0
See the version list below for details.
dotnet tool install --global DotnetCodingContextMCP --version 0.2.0
dotnet new tool-manifest
dotnet tool install --local DotnetCodingContextMCP --version 0.2.0
#tool dotnet:?package=DotnetCodingContextMCP&version=0.2.0
nuke :add-package DotnetCodingContextMCP --version 0.2.0
DotnetCodingContextMCP
An MCP server that gives AI agents the coding context they need to write compilable C# code — type signatures, constructors, mock patterns, and test conventions in a single call.
The Problem
When AI agents write C# code, they hallucinate type names, property names, constructor signatures, and assertion patterns:
| What the agent writes | What actually exists |
|---|---|
new UserRepository() |
new UserRepository(IDbContext context) |
user.EmailAddress = "..." |
user.Email (different property name) |
record.Name = "x" |
positional record — requires constructor |
result.Should().BeTrue() |
result.ShouldBeTrue() (wrong assertion library) |
This causes build-fail-fix-build spirals that waste time and tokens.
The Solution: 3 Tools
get_coding_context
One call → everything needed to write code against specific types.
Input: { "typeNames": "UserService, OrderRepository",
"path": "/src/MyApp.sln" }
Output:
{
"types": [
{
"name": "UserService",
"using": "using MyApp.Services;",
"kind": "class",
"constructors": ["new UserService(IUserRepository repo, ILogger<UserService> logger)"],
"properties": [
{ "name": "IsInitialized", "type": "bool", "settable": false }
],
"instantiation": "new UserService(Mock.Of<IUserRepository>(), Mock.Of<ILogger<UserService>>())"
}
],
"relatedTypes": [...]
}
get_interface_contract
Mock-ready interface extraction with Moq setup patterns.
Input: { "interfaceName": "IUserRepository", "path": "/src/MyApp.sln" }
Output:
{
"members": [
{
"name": "GetByIdAsync",
"signature": "Task<User?> GetByIdAsync(int id)",
"mockSetup": "mock.Setup(x => x.GetByIdAsync(It.IsAny<int>())).ReturnsAsync(default(User?)!)"
}
],
"implementations": ["SqlUserRepository", "InMemoryUserRepository"],
"parameterTypes": [{ "name": "User", "kind": "class", "instantiation": "..." }]
}
get_project_test_context
Analyze existing tests to extract conventions.
Input: { "testProjectPath": "/test/MyApp.Tests/MyApp.Tests.csproj" }
Output:
{
"framework": "xunit",
"assertionLibrary": "Shouldly",
"mockingLibrary": "Moq",
"assertionPatterns": {
"equality": "result.ShouldBe(expected)",
"true": "result.ShouldBeTrue()",
"null": "result.ShouldBeNull()"
},
"namingConvention": "MethodName_Scenario_ExpectedBehavior",
"helperMethods": [
{ "name": "CreateTestUser", "signature": "User CreateTestUser(string name)" }
]
}
Quick Start
Install
dotnet tool install --global DotnetCodingContextMCP
VS Code / GitHub Copilot
Add to mcp.json:
{
"servers": {
"coding-context": {
"type": "stdio",
"command": "coding-context-mcp"
}
}
}
Pair with DotnetTemplateMCP
For complete .NET AI tooling — templates for project creation, coding context for code authoring:
{
"servers": {
"dotnet-templates": {
"type": "stdio",
"command": "template-engine-mcp"
},
"coding-context": {
"type": "stdio",
"command": "coding-context-mcp"
}
}
}
Why Not SharpLensMcp / Other Roslyn MCPs?
Existing Roslyn MCP servers expose many granular tools designed for code exploration (navigate, inspect, analyze). This MCP exposes 3 compound tools designed for code authoring — giving agents exactly what they need to write compilable code:
| Granular Roslyn MCPs | This MCP (3 tools) | |
|---|---|---|
| Tool calls per coding task | ~25-50 | 3 |
| Tool selection complexity | High — dozens of choices | Low — 3 obvious choices |
| Output format | Raw Roslyn data | Ready-to-paste code snippets |
| Mock setup generation | ❌ | ✅ Moq patterns included |
| Instantiation examples | ❌ | ✅ with actual constructor args |
| Test convention detection | ❌ | ✅ framework, assertions, helpers |
Requirements
- .NET 10 SDK
- MSBuild (included with .NET SDK)
License
MIT
| 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.