use axum::{Json, http::StatusCode, response::IntoResponse};
use serde_json::json;
pub async fn authorization_server_metadata() -> impl IntoResponse {
let base_url =
std::env::var("BASE_URL").unwrap_or_else(|_| "http://localhost:3000".to_string());
let metadata = json!({
"issuer": base_url,
"registration_endpoint": format!("{}/oauth/register", base_url),
"authorization_endpoint": format!("{}/oauth/authorize", base_url),
"token_endpoint": format!("{}/oauth/token", base_url),
"response_types_supported": ["code"],
"grant_types_supported": ["authorization_code", "refresh_token"],
"code_challenge_methods_supported": ["S256"],
"scopes_supported": [
"mcp:read",
"mcp:write",
"mcp:tools",
"mcp:resources",
"mcp:prompts"
],
"token_endpoint_auth_methods_supported": ["client_secret_post"],
"resource_indicators_supported": true,
});
(StatusCode::OK, Json(metadata)).into_response()
}