import { getLogger } from "../logger.js";
import { extractComposioServerId, isComposioMCPServerAuthenticated } from "./composio-client.js";

//#region src/utils/third-party-mcp-servers/third-party-check.ts
/**
* Third-Party MCP Server Authentication Check
* Generic interface for checking authentication status of third-party MCP servers
*/
const logger = getLogger("third-party-check");
/**
* Check if a third-party MCP server is authenticated for the given tenant/project/user
* This is a generic function that routes to the appropriate provider-specific check
* @param credentialScope - 'project' for shared team credentials, 'user' for per-user credentials
* @param userId - The actual user ID (required if credentialScope is 'user')
*/
async function isThirdPartyMCPServerAuthenticated(tenantId, projectId, mcpServerUrl, credentialScope = "project", userId) {
	if (extractComposioServerId(mcpServerUrl)) {
		logger.debug({ mcpServerUrl }, "Detected Composio MCP server, checking auth status");
		return isComposioMCPServerAuthenticated(tenantId, projectId, mcpServerUrl, credentialScope, userId);
	}
	logger.info({ mcpServerUrl }, "Unknown third-party MCP server provider");
	return { authenticated: false };
}

//#endregion
export { isThirdPartyMCPServerAuthenticated };