| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | namespace Nexus\Mcp\Client\Exception; |
| 15: | |
| 16: | use Nexus\Mcp\Core\Exception\McpExceptionInterface; |
| 17: | use Nexus\Mcp\Core\SafeDisplay; |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | final class InsufficientScopeException extends \RuntimeException implements McpExceptionInterface |
| 25: | { |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | public function __construct( |
| 31: | public readonly array $required, |
| 32: | bool $named = false, |
| 33: | ) { |
| 34: | parent::__construct(match (true) { |
| 35: | [] !== $required => \sprintf('The MCP server requires the scope "%s".', SafeDisplay::sanitiseCause(implode(' ', $required))), |
| 36: | $named => 'The MCP server named only scopes that are not RFC 6749 scope-tokens, so none can be requested.', |
| 37: | default => 'The MCP server answered insufficient_scope without naming a scope.', |
| 38: | }); |
| 39: | } |
| 40: | } |
| 41: | |