modelcontextprotocol / modelcontextprotocol/csharp-sdk

Optional exception summarization for server-side logging

Open
#1,690 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement P3 ready for work
Dominant language
C#
Stars
4.5k
Forks
814
Avg merge
9d 19h
Merged PRs (30d)
4

Description

Summary

Add an opt-in way to sanitize/summarize exception content in logs using the standard .NET Microsoft.Extensions.Diagnostics.ExceptionSummarization abstractions (IExceptionSummarizer / ExceptionSummary).

Motivation

Today, exceptions are logged by passing Exception instances to ILogger logger-message methods on failure paths (notably request handler failures and outer message-handler failures).
Many logging providers render exception message + stack trace, which can include sensitive or overly detailed runtime data.

Hosts currently can customize providers/sinks, but there isn’t an SDK-level opt-in to use the .NET exception summarization abstraction directly at these logging callsites. Supporting that would make privacy/safety-oriented logging easier and more consistent in production environments.

Proposed behavior

If no summarizer is configured: keep current behavior (log raw exception as today).
If an IExceptionSummarizer is configured: log summarized/sanitized description (e.g., ExceptionSummary.Description) on the relevant exception logging paths instead of passing the raw exception object for those paths.

Why this helps

Enables centralized privacy/safety controls for logs at a common server hot path.
Aligns with existing .NET diagnostics abstractions instead of introducing MCP-specific logging contracts.
Keeps compatibility by remaining opt-in and preserving default behavior.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the ILogger callsites for request handler failures and outer message-handler failures, then review the IExceptionSummarizer and ExceptionSummary abstractions. When configured, those paths should log the summarized description; without a summarizer, raw exception logging should remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, observability-sre
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.