Skip to content

Implement Model Context Protocol (MCP) server with command handling and JSON-RPC support - #696

Merged
slang25 merged 7 commits into
masterfrom
spboyer/issue693
Feb 8, 2026
Merged

slang25 merged 7 commits into
masterfrom
spboyer/issue693

Conversation

@spboyer

@spboyer spboyer commented Dec 9, 2025

Copy link
Copy Markdown
Collaborator
  • Added McpCommand class to handle MCP server execution.
  • Introduced McpServer class to manage service interactions and request handling.
  • Implemented JSON-RPC request and response models for communication.
  • Created McpConsole for console output redirection.
  • Developed unit tests for MCP server functionalities including initialization and tool listing.
  • Updated DotNetOutdated.Tests project file to disable assembly info generation.

Fixes Create MCP server to support LLM-based agent assistance for .NET development
Fixes #693

…nd JSON-RPC support

- Added McpCommand class to handle MCP server execution.
- Introduced McpServer class to manage service interactions and request handling.
- Implemented JSON-RPC request and response models for communication.
- Created McpConsole for console output redirection.
- Developed unit tests for MCP server functionalities including initialization and tool listing.
- Updated DotNetOutdated.Tests project file to disable assembly info generation.

Fixes Create MCP server to support LLM-based agent assistance for .NET development
Fixes #693

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a Model Context Protocol (MCP) server for dotnet-outdated, enabling AI agents to interact with .NET projects to discover, analyze, and update outdated NuGet packages. The implementation includes JSON-RPC communication, three main tools (discover_projects, analyze_project, update_package), and basic test coverage.

Key Changes:

  • Added MCP server implementation with JSON-RPC request/response handling
  • Created three MCP tools for project discovery, package analysis, and package updates
  • Implemented custom console redirection to support MCP's stdin/stdout communication protocol

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 21 comments.

Show a summary per file
File Description
src/DotNetOutdated/McpServer.cs Core MCP server implementation with JSON-RPC handling and tool execution
src/DotNetOutdated/McpCommand.cs Command-line handler to start the MCP server with proper service configuration
src/DotNetOutdated/Models/JsonRpc.cs JSON-RPC request/response models with proper serialization attributes
src/DotNetOutdated/Services/McpConsole.cs Console wrapper that redirects output to stderr for MCP compatibility
src/DotNetOutdated/Program.cs Registered MCP subcommand in the main program
test/DotNetOutdated.Tests/McpServerTests.cs Unit tests for MCP server initialization and basic tool functionality
test/DotNetOutdated.Tests/DotNetOutdated.Tests.csproj Disabled assembly info generation
test-projects/development-dependencies-lock/packages.lock.json Removed net8.0/linux-x64 platform-specific dependencies
README.md Added MCP server documentation with configuration examples
DotNetOutdated.sln Reformatted solution file (GlobalSection reordering)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +367 to +379
else
{
status = _centralPackageVersionManagementService.AddPackage(projectPath, packageName, version, false);

if (!status.IsSuccess)
{
return new
{
content = new[] { new { type = "text", text = $"Failed to update package. If this is not a CPM project, please provide the 'framework' argument. Error: {status.Errors}" } },
isError = true
};
}
}

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The early return at lines 371-378 creates an asymmetric flow where the else branch can return early on failure, but the if branch (line 365) continues to check status at line 381. Consider refactoring to make the logic more consistent, such as checking status.IsSuccess after both branches complete without early returns.

Copilot uses AI. Check for mistakes.
Comment thread README.md
Comment on lines 238 to 239
## FAQ

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The section doesn't explain what MCP tools are available or what they do. Consider adding a "### Available Tools" subsection that lists discover_projects, analyze_project, and update_package with brief descriptions of each.

Suggested change
## FAQ

Copilot uses AI. Check for mistakes.
Comment on lines +230 to +252
private async Task<object> HandleDiscoverProjects(JsonElement arguments)
{
string path = arguments.GetProperty("path").GetString();
bool recursive = false;
if (arguments.TryGetProperty("recursive", out var recursiveProp))
{
recursive = recursiveProp.GetBoolean();
}

var projects = _projectDiscoveryService.DiscoverProjects(path, recursive);

return new
{
content = new[]
{
new
{
type = "text",
text = JsonSerializer.Serialize(projects)
}
}
};
}

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method is marked async but doesn't use any await keywords. Since the method returns a synchronous result, consider removing the async keyword and returning Task.FromResult(...) or add #pragma warning disable CS1998 if the async signature is required for consistency.

