Method HasCapability
HasCapability(McpServerCapabilities)
Checks whether the server supports a specific capability.
public bool HasCapability(McpServerCapabilities capability)
Parameters
capabilityMcpServerCapabilitiesThe capability to check for (e.g., Tools).
Returns
- bool
trueif the server supports the specified capability; otherwise,false.
Examples
if (client.HasCapability(McpServerCapabilities.Resources))
{
var resources = await client.ListResourcesAsync();
}
else
{
Console.WriteLine("This server doesn't support resources.");
}
Remarks
This is a convenience method for checking capabilities. It's equivalent to checking the ServerCapabilities property with a bitwise AND operation.
Always returns false before the client is initialized. Call InitializeAsync(CancellationToken)
first to populate the server capabilities.