Propagate tool call exceptions through filters (#844)

* Add McpProtocolException specifically for JSON-RPC errors
This commit is contained in:
Stephen Halter 2025-10-14 21:10:55 -05:00 • committed by GitHub
commit 3255adb4d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -207,7 +207,7 @@ McpServerOptions options = new()
{
if (request.Params.Arguments?.TryGetValue("message", out var message) is not true)
{
throw new McpException("Missing required argument 'message'");
throw new McpProtocolException("Missing required argument 'message'", McpErrorCode.InvalidParams);
}
return ValueTask.FromResult(new CallToolResult
@ -216,7 +216,7 @@ McpServerOptions options = new()
});
}
throw new McpException($"Unknown tool: '{request.Params?.Name}'");
throw new McpProtocolException($"Unknown tool: '{request.Params?.Name}'", McpErrorCode.InvalidRequest);
}
}
};