Skip to main content
Glama

open_with_app

Open files or folders directly with a specified application on macOS, streamlining access and improving workflow efficiency.

Instructions

Open a file or folder with a specific application

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appNameYes
filePathYes

Implementation Reference

  • Implements the core logic to open a file with a specified macOS application using the 'open -a' command.
    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; } }
  • Zod schema for input validation of the open_with_app tool.
    export const OpenWithAppInputSchema = { appName: z.string(), filePath: z.string(), };
  • tools.ts:76-101 (registration)
    Registers the open_with_app tool with name, description, annotations, schema reference, and callback that invokes the handler.
    const openWithAppConfig: ToolConfig<typeof OpenWithAppInputSchema> = { name: "open_with_app", description: "Open a file or folder with a specific application", annotations: { title: "用應用程式開啟檔案", readOnlyHint: false, // 會修改系統狀態 destructiveHint: false, // 不執行破壞性操作 idempotentHint: false, // 重複開啟可能有不同結果 openWorldHint: true, // 與外部應用程式和檔案互動 }, schema: OpenWithAppInputSchema, cb: async (args) => { const success = await openWithApp(args.appName, args.filePath); const toolResult: CallToolResult = { content: [ { type: "text", text: success ? "File opened successfully" : "Failed to open file with application", }, ], }; return toolResult; }, };

Other Tools

Related Tools

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/eugenechen0514/mac-apps-launcher'

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