Copilot uses AI. Check for mistakes.

private async Task<object> HandleAnalyzeProject(JsonElement arguments)
{
string projectPath = arguments.GetProperty("projectPath").GetString();

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling GetString() without null check may throw if the "projectPath" property is missing or null. Consider using GetString() ?? throw new ArgumentException("projectPath is required") or add explicit validation.

Suggested change
string projectPath = arguments.GetProperty("projectPath").GetString();
string projectPath = arguments.GetProperty("projectPath").GetString() ?? throw new ArgumentException("projectPath is required");

Copilot uses AI. Check for mistakes.
Comment on lines +330 to +343
private string GetUpgradeSeverity(NuGetVersion resolved, NuGetVersion latest)
{
if (latest == null || resolved == null)
return "Unknown";

if (latest.Major > resolved.Major || resolved.IsPrerelease)
return "Major";
if (latest.Minor > resolved.Minor)
return "Minor";
if (latest.Patch > resolved.Patch || latest.Revision > resolved.Revision)
return "Patch";

return "None";
}

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method uses nullable parameters but doesn't have nullable annotations (NuGetVersion?). Since the method checks for null at line 332, the parameters should be declared as nullable to match the implementation.

Copilot uses AI. Check for mistakes.
return;
}

object result = null;

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable result is initialized with null but should have an explicit type or be declared as object? to be nullable. This can cause a warning in some compiler configurations.

Suggested change
object result = null;
object? result = null;

Copilot uses AI. Check for mistakes.
Comment thread src/DotNetOutdated/McpServer.cs Resolved
"System.Xml.XPath": "4.0.1",
"System.Xml.XmlDocument": "4.0.1"
}
}

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entire "net8.0/linux-x64" runtime dependencies section has been removed. This appears to be cleanup, but ensure this doesn't affect test scenarios that depend on these platform-specific packages. Verify that tests still pass on Linux x64 platforms.

Suggested change
}
}
},
"net8.0/linux-x64": {
"runtime": {
// TODO: Restore actual runtime dependencies here.
// Example placeholder:
// "Some.Linux.Specific.Package": {
// "type": "Transitive",
// "resolved": "1.0.0",
// "contentHash": "PLACEHOLDER"
// }
}

Copilot uses AI. Check for mistakes.
Comment on lines +388 to +395
else
{
return new
{
content = new[] { new { type = "text", text = $"Failed to update package: {status.Errors}" } },
isError = true
};
}

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both branches of this 'if' statement return - consider using '?' to express intent better.

Suggested change
else
{
return new
{
content = new[] { new { type = "text", text = $"Failed to update package: {status.Errors}" } },
isError = true
};
}
return new
{
content = new[] { new { type = "text", text = $"Failed to update package: {status.Errors}" } },
isError = true
};

Copilot uses AI. Check for mistakes.
@slang25

slang25 commented Dec 12, 2025

Copy link
Copy Markdown
Member

This is really cool, and I hadn't considered it for dotnet-outdated, but it would be a great fit.

My instinct is that this would be packaged up as a dedicated tool, however I can't think of a technical reason for this. Is there precedent for other similar dotnet tools combining a MCP server mode into their existing tool out of interest? (I don't think we should make the decision based on that, I'm just curious)

slang25 and others added 3 commits February 8, 2026 12:20
Restores the original CRLF line endings in DotNetOutdated.sln and
restores the accidentally deleted packages.lock.json file.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Per the JSON-RPC 2.0 spec, result and error should be mutually
exclusive in responses rather than both always being present.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@slang25

slang25 commented Feb 8, 2026

Copy link
Copy Markdown
Member

Sorry for the slow response, this is a great addition (even if Skills is now the new hotness 😅 )
Thanks @spboyer

@slang25
slang25 merged commit 7606010 into master Feb 8, 2026
6 checks passed
slang25 added a commit that referenced this pull request Feb 14, 2026
- Implement Model Context Protocol (MCP) server (#696)
- Make dotnet command timeout configurable (#701)
- Remove specialized code for Central Package Management (#697)
- Fix warning (#667)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create MCP server to support LLM-based agent assistance for .NET development

3 participants