Skip to main content
Glama

finder_get_selection

Retrieve currently selected files and folders in macOS Finder to enable AI agents to access and manage user-selected items for automation tasks.

Instructions

Get currently selected files/folders in Finder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main handler for 'finder_get_selection' tool. Executes AppleScript via osascript to get Finder's current selection as alias list, processes stderr for errors, handles empty selection, parses aliases into friendly file/directory names (handling directories and .localized), and returns formatted list of selected items.
    case 'finder_get_selection':
      try {
        const command = `osascript -e 'tell application "Finder" to get selection as alias list'`;
        const { stdout, stderr } = await execAsync(command);
        
        if (stderr.trim()) {
          return {
            content: [
              {
                type: 'text',
                text: `Error getting Finder selection: ${stderr.trim()}`,
              },
            ],
          };
        }
        
        const output = stdout.trim();
        if (!output || output === '') {
          return {
            content: [
              {
                type: 'text',
                text: 'No files selected in Finder',
              },
            ],
          };
        }
        
        // Process AppleScript aliases to user-friendly names
        const aliases = output.split(', ');
        const friendlyNames = aliases.map(alias => {
          // Extract filename from alias path
          const pathParts = alias.replace('alias ', '').split(':');
          
          // Check if it's a directory (ends with colon, creates empty last element)
          const isDirectory = alias.endsWith(':');
          
          let filename;
          if (isDirectory) {
            // For directories: take second-to-last element (last is empty from trailing colon)
            filename = pathParts[pathParts.length - 2];
          } else {
            // For files: take last element
            filename = pathParts[pathParts.length - 1];
          }
          
          // Remove .localized suffix if present
          if (filename && filename.endsWith('.localized')) {
            filename = filename.replace('.localized', '');
          }
          
          return isDirectory ? `${filename}/` : filename;
        });
        
        return {
          content: [
            {
              type: 'text',
              text: `Selected items (${friendlyNames.length}):\n${friendlyNames.join('\n')}`,
            },
          ],
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: 'text',
              text: `Error executing Finder selection command: ${error.message}`,
            },
          ],
        };
      }
  • src/index.ts:52-59 (registration)
    Tool registration in ListToolsRequestSchema handler, defines name, description, and empty inputSchema (no parameters required).
    {
      name: 'finder_get_selection',
      description: 'Get currently selected files/folders in Finder',
      inputSchema: {
        type: 'object',
        properties: {},
      },
    },
  • Input schema for finder_get_selection: empty object (no input parameters).
    inputSchema: {
      type: 'object',
      properties: {},
    },
  • Test invocation of finder_get_selection tool, notes it requires manual Finder selection.
    // finder_get_selection requires manual selection, skipping or expecting empty
    await testTool('finder_get_selection');
Behavior2/5

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

With no annotations provided, the description carries full burden but only states what the tool does without behavioral details. It doesn't disclose if this requires specific permissions, how it handles no selection, or what the return format is (e.g., list of paths), which is critical for a tool with no output schema.

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 a single, efficient sentence with zero waste—it directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy for an agent 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 no annotations and no output schema, the description is incomplete for effective tool use. It lacks details on return values (e.g., format, handling of empty selections) and behavioral context, which are essential for an agent to invoke this tool correctly without trial and error.

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, and schema description coverage is 100%, so no parameter information is needed. The description correctly avoids discussing parameters, aligning with the empty input schema, which justifies a baseline score of 4 for this dimension.

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 verb ('Get') and resource ('currently selected files/folders in Finder'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'finder_get_current_folder', which retrieves a different Finder state, so it misses the highest 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?

No guidance is provided on when to use this tool versus alternatives. The description implies usage when needing the current Finder selection, but it doesn't specify prerequisites (e.g., Finder must be active) or compare to siblings like 'finder_get_current_folder' for context, leaving the agent to infer usage.

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/samicokar/mcp-mac'

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