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";
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action but lacks details on permissions needed, what happens if no files are selected, whether it returns paths or file objects, or any error conditions. This is inadequate for a tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise and front-loaded in a single sentence, with zero wasted words. It efficiently communicates the core purpose without unnecessary elaboration, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., file paths, metadata), error handling, or dependencies like requiring Finder to be active. For a tool with no structured data support, this leaves significant gaps in understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters with 100% schema description coverage, so the schema fully documents the lack of inputs. The description doesn't need to add parameter details, and it correctly implies no inputs are required by not mentioning any. A baseline of 4 is appropriate for zero-parameter tools.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and resource ('currently selected files in Finder'), making the tool's purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'finder_search_files' or 'finder_quick_look_file', which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., Finder must be open), exclusions, or comparisons to other file-related tools in the sibling list, leaving usage context unclear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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