<?php

declare(strict_types=1);

myronSendMcpOAuthNoStoreHeaders();
header('Content-Type: application/json; charset=utf-8');
header('X-Content-Type-Options: nosniff');

$path = myronResolveAppRequestPath((string) ($_SERVER['REQUEST_URI'] ?? '/'));
$metadata = myronMcpOAuthMetadataService();

if ($path === '/.well-known/oauth-authorization-server') {
    echo json_encode($metadata->authorizationServerMetadata(), JSON_UNESCAPED_SLASHES);
    return;
}

if ($path === '/.well-known/oauth-protected-resource' || str_starts_with($path, '/.well-known/oauth-protected-resource/')) {
    echo json_encode($metadata->protectedResourceMetadata(), JSON_UNESCAPED_SLASHES);
    return;
}

http_response_code(404);
echo json_encode(['error' => 'not_found'], JSON_UNESCAPED_SLASHES);

