modelcontextprotocol / modelcontextprotocol/csharp-sdk

Custom filters

Open
#1,314 0 comments 1 reaction 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

Is your feature request related to a problem? Please describe.

Cancellation token is throwing error which can be handled graceful way like described here

https://andrewlock.net/using-cancellationtokens-in-asp-net-core-mvc-controllers/

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddMvc(options =>
        {
            options.Filters.Add<OperationCancelledExceptionFilter>();
        });
    }
}

Describe the solution you'd like

It would be nice to add custom filter

builder.Services.AddMcpServer(options =>
        {
            options.Filters.Add<OperationCancelledExceptionFilter>();
        })

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

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 reviewing the AddMcpServer options entry point and how cancellation exceptions are currently handled in the server pipeline. Define how a custom OperationCancelledExceptionFilter can be registered there and verify that cancellation is handled gracefully without producing the current error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.