-
Notifications
You must be signed in to change notification settings - Fork 237
Handle requests for capabilty, when capability not present #290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Handle requests for capabilty, when capability not present #290
Conversation
This part seems good. I agree that the server should not emit error logs just because a client is behaving improperly.
This seems problematic. Have you tried calling csharp-sdk/src/ModelContextProtocol/Shared/McpSession.cs Lines 159 to 165 in 0c9e91f
|
ba89760
to
92f7112
Compare
Ah, ok! Thanks. So it might be better to do respond with an I cannot throw, since that's tied together with the problematic error log level.
+++ await SendMessageAsync(new JsonRpcError
+++ {
+++ Id = request.Id,
+++ JsonRpc = "2.0",
+++ Error = detail,
+++ RelatedTransport = request.RelatedTransport,
+++ }, cancellationToken).ConfigureAwait(false);
--- await _transport.SendMessageAsync(new JsonRpcNotification
---{
--- JsonRpc = "2.0",
--- Method = NotificationMethods.LoggingMessageNotification,
--- Params = new JsonObject
--- {
--- ["message"] = $"{EndpointName} lacks capability to do {request.Method}",
--- ["requestId"] = request.Id.ToString(),
--- ["type"] = nameof(BadRequest)
--- }
---}, cancellationToken).ConfigureAwait(false);
---return;
No, I did not do a manual regression test. All automated tests pass when I do |
92f7112
to
21833b9
Compare
Will also lower log level from err to wrn Scenario: ex: Claude Desktop polls for `/resources/list` even though `resources` is missing from the `capabilities`
21833b9
to
91959fa
Compare
Updated the code to respond with |
How does this surface now if the client calls something like |
Not sure I can assert that the log level is reduced, but I have not changed any behaviour. Is there a missing test from before, I'll happily add it. Where do you want it? Before the change:
After the change
|
Motivation and Context
Some clients ignore the capabilities, and sends
<capability>/list
requests regardless (ex: Claude Desktop).ex: Claude Desktop polls for
/resources/list
even thoughresources
is missing from thecapabilities
. The C# SDK throws exceptions and logs as ERROR statements. This PR changes this to just return theMethodNotFound
error code over JSON-RPC, and log as a warning instead of error.Relevant discussion: #74 (comment)
How Has This Been Tested?
Use Claude Desktop
Ran all tests
Breaking Changes
No
Types of changes
Checklist
Additional context