Server context Vs Location context

Is there any way to check in a command’s set function if the command was
invoked i.e. the command was called from server context or location
context. For example, if I write a command that can be used both in
server
context and location context, is there a way to differentiate from where
it
was called in my function that sets up the configuration?