Skip to content

MCP Server Stdio transport: configure all logs to go to stderr - #3959

Merged
marcschier merged 8 commits into
OPCFoundation:masterfrom
jjell:master
Jul 7, 2026
Merged

MCP Server Stdio transport: configure all logs to go to stderr#3959
marcschier merged 8 commits into
OPCFoundation:masterfrom
jjell:master

Conversation

@jjell

@jjell jjell commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Description

In the Stdio transport mode of the MCP server, logging is redirected to stderr in order to avoid deserialization exceptions when calling tools

Related Issues

Checklist

Put an x in the boxes that apply. You can complete these step by step after opening the PR.

  • I have signed the CLA and read the CONTRIBUTING doc.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added all necessary documentation.
  • I have verified that my changes do not introduce (new) build or analyzer warnings.
  • I ran all tests locally using the UA.slnx solution against at least .net framework and .net 10, and all passed.
  • I fixed all failing and flaky tests in the CI pipelines and all CodeQL warnings.
  • I have addressed all PR feedback received.

Copilot AI review requested due to automatic review settings July 5, 2026 18:03
@CLAassistant

CLAassistant commented Jul 5, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

Updates the MCP Server’s stdio transport behavior to avoid tool deserialization issues by ensuring logs are written to stderr instead of stdout.

Changes:

  • Configures console logging to route all log levels to stderr via LogToStandardErrorThreshold.
  • Minor reordering of using directives.

Comment thread Applications/McpServer/Program.cs Outdated
Comment thread Applications/McpServer/Program.cs Outdated
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.20%. Comparing base (5204906) to head (981dff7).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3959      +/-   ##
==========================================
- Coverage   76.21%   76.20%   -0.01%     
==========================================
  Files        1202     1202              
  Lines      171601   171601              
  Branches    29666    29666              
==========================================
- Hits       130778   130769       -9     
- Misses      29778    29794      +16     
+ Partials    11045    11038       -7     

see 24 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@marcschier marcschier left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please fix the review comments, the ConfigureLogging is probably the better place to conditionally change the logging to stderr (when stdio is configured)

Comment thread Applications/McpServer/Program.cs Outdated
Comment thread Applications/McpServer/Program.cs
@marcschier marcschier added the ready Ready to merge once CI Passes label Jul 6, 2026
@marcschier

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@marcschier
marcschier merged commit 76aa837 into OPCFoundation:master Jul 7, 2026
175 checks passed
marcschier added a commit to marcschier/UA-.NETStandard that referenced this pull request Jul 9, 2026
Brings in 5 upstream commits: OPCFoundation#3957 (expand DI/Fluent API injectability +
one-shot ergonomics across client/server/PubSub/discovery/bindings),
OPCFoundation#3968 (fix false-positive MODELGEN010), OPCFoundation#3966 (fix source generator
dropping BaseAnalogType EURange/EngineeringUnits), OPCFoundation#3949 (Apache Kafka
PubSub transport, Part 14 Annex B.2), and OPCFoundation#3959 (MCP server stdio logs
to stderr).

Resolved one conflict in Directory.Packages.props (three regions), all
from our UaLens-specific package entries interleaving with upstream's
new Kafka dependency and a Microsoft.Extensions.* version bump:

 * Kept CommunityToolkit.Mvvm 8.4.2 and added upstream's new
   Confluent.Kafka 2.15.0.
 * Accepted upstream's Microsoft.Extensions.* bump (10.0.8 -> 10.0.9,
   10.6.0 -> 10.7.0) while re-inserting our
   Microsoft.Extensions.Diagnostics.ResourceMonitoring 10.5.0 (a UaLens
   dependency absent from master) in alphabetical position.
 * Kept ScottPlot.Avalonia 5.1.58 and took upstream's SharpFuzz
   2.2.0 -> 2.3.0 bump.

UA.slnx auto-merged and retained our McpServer project path.

UaLens build clean (0 warnings / 0 errors).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready Ready to merge once CI Passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP Server Stdio transport: deserialization exceptions due to logging to stdout

4 participants