DotnetCodingContextMCP 0.3.1

There is a newer version of this package available.
See the version list below for details.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet tool install --global DotnetCodingContextMCP --version 0.3.1
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local DotnetCodingContextMCP --version 0.3.1
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=DotnetCodingContextMCP&version=0.3.1
                    
nuke :add-package DotnetCodingContextMCP --version 0.3.1
                    

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: 4 Tools

analyze_solution_for_testing (new in v0.2.0)

Discover what's testable in a solution — call this FIRST.

Input:  { "path": "/src/MyApp.sln" }

Output:
{
  "sourceProjects": ["MyApp.Core", "MyApp.API"],
  "testProjects": ["MyApp.Tests"],
  "projects": [
    {
      "projectName": "MyApp.Core",
      "totalPublicTypes": 42,
      "testableTypes": [
        {
          "name": "UserService",
          "kind": "class",
          "publicMethodCount": 8,
          "constructorDependencies": ["IUserRepository", "ILogger<UserService>"],
          "complexity": 12,
          "instantiationHint": "new UserService(Mock.Of<IUserRepository>(), Mock.Of<ILogger<UserService>>())"
        }
      ]
    }
  ],
  "recommendedTestSetup": "Most-used dependencies to mock: IUserRepository, ILogger. Create mock instances first."
}

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"
    }
  }
}

MSBench / GitHub Copilot CLI with Custom Agent

For benchmark runs, combine the MCP server with a custom agent prompt to instruct the agent to use the tools:

# In your runner.sh, before sourcing entry.sh:

# 1. Configure MCP server
export GITHUB_COPILOT_MCP_JSON='{"mcpServers":{"coding-context":{"type":"local","tools":["*"],"command":"coding-context-mcp","args":[]}}}'

# 2. Create custom agent with MCP usage instructions
mkdir -p ~/.copilot/agents
cat > ~/.copilot/agents/dotnet-test-writer.md << 'EOF'
---
name: dotnet-test-writer
description: Expert .NET test writer that uses coding context MCP tools.
tools: ["*"]
---

You have access to coding-context MCP tools. Follow this workflow:

1. FIRST call `coding-context-analyze_solution_for_testing` with the solution path
2. Before writing code that uses specific types, call `coding-context-get_coding_context`
3. Before mocking interfaces, call `coding-context-get_interface_contract`
4. Before creating test files, call `coding-context-get_project_test_context`
EOF

export COPILOT_CUSTOM_AGENT=dotnet-test-writer

See examples/ for complete msbench runner scripts.

Why Not SharpLensMcp / Other Roslyn MCPs?

Existing Roslyn MCP servers expose many granular tools designed for code exploration (navigate, inspect, analyze). This MCP exposes 4 compound tools designed for code authoring — giving agents exactly what they need to write compilable code:

Granular Roslyn MCPs This MCP (4 tools)
Tool calls per coding task ~25-50 3-5
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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
0.4.2 122 3/9/2026
0.4.1 78 3/6/2026
0.4.0 79 3/6/2026
0.3.3 202 3/5/2026
0.3.2 197 3/5/2026
0.2.0 179 3/4/2026
0.1.0 144 3/4/2026