Skip to main content
Glama
ApiKey.kt1.36 kB
package maestro.auth import java.nio.file.Paths import kotlin.io.path.deleteIfExists import kotlin.io.path.exists import kotlin.io.path.isDirectory import kotlin.io.path.readText class ApiKey { companion object { private val cachedAuthTokenFile by lazy { Paths.get( System.getProperty("user.home"), ".mobiledev", "authtoken" ) } private fun maestroCloudApiKey(): String? { return System.getenv("MAESTRO_CLOUD_API_KEY") } private fun getCachedAuthToken(): String? { if (!cachedAuthTokenFile.exists()) return null if (cachedAuthTokenFile.isDirectory()) return null val cachedAuthToken = cachedAuthTokenFile.readText() return cachedAuthToken } fun getToken(): String? { return maestroCloudApiKey() ?: // Resolve API key from shell if set getCachedAuthToken() // Otherwise, if the user has already logged in, use the cached auth token } fun setToken(token: String?) { cachedAuthTokenFile.parent.toFile().mkdirs() if (token == null) { cachedAuthTokenFile.deleteIfExists() return } cachedAuthTokenFile.toFile().writeText(token) } } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mobile-dev-inc/Maestro'

If you have feedback or need assistance with the MCP directory API, please join our Discord server