We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/eugenechen0514/mac-apps-launcher'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
import { readdir } from "fs/promises";
import { join } from "path";
import { exec } from "child_process";
import { promisify } from "util";
const execAsync = promisify(exec);
export async function listApplications(): Promise<string[]> {
try {
const files = await readdir("/Applications");
return files.filter((file) => file.endsWith(".app")).sort();
} catch (error) {
console.error("Error listing applications:", error);
return [];
}
}
export async function launchApp(appName: string): Promise<boolean> {
try {
const fullAppName = appName.endsWith(".app") ? appName : `${appName}.app`;
const appPath = join("/Applications", fullAppName);
await execAsync(`open "${appPath}"`);
return true;
} catch (error) {
console.error("Error launching application:", error);
return false;
}
}
export async function openWithApp(
appName: string,
filePath: string
): Promise<boolean> {
try {
const fullAppName = appName.endsWith(".app") ? appName : `${appName}.app`;
const appPath = join("/Applications", fullAppName);
await execAsync(`open -a "${appPath}" "${filePath}"`);
return true;
} catch (error) {
console.error("Error opening file with application:", error);
return false;
}
}