Skip to main content
Glama

finder_get_selected_files

Retrieve the currently selected files in macOS Finder to access file paths for automation workflows.

Instructions

[Finder and file operations] Get currently selected files in Finder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • AppleScript handler implementation for the 'get_selected_files' script in the 'finder' category, executed as the tool 'finder_get_selected_files'.
    { name: "get_selected_files", description: "Get currently selected files in Finder", script: ` tell application "Finder" try set selectedItems to selection if selectedItems is {} then return "No items selected" end if set itemPaths to "" repeat with theItem in selectedItems set itemPaths to itemPaths & (POSIX path of (theItem as alias)) & linefeed end repeat return itemPaths on error errMsg return "Failed to get selected files: " & errMsg end try end tell `, },
  • Registration of tools where each script is listed with name constructed as '{category.name}_{script.name}', creating 'finder_get_selected_files'.
    tools: this.categories.flatMap((category) => category.scripts.map((script) => ({ name: `${category.name}_${script.name}`, // Changed from dot to underscore description: `[${category.description}] ${script.description}`, inputSchema: script.schema || { type: "object", properties: {}, }, })), ),
  • Core handler logic for parsing tool name 'finder_get_selected_files', extracting category 'finder' and script 'get_selected_files', and locating the script for execution.
    // Split on underscore instead of dot const [categoryName, ...scriptNameParts] = toolName.split("_"); const scriptName = scriptNameParts.join("_"); // Rejoin in case script name has underscores const category = this.categories.find((c) => c.name === categoryName); if (!category) { this.log("warning", "Category not found", { categoryName }); throw new McpError( ErrorCode.MethodNotFound, `Category not found: ${categoryName}`, ); } const script = category.scripts.find((s) => s.name === scriptName); if (!script) { this.log("warning", "Script not found", { categoryName, scriptName }); throw new McpError( ErrorCode.MethodNotFound, `Script not found: ${scriptName}`, ); }
  • src/index.ts:27-27 (registration)
    Server registration of the finder category, which includes the get_selected_files script.
    server.addCategory(finderCategory);
  • src/index.ts:4-4 (registration)
    Import of the finder category containing the tool implementation.
    import { finderCategory } from "./categories/finder.js";

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/joshrutkowski/applescript-mcp'

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