We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/damms005/devdb-vscode'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
import { getWorkspaceFileContent } from "../workspace";
/**
* Returns the hostname portion of the APP_URL environment variable.
*/
export async function getHostname(): Promise<string | undefined> {
const appUrl = await getEnvFileValue('APP_URL')
if (!appUrl) return
const appUrlWithoutQuotes = appUrl.replace(/"/g, '')
const appUrlWithoutTrailingSlash = appUrlWithoutQuotes.endsWith('/')
? appUrlWithoutQuotes.substring(0, appUrlWithoutQuotes.length - 1)
: appUrlWithoutQuotes
const appUrlWithoutProtocol = appUrlWithoutTrailingSlash.replace(/https?:\/\//, '')
const appUrlWithoutPort = appUrlWithoutProtocol.replace(/:\d+/, '')
return appUrlWithoutPort
}
export async function getEnvFileValue(envFileKey: string): Promise<string | undefined> {
const envFileContents = getWorkspaceFileContent('.env')?.toString()
if (!envFileContents) return
const lines = envFileContents.split('\n');
const appUrlLine = lines.find((line: string) => line.startsWith(`${envFileKey}=`))
if (!appUrlLine) return
const appUrl = appUrlLine.substring(appUrlLine.indexOf('=') + 1)
const appUrlWithoutQuotes = appUrl.replace(/"/g, '')
const appUrlWithoutTrailingSlash = appUrlWithoutQuotes.endsWith('/')
? appUrlWithoutQuotes.substring(0, appUrlWithoutQuotes.length - 1)
: appUrlWithoutQuotes
const appUrlWithoutProtocol = appUrlWithoutTrailingSlash.replace(/https?:\/\//, '')
const appUrlWithoutPort = appUrlWithoutProtocol.replace(/:\d+/, '')
return appUrlWithoutPort.trim()
}