Skill: roaycl/eagle-skill (version 1.0.0)

--- name: eagle description: Control Eagle application for digital asset management - search, organize, tag items, manage folders and tag groups. Use when user wants to interact with their Eagle library, search for images, manage tags or folders. allowed-tools: Bash(node *) --- # Eagle API Skill Control the local Eagle application through CLI commands. Eagle is a digital asset management tool for organizing images, videos, fonts, and design files. ## Prerequisites - Eagle application must be running - Eagle MCP plugin must be enabled (provides the local API server on port 41596) ## CLI Usage The CLI script is located at `scripts/eagle-api-cli.js` relative to this skill directory. ```bash # Call a tool with JSON parameters node scripts/eagle-api-cli.js call <tool_name> --json '{"key": "value"}' # Call a tool with individual parameters node scripts/eagle-api-cli.js call <tool_name> --param1 value1 --param2 value2 # List all available tools node scripts/eagle-api-cli.js list # Get help for a specific tool node scripts/eagle-api-cli.js help <tool_name> ``` Array and object values are auto-parsed from JSON: ```bash node scripts/eagle-api-cli.js call item_get --tags '["photo","landscape"]' --limit 10 ``` ## Tool Categories Choose the relevant reference file for detailed tool documentation: - **App** — Get Eagle app info (version, platform, locale). See [references/app-tools.md](references/app-tools.md) - **Item** — Search, filter, add, update, tag, and organize library items. See [references/item-tools.md](references/item-tools.md) - **Folder** — Create, query, and update folder hierarchy. See [references/folder-tools.md](references/folder-tools.md) - **Tag** — Query, count, rename, and merge tags. See [references/tag-tools.md](references/tag-tools.md) - **Tag Group** — Manage tag groups and tag associations. See [references/tag-group-tools.md](references/tag-group-tools.md) - **AI Search** — Semantic search by text or similar items (requires AI Search plugin). See [references/ai-search-tools.md](references/ai-search-tools.md) ## Common Workflows ### Search for items ```bash # Text search node scripts/eagle-api-cli.js call item_query --query "sunset landscape" # Filter by tags and extension node scripts/eagle-api-cli.js call item_get --tags '["photo"]' --ext "jpg" --limit 20 # Get selected items in Eagle node scripts/eagle-api-cli.js call item_get_selected ``` ### Organize items ```bash # Add tags to items node scripts/eagle-api-cli.js call item_add_tags --json '{"ids": ["item1", "item2"], "tags": ["reviewed", "approved"]}' # Move items to folders node scripts/eagle-api-cli.js call item_add_to_folders --json '{"ids": ["item1"], "folders": ["folder_id"]}' # Create a new folder node scripts/eagle-api-cli.js call folder_create --json '{"folders": [{"name": "My Folder", "iconColor": "blue"}]}' ``` ### Tag management ```bash # List all tags node scripts/eagle-api-cli.js call tag_get # Merge duplicate tags node scripts/eagle-api-cli.js call tag_merge --json '{"sourceTags": ["photo", "photograph"], "targetTag": "photo"}' ```

path: references/ai-search-tools.md
content: # Ai Search Tools

AI-powered semantic search (requires AI Search plugin)

## ai_search_status

Check AI Search plugin availability and status. Returns whether the plugin is installed, ready, starting, or syncing. This tool never fails — it always returns status information even if the plugin is not installed.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|

### Example

```bash
node scripts/eagle-api-cli.js call ai_search_status
```

## ai_search_by_text

Semantic search for Eagle items using natural language. Uses AI embeddings for meaning-based search rather than keyword matching. Requires the AI Search plugin to be installed and ready.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| query | string | Yes | Natural language search query for semantic search (e.g., 'sunset over ocean', 'minimalist logo') |
| limit | number | No | Maximum number of results to return (default: 20, max: 100) |
| fullDetails | boolean | No | Return complete item details (default: false, returns only core fields + score) |

### Example

```bash
node scripts/eagle-api-cli.js call ai_search_by_text --json '{"query":"cat"}'
```

## ai_search_by_item

Find visually similar items to an existing Eagle item using AI. Provide an item ID from your Eagle library to discover similar images. Requires the AI Search plugin to be installed and ready.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| itemId | string | Yes | Eagle item ID to find similar items for |
| limit | number | No | Maximum number of results to return (default: 20, max: 100) |
| fullDetails | boolean | No | Return complete item details (default: false, returns only core fields + score) |

### Example

```bash
node scripts/eagle-api-cli.js call ai_search_by_item --json '{"itemId":"<string>"}'
```


path: references/app-tools.md
content: # App Tools

Application information and system details

## get_app_info

Retrieves Eagle application information including version, build number, and system details. Provides comprehensive application metadata for debugging and compatibility checks. Supports both full information retrieval and specific property queries.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| property | string | No | Optional application property to retrieve (e.g., version, build, locale, arch, platform, theme) |

### Example

```bash
node scripts/eagle-api-cli.js call get_app_info
```


path: references/folder-tools.md
content: # Folder Tools

Folder management - create, query, and update folder hierarchy

## folder_create

Batch create folders with support for nested structures and parent-child relationships. Supports creating multiple folders in one operation, including hierarchical folder trees.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| parentId | string | No | Shared parent folder ID for all folders. Individual folder parentId overrides this value. |
| folders | object[] | Yes | Array of folders to create |

### Example

```bash
node scripts/eagle-api-cli.js call folder_create --json '{"folders":[]}'
```

## folder_get

Retrieve Eagle folders based on various criteria. Supports querying by ID, selected status, recent usage, and hierarchical relationships. Perfect for folder management and organization tasks.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| ids | string[] | No | Array of specific folder IDs |
| isSelected | boolean | No | Retrieve currently selected folders |
| isRecent | boolean | No | Retrieve recently used folders |
| getAllHierarchy | boolean | No | Return complete hierarchical structure |
| fullDetails | boolean | No | Return complete folder information |

### Example

```bash
node scripts/eagle-api-cli.js call folder_get
```

## folder_update

Batch update multiple folders with new properties. Supports updating folder names, descriptions, icon colors, and parent folder assignments. Efficient for reorganizing and maintaining folder structures with visual organization and hierarchy management.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| parentId | string | No | Shared parent folder ID to move all folders under. Individual folder parentId overrides this value. Use null to move to root level. |
| folders | object[] | Yes | Array of folders to update |

### Example

```bash
node scripts/eagle-api-cli.js call folder_update --json '{"folders":[]}'
```


path: references/item-tools.md
content: # Item Tools

Library item management - search, filter, add, update, tag, and organize

## item_query

Smart text search engine with comprehensive query syntax support. Supports complex search patterns like AND/OR/NOT operations, quoted phrases, and field-specific searches. Perfect for finding specific items when you know keywords or search terms.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| query | string | Yes | Search query string with syntax support. Examples: 'cat', 'cat OR dog', '(cute OR adorable) cat -dog' |
| fullDetails | boolean | No | Return complete Item object details (default: false, returns only core fields: id, name, ext, tags, folders, width, height, thumbnailPath, filePath) |

### Example

```bash
node scripts/eagle-api-cli.js call item_query --json '{"query":"cat"}'
```

## item_get

Precision attribute filter for retrieving Eagle library items based on specific criteria. Supports filtering by ID, tags, folders, extensions, ratings, and more. Includes pagination support for large result sets. Use this when you need exact matching against specific item properties.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| ids | string[] | No | Array of specific item IDs to retrieve |
| keywords | string[] | No | Array of keywords to search for |
| ext | string | No | File extension filter (e.g., 'jpg', 'png', 'gif') |
| tags | string[] | No | Array of tags to filter by |
| folders | string[] | No | Array of folder IDs to filter by |
| shape | "square" \| "portrait" \| "landscape" | No | Image shape filter |
| rating | number | No | Star rating filter (0-5 stars) |
| annotation | string | No | Annotation content filter |
| url | string | No | Source URL filter |
| isUnfiled | boolean | No | Retrieve items not in any folder |
| isUntagged | boolean | No | Retrieve items without any tags |
| fullDetails | boolean | No | Return complete item information (default: false) |
| limit | number | No | Maximum number of items to return (default: 100, max: 1000) |
| offset | number | No | Number of items to skip for pagination (default: 0) |

### Example

```bash
node scripts/eagle-api-cli.js call item_get
```

## item_get_selected

Get currently selected items in Eagle application. Perfect for working with items the user has manually selected. Returns empty array if no items are selected.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| fullDetails | boolean | No | Return complete item information (default: false) |

### Example

```bash
node scripts/eagle-api-cli.js call item_get_selected
```

## item_update

Batch update multiple items with new properties. Supports shared parameters (tags, folders, annotation, star) at top level that apply to all items - individual items can override these. Efficient for bulk operations with common metadata.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| tags | string[] | No | Shared tags applied to all items (can be overridden per item) |
| folders | string[] | No | Shared folder IDs applied to all items (can be overridden per item) |
| annotation | string | No | Shared annotation applied to all items (can be overridden per item) |
| star | number | No | Shared star rating applied to all items (can be overridden per item) |
| items | object[] | Yes | Array of items to update, each containing id and properties to update |

### Example

```bash
node scripts/eagle-api-cli.js call item_update --json '{"items":[]}'
```

## item_count

High-performance counting tool for Eagle library items. Supports all the same filter criteria as item_get but returns only the count without loading full item data. Perfect for analytics and overview information.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| id | string | No | Specific item ID to count |
| ids | string[] | No | Array of specific item IDs to count |
| keywords | string[] | No | Array of keywords to search for |
| ext | string | No | File extension filter (e.g., 'jpg', 'png', 'gif') |
| tags | string[] | No | Array of tags to filter by |
| folders | string[] | No | Array of folder IDs to filter by |
| shape | "square" \| "portrait" \| "landscape" | No | Image shape filter |
| rating | number | No | Star rating filter (0-5 stars) |
| annotation | string | No | Annotation content filter |
| url | string | No | Source URL filter |
| isUnfiled | boolean | No | Count items not in any folder |
| isUntagged | boolean | No | Count items without any tags |
| isSelected | boolean | No | Count currently selected items |

### Example

```bash
node scripts/eagle-api-cli.js call item_count
```

## item_add

Unified item addition tool with intelligent source type routing. Supports URL, Base64, file path, and bookmark sources in batch operations. Supports shared parameters (tags, folders, annotation) at top level that apply to all items - individual items can override these. Perfect for batch imports with common metadata.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| tags | string[] | No | Shared tags applied to all items (can be overridden per item) |
| folders | string[] | No | Shared folder IDs applied to all items (can be overridden per item) |
| annotation | string | No | Shared annotation applied to all items (can be overridden per item) |
| items | object[] | Yes | Array of items to add |

### Example

```bash
node scripts/eagle-api-cli.js call item_add --json '{"items":[]}'
```

## item_move_to_trash

Batch move items to trash. Supports moving multiple items at once by providing their IDs. Items moved to trash can be restored from Eagle's trash folder. Use carefully as this affects the library organization.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| ids | string[] | Yes | Array of item IDs to move to trash |

### Example

```bash
node scripts/eagle-api-cli.js call item_move_to_trash --json '{"ids":[]}'
```

## item_add_tags

Incrementally add tags to multiple items without replacing existing tags. All specified items receive the same tags. Tags are merged with existing ones, duplicates are automatically handled.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| ids | string[] | Yes | Array of item IDs |
| tags | string[] | Yes | Tags to add to all specified items |

### Example

```bash
node scripts/eagle-api-cli.js call item_add_tags --json '{"ids":[],"tags":[]}'
```

## item_remove_tags

Incrementally remove specific tags from multiple items without affecting other tags. All specified items have the same tags removed. Non-existent tags are silently ignored.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| ids | string[] | Yes | Array of item IDs |
| tags | string[] | Yes | Tags to remove from all specified items |

### Example

```bash
node scripts/eagle-api-cli.js call item_remove_tags --json '{"ids":[],"tags":[]}'
```

## item_add_to_folders

Incrementally add multiple items to folders without replacing existing folder assignments. All specified items are added to the same folders. Folders are merged with existing ones, duplicates are automatically handled.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| ids | string[] | Yes | Array of item IDs |
| folders | string[] | Yes | Folder IDs to add all specified items to |

### Example

```bash
node scripts/eagle-api-cli.js call item_add_to_folders --json '{"ids":[],"folders":[]}'
```

## item_remove_from_folders

Incrementally remove multiple items from specific folders without affecting other folder assignments. All specified items are removed from the same folders. Non-existent folder assignments are silently ignored.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| ids | string[] | Yes | Array of item IDs |
| folders | string[] | Yes | Folder IDs to remove all specified items from |

### Example

```bash
node scripts/eagle-api-cli.js call item_remove_from_folders --json '{"ids":[],"folders":[]}'
```


path: references/tag-group-tools.md
content: # Tag Group Tools

Tag group management - create, update, delete groups and manage tag associations

## tag_group_create

Create tag groups to organize and categorize tags. Supports custom colors and tag associations for better tag management and visual organization.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| tagGroups | object[] | Yes | Array of tag groups to create |

### Example

```bash
node scripts/eagle-api-cli.js call tag_group_create --json '{"tagGroups":[]}'
```

## tag_group_get

Retrieve tag groups by ID or name. Perfect for managing tag organization and retrieving group information with associated tags.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| ids | string[] | No | Array of specific tag group IDs |
| names | string[] | No | Array of specific tag group names |
| fullDetails | boolean | No | Return complete tag group information |

### Example

```bash
node scripts/eagle-api-cli.js call tag_group_get
```

## tag_group_update

Update tag group properties including name, color, and associated tags. Supports shared parameters (name, description, color, tags) at top level that apply to all groups - individual groups can override these. Efficient for batch updates with common metadata.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| name | string | No | Shared group name applied to all groups (can be overridden per group) |
| description | string | No | Shared description applied to all groups (can be overridden per group) |
| color | "red" \| "orange" \| "yellow" \| "green" \| "aqua" \| "blue" \| "purple" \| "pink" \| "none" | No | Shared color applied to all groups (can be overridden per group). Use predefined colors or 'none' to clear |
| tags | string[] | No | Shared tags applied to all groups - FULL REPLACEMENT (can be overridden per group). For incremental changes, use tag_group_add_tags / tag_group_remove_tags |
| tagGroups | object[] | Yes | Array of tag groups to update, each containing id and optional override properties |

### Example

```bash
node scripts/eagle-api-cli.js call tag_group_update --json '{"tagGroups":[]}'
```

## tag_group_delete

Delete tag groups by ID. This removes the grouping but does not delete the actual tags. Use carefully as this operation cannot be undone.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| ids | string[] | Yes | Array of tag group IDs to delete |

### Example

```bash
node scripts/eagle-api-cli.js call tag_group_delete --json '{"ids":[]}'
```

## tag_group_add_tags

Incrementally add or move tags to tag groups. Use removeFromSource=true to move tags (removes from original groups), or false to just add (tags can exist in multiple groups). Much more efficient than updating the entire tags array.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| operations | object[] | Yes | Array of add tags operations |

### Example

```bash
node scripts/eagle-api-cli.js call tag_group_add_tags --json '{"operations":[]}'
```

## tag_group_remove_tags

Remove specific tags from tag groups. This only removes the association between tags and groups - it does not delete the tags themselves or affect items using those tags.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| operations | object[] | Yes | Array of remove tags operations |

### Example

```bash
node scripts/eagle-api-cli.js call tag_group_remove_tags --json '{"operations":[]}'
```


path: references/tag-tools.md
content: # Tag Tools

Tag management - query, count, rename, and merge tags

## tag_get

Query Eagle tags with filtering capabilities. Supports searching by name, usage count, and returns tag statistics. Perfect for tag management and analysis.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| name | string | No | Specific tag name to search for |
| names | string[] | No | Array of specific tag names |
| minCount | number | No | Minimum usage count filter |
| coreFieldsOnly | boolean | No | Return only core fields (name, count) |

### Example

```bash
node scripts/eagle-api-cli.js call tag_get
```

## tag_count

High-performance counting tool for Eagle tags. Returns only the count without loading full tag data. Perfect for analytics, dashboards, and checking tag statistics efficiently.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| minCount | number | No | Only count tags with at least this many items |

### Example

```bash
node scripts/eagle-api-cli.js call tag_count
```

## tag_update

Batch rename tags across the entire Eagle library. This operation affects all items using the renamed tags. Use carefully as changes are global and permanent.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| tags | object[] | Yes | Array of tag rename operations |

### Example

```bash
node scripts/eagle-api-cli.js call tag_update --json '{"tags":[]}'
```

## tag_merge

Merge tags by renaming source tag to target tag. All items using the source tag will be updated to use the target tag. Also updates tag groups, starred tags, and history tags. This operation is irreversible.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| operations | object[] | Yes | Array of tag merge operations |

### Example

```bash
node scripts/eagle-api-cli.js call tag_merge --json '{"operations":[]}'
```


path: scripts/eagle-api-cli.js
content: #!/usr/bin/env node
/**
 * Eagle API CLI - Auto-generated by build-skill.js
 * Zero dependencies — uses only Node.js built-in http module
 *
 * Usage:
 *   node eagle-api-cli.js call <tool> [--param value ...] [--json '{...}']
 *   node eagle-api-cli.js list
 *   node eagle-api-cli.js help <tool>
 *   node eagle-api-cli.js --help
 */

const http = require('http');

// --- Embedded tool metadata (auto-generated, do not edit) ---
const TOOLS = {
  "ai_search_status": {
    "name": "ai_search_status",
    "description": "Check AI Search plugin availability and status. Returns whether the plugin is installed, ready, starting, or syncing. This tool never fails — it always returns status information even if the plugin is not installed.",
    "inputSchema": {
      "type": "object",
      "properties": {},
      "additionalProperties": false
    }
  },
  "ai_search_by_text": {
    "name": "ai_search_by_text",
    "description": "Semantic search for Eagle items using natural language. Uses AI embeddings for meaning-based search rather than keyword matching. Requires the AI Search plugin to be installed and ready.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "query": {
          "type": "string",
          "description": "Natural language search query for semantic search (e.g., 'sunset over ocean', 'minimalist logo')",
          "minLength": 1
        },
        "limit": {
          "type": "number",
          "description": "Maximum number of results to return (default: 20, max: 100)",
          "minimum": 1,
          "maximum": 100
        },
        "fullDetails": {
          "type": "boolean",
          "description": "Return complete item details (default: false, returns only core fields + score)"
        }
      },
      "required": [
        "query"
      ],
      "additionalProperties": false
    }
  },
  "ai_search_by_item": {
    "name": "ai_search_by_item",
    "description": "Find visually similar items to an existing Eagle item using AI. Provide an item ID from your Eagle library to discover similar images. Requires the AI Search plugin to be installed and ready.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "itemId": {
          "type": "string",
          "description": "Eagle item ID to find similar items for",
          "minLength": 1
        },
        "limit": {
          "type": "number",
          "description": "Maximum number of results to return (default: 20, max: 100)",
          "minimum": 1,
          "maximum": 100
        },
        "fullDetails": {
          "type": "boolean",
          "description": "Return complete item details (default: false, returns only core fields + score)"
        }
      },
      "required": [
        "itemId"
      ],
      "additionalProperties": false
    }
  },
  "get_app_info": {
    "name": "get_app_info",
    "description": "Retrieves Eagle application information including version, build number, and system details. Provides comprehensive application metadata for debugging and compatibility checks. Supports both full information retrieval and specific property queries.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "property": {
          "type": "string",
          "description": "Optional application property to retrieve (e.g., version, build, locale, arch, platform, theme)"
        }
      },
      "additionalProperties": false
    }
  },
  "folder_create": {
    "name": "folder_create",
    "description": "Batch create folders with support for nested structures and parent-child relationships. Supports creating multiple folders in one operation, including hierarchical folder trees.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "parentId": {
          "type": "string",
          "description": "Shared parent folder ID for all folders. Individual folder parentId overrides this value."
        },
        "folders": {
          "type": "array",
          "description": "Array of folders to create",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "description": "Folder name",
                "minLength": 1
              },
              "description": {
                "type": "string",
                "description": "Folder description"
              },
              "parentId": {
                "type": "string",
                "description": "Parent folder ID, overrides shared parentId. Leave empty to use shared parentId or create top-level folder"
              },
              "iconColor": {
                "type": "string",
                "enum": [
                  "red",
                  "orange",
                  "yellow",
                  "green",
                  "aqua",
                  "blue",
                  "purple",
                  "pink",
                  "none"
                ],
                "description": "Folder icon color. Use predefined colors (red, orange, yellow, green, aqua, blue, purple, pink) or 'none' to clear color"
              }
            },
            "required": [
              "name"
            ],
            "additionalProperties": false
          },
          "minItems": 1
        }
      },
      "required": [
        "folders"
      ],
      "additionalProperties": false
    }
  },
  "folder_get": {
    "name": "folder_get",
    "description": "Retrieve Eagle folders based on various criteria. Supports querying by ID, selected status, recent usage, and hierarchical relationships. Perfect for folder management and organization tasks.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "ids": {
          "type": "array",
          "description": "Array of specific folder IDs",
          "items": {
            "type": "string",
            "description": ""
          }
        },
        "isSelected": {
          "type": "boolean",
          "description": "Retrieve currently selected folders"
        },
        "isRecent": {
          "type": "boolean",
          "description": "Retrieve recently used folders"
        },
        "getAllHierarchy": {
          "type": "boolean",
          "description": "Return complete hierarchical structure"
        },
        "fullDetails": {
          "type": "boolean",
          "description": "Return complete folder information"
        }
      },
      "additionalProperties": false
    }
  },
  "folder_update": {
    "name": "folder_update",
    "description": "Batch update multiple folders with new properties. Supports updating folder names, descriptions, icon colors, and parent folder assignments. Efficient for reorganizing and maintaining folder structures with visual organization and hierarchy management.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "parentId": {
          "type": "string",
          "description": "Shared parent folder ID to move all folders under. Individual folder parentId overrides this value. Use null to move to root level."
        },
        "folders": {
          "type": "array",
          "description": "Array of folders to update",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "Folder ID",
                "minLength": 1
              },
              "name": {
                "type": "string",
                "description": "New folder name"
              },
              "description": {
                "type": "string",
                "description": "New folder description"
              },
              "iconColor": {
                "type": "string",
                "enum": [
                  "red",
                  "orange",
                  "yellow",
                  "green",
                  "aqua",
                  "blue",
                  "purple",
                  "pink",
                  "none"
                ],
                "description": "Folder icon color. Use predefined colors (red, orange, yellow, green, aqua, blue, purple, pink) or 'none' to clear color"
              },
              "parentId": {
                "type": "string",
                "description": "Parent folder ID to move this folder under. Overrides shared parentId. Use null to move to root level."
              }
            },
            "required": [
              "id"
            ],
            "additionalProperties": false
          },
          "minItems": 1
        }
      },
      "required": [
        "folders"
      ],
      "additionalProperties": false
    }
  },
  "item_query": {
    "name": "item_query",
    "description": "Smart text search engine with comprehensive query syntax support. Supports complex search patterns like AND/OR/NOT operations, quoted phrases, and field-specific searches. Perfect for finding specific items when you know keywords or search terms.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "query": {
          "type": "string",
          "description": "Search query string with syntax support. Examples: 'cat', 'cat OR dog', '(cute OR adorable) cat -dog'",
          "minLength": 1
        },
        "fullDetails": {
          "type": "boolean",
          "description": "Return complete Item object details (default: false, returns only core fields: id, name, ext, tags, folders, width, height, thumbnailPath, filePath)"
        }
      },
      "required": [
        "query"
      ],
      "additionalProperties": false
    }
  },
  "item_get": {
    "name": "item_get",
    "description": "Precision attribute filter for retrieving Eagle library items based on specific criteria. Supports filtering by ID, tags, folders, extensions, ratings, and more. Includes pagination support for large result sets. Use this when you need exact matching against specific item properties.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "ids": {
          "type": "array",
          "description": "Array of specific item IDs to retrieve",
          "items": {
            "type": "string",
            "description": ""
          }
        },
        "keywords": {
          "type": "array",
          "description": "Array of keywords to search for",
          "items": {
            "type": "string",
            "description": ""
          }
        },
        "ext": {
          "type": "string",
          "description": "File extension filter (e.g., 'jpg', 'png', 'gif')"
        },
        "tags": {
          "type": "array",
          "description": "Array of tags to filter by",
          "items": {
            "type": "string",
            "description": ""
          }
        },
        "folders": {
          "type": "array",
          "description": "Array of folder IDs to filter by",
          "items": {
            "type": "string",
            "description": ""
          }
        },
        "shape": {
          "type": "string",
          "enum": [
            "square",
            "portrait",
            "landscape"
          ],
          "description": "Image shape filter"
        },
        "rating": {
          "type": "number",
          "description": "Star rating filter (0-5 stars)",
          "minimum": 0,
          "maximum": 5
        },
        "annotation": {
          "type": "string",
          "description": "Annotation content filter"
        },
        "url": {
          "type": "string",
          "description": "Source URL filter"
        },
        "isUnfiled": {
          "type": "boolean",
          "description": "Retrieve items not in any folder"
        },
        "isUntagged": {
          "type": "boolean",
          "description": "Retrieve items without any tags"
        },
        "fullDetails": {
          "type": "boolean",
          "description": "Return complete item information (default: false)"
        },
        "limit": {
          "type": "number",
          "description": "Maximum number of items to return (default: 100, max: 1000)",
          "minimum": 1,
          "maximum": 1000
        },
        "offset": {
          "type": "number",
          "description": "Number of items to skip for pagination (default: 0)",
          "minimum": 0
        }
      },
      "additionalProperties": false
    }
  },
  "item_get_selected": {
    "name": "item_get_selected",
    "description": "Get currently selected items in Eagle application. Perfect for working with items the user has manually selected. Returns empty array if no items are selected.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "fullDetails": {
          "type": "boolean",
          "description": "Return complete item information (default: false)"
        }
      },
      "additionalProperties": false
    }
  },
  "item_update": {
    "name": "item_update",
    "description": "Batch update multiple items with new properties. Supports shared parameters (tags, folders, annotation, star) at top level that apply to all items - individual items can override these. Efficient for bulk operations with common metadata.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "tags": {
          "type": "array",
          "description": "Shared tags applied to all items (can be overridden per item)",
          "items": {
            "type": "string",
            "description": ""
          }
        },
        "folders": {
          "type": "array",
          "description": "Shared folder IDs applied to all items (can be overridden per item)",
          "items": {
            "type": "string",
            "description": ""
          }
        },
        "annotation": {
          "type": "string",
          "description": "Shared annotation applied to all items (can be overridden per item)"
        },
        "star": {
          "type": "number",
          "description": "Shared star rating applied to all items (can be overridden per item)",
          "minimum": 0,
          "maximum": 5
        },
        "items": {
          "type": "array",
          "description": "Array of items to update, each containing id and properties to update",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "Item ID",
                "minLength": 1
              },
              "name": {
                "type": "string",
                "description": "New file name"
              },
              "tags": {
                "type": "array",
                "description": "Item-specific tags (overrides shared tags)",
                "items": {
                  "type": "string",
                  "description": ""
                }
              },
              "annotation": {
                "type": "string",
                "description": "Item-specific annotation (overrides shared annotation)"
              },
              "star": {
                "type": "number",
                "description": "Item-specific star rating (overrides shared star)",
                "minimum": 0,
                "maximum": 5
              },
              "folders": {
                "type": "array",
                "description": "Item-specific folder IDs (overrides shared folders)",
                "items": {
                  "type": "string",
                  "description": ""
                }
              }
            },
            "required": [
              "id"
            ],
            "additionalProperties": false
          },
          "minItems": 1
        }
      },
      "required": [
        "items"
      ],
      "additionalProperties": false
    }
  },
  "item_count": {
    "name": "item_count",
    "description": "High-performance counting tool for Eagle library items. Supports all the same filter criteria as item_get but returns only the count without loading full item data. Perfect for analytics and overview information.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Specific item ID to count"
        },
        "ids": {
          "type": "array",
          "description": "Array of specific item IDs to count",
          "items": {
            "type": "string",
            "description": ""
          }
        },
        "keywords": {
          "type": "array",
          "description": "Array of keywords to search for",
          "items": {
            "type": "string",
            "description": ""
          }
        },
        "ext": {
          "type": "string",
          "description": "File extension filter (e.g., 'jpg', 'png', 'gif')"
        },
        "tags": {
          "type": "array",
          "description": "Array of tags to filter by",
          "items": {
            "type": "string",
            "description": ""
          }
        },
        "folders": {
          "type": "array",
          "description": "Array of folder IDs to filter by",
          "items": {
            "type": "string",
            "description": ""
          }
        },
        "shape": {
          "type": "string",
          "enum": [
            "square",
            "portrait",
            "landscape"
          ],
          "description": "Image shape filter"
        },
        "rating": {
          "type": "number",
          "description": "Star rating filter (0-5 stars)",
          "minimum": 0,
          "maximum": 5
        },
        "annotation": {
          "type": "string",
          "description": "Annotation content filter"
        },
        "url": {
          "type": "string",
          "description": "Source URL filter"
        },
        "isUnfiled": {
          "type": "boolean",
          "description": "Count items not in any folder"
        },
        "isUntagged": {
          "type": "boolean",
          "description": "Count items without any tags"
        },
        "isSelected": {
          "type": "boolean",
          "description": "Count currently selected items"
        }
      },
      "additionalProperties": false
    }
  },
  "item_add": {
    "name": "item_add",
    "description": "Unified item addition tool with intelligent source type routing. Supports URL, Base64, file path, and bookmark sources in batch operations. Supports shared parameters (tags, folders, annotation) at top level that apply to all items - individual items can override these. Perfect for batch imports with common metadata.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "tags": {
          "type": "array",
          "description": "Shared tags applied to all items (can be overridden per item)",
          "items": {
            "type": "string",
            "description": ""
          }
        },
        "folders": {
          "type": "array",
          "description": "Shared folder IDs applied to all items (can be overridden per item)",
          "items": {
            "type": "string",
            "description": ""
          }
        },
        "annotation": {
          "type": "string",
          "description": "Shared annotation applied to all items (can be overridden per item)"
        },
        "items": {
          "type": "array",
          "description": "Array of items to add",
          "items": {
            "type": "object",
            "properties": {
              "source": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "url",
                        "description": "Literal value: url"
                      },
                      "url": {
                        "type": "string",
                        "description": "Image URL to download and add to Eagle"
                      },
                      "website": {
                        "type": "string",
                        "description": "Source website URL"
                      }
                    },
                    "required": [
                      "type",
                      "url"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "base64",
                        "description": "Literal value: base64"
                      },
                      "base64": {
                        "type": "string",
                        "description": "Base64 encoded image data",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "type",
                      "base64"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "path",
                        "description": "Literal value: path"
                      },
                      "path": {
                        "type": "string",
                        "description": "Local file path to import",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "type",
                      "path"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "bookmark",
                        "description": "Literal value: bookmark"
                      },
                      "url": {
                        "type": "string",
                        "description": "Bookmark URL to save"
                      },
                      "base64": {
                        "type": "string",
                        "description": "Custom thumbnail as Base64 data"
                      }
                    },
                    "required": [
                      "type",
                      "url"
                    ],
                    "additionalProperties": false
                  }
                ],
                "description": "Discriminated union on type"
              },
              "name": {
                "type": "string",
                "description": "Item name"
              },
              "tags": {
                "type": "array",
                "description": "Item-specific tags (overrides shared tags)",
                "items": {
                  "type": "string",
                  "description": ""
                }
              },
              "folders": {
                "type": "array",
                "description": "Item-specific folder IDs (overrides shared folders)",
                "items": {
                  "type": "string",
                  "description": ""
                }
              },
              "annotation": {
                "type": "string",
                "description": "Item-specific annotation (overrides shared annotation)"
              }
            },
            "required": [
              "source"
            ],
            "additionalProperties": false
          },
          "minItems": 1
        }
      },
      "required": [
        "items"
      ],
      "additionalProperties": false
    }
  },
  "item_move_to_trash": {
    "name": "item_move_to_trash",
    "description": "Batch move items to trash. Supports moving multiple items at once by providing their IDs. Items moved to trash can be restored from Eagle's trash folder. Use carefully as this affects the library organization.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "ids": {
          "type": "array",
          "description": "Array of item IDs to move to trash",
          "items": {
            "type": "string",
            "description": "",
            "minLength": 1
          },
          "minItems": 1
        }
      },
      "required": [
        "ids"
      ],
      "additionalProperties": false
    }
  },
  "item_add_tags": {
    "name": "item_add_tags",
    "description": "Incrementally add tags to multiple items without replacing existing tags. All specified items receive the same tags. Tags are merged with existing ones, duplicates are automatically handled.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "ids": {
          "type": "array",
          "description": "Array of item IDs",
          "items": {
            "type": "string",
            "description": "",
            "minLength": 1
          },
          "minItems": 1
        },
        "tags": {
          "type": "array",
          "description": "Tags to add to all specified items",
          "items": {
            "type": "string",
            "description": "",
            "minLength": 1
          },
          "minItems": 1
        }
      },
      "required": [
        "ids",
        "tags"
      ],
      "additionalProperties": false
    }
  },
  "item_remove_tags": {
    "name": "item_remove_tags",
    "description": "Incrementally remove specific tags from multiple items without affecting other tags. All specified items have the same tags removed. Non-existent tags are silently ignored.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "ids": {
          "type": "array",
          "description": "Array of item IDs",
          "items": {
            "type": "string",
            "description": "",
            "minLength": 1
          },
          "minItems": 1
        },
        "tags": {
          "type": "array",
          "description": "Tags to remove from all specified items",
          "items": {
            "type": "string",
            "description": "",
            "minLength": 1
          },
          "minItems": 1
        }
      },
      "required": [
        "ids",
        "tags"
      ],
      "additionalProperties": false
    }
  },
  "item_add_to_folders": {
    "name": "item_add_to_folders",
    "description": "Incrementally add multiple items to folders without replacing existing folder assignments. All specified items are added to the same folders. Folders are merged with existing ones, duplicates are automatically handled.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "ids": {
          "type": "array",
          "description": "Array of item IDs",
          "items": {
            "type": "string",
            "description": "",
            "minLength": 1
          },
          "minItems": 1
        },
        "folders": {
          "type": "array",
          "description": "Folder IDs to add all specified items to",
          "items": {
            "type": "string",
            "description": "",
            "minLength": 1
          },
          "minItems": 1
        }
      },
      "required": [
        "ids",
        "folders"
      ],
      "additionalProperties": false
    }
  },
  "item_remove_from_folders": {
    "name": "item_remove_from_folders",
    "description": "Incrementally remove multiple items from specific folders without affecting other folder assignments. All specified items are removed from the same folders. Non-existent folder assignments are silently ignored.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "ids": {
          "type": "array",
          "description": "Array of item IDs",
          "items": {
            "type": "string",
            "description": "",
            "minLength": 1
          },
          "minItems": 1
        },
        "folders": {
          "type": "array",
          "description": "Folder IDs to remove all specified items from",
          "items": {
            "type": "string",
            "description": "",
            "minLength": 1
          },
          "minItems": 1
        }
      },
      "required": [
        "ids",
        "folders"
      ],
      "additionalProperties": false
    }
  },
  "tag_group_create": {
    "name": "tag_group_create",
    "description": "Create tag groups to organize and categorize tags. Supports custom colors and tag associations for better tag management and visual organization.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "tagGroups": {
          "type": "array",
          "description": "Array of tag groups to create",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "description": "Tag group name",
                "minLength": 1
              },
              "description": {
                "type": "string",
                "description": "Tag group description"
              },
              "color": {
                "type": "string",
                "enum": [
                  "red",
                  "orange",
                  "yellow",
                  "green",
                  "aqua",
                  "blue",
                  "purple",
                  "pink",
                  "none"
                ],
                "description": "Group color. Use predefined colors (red, orange, yellow, green, aqua, blue, purple, pink) or 'none' to clear color"
              },
              "tags": {
                "type": "array",
                "description": "Array of tag names to associate with this group",
                "items": {
                  "type": "string",
                  "description": ""
                }
              }
            },
            "required": [
              "name"
            ],
            "additionalProperties": false
          },
          "minItems": 1
        }
      },
      "required": [
        "tagGroups"
      ],
      "additionalProperties": false
    }
  },
  "tag_group_get": {
    "name": "tag_group_get",
    "description": "Retrieve tag groups by ID or name. Perfect for managing tag organization and retrieving group information with associated tags.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "ids": {
          "type": "array",
          "description": "Array of specific tag group IDs",
          "items": {
            "type": "string",
            "description": ""
          }
        },
        "names": {
          "type": "array",
          "description": "Array of specific tag group names",
          "items": {
            "type": "string",
            "description": ""
          }
        },
        "fullDetails": {
          "type": "boolean",
          "description": "Return complete tag group information"
        }
      },
      "additionalProperties": false
    }
  },
  "tag_group_update": {
    "name": "tag_group_update",
    "description": "Update tag group properties including name, color, and associated tags. Supports shared parameters (name, description, color, tags) at top level that apply to all groups - individual groups can override these. Efficient for batch updates with common metadata.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "Shared group name applied to all groups (can be overridden per group)"
        },
        "description": {
          "type": "string",
          "description": "Shared description applied to all groups (can be overridden per group)"
        },
        "color": {
          "type": "string",
          "enum": [
            "red",
            "orange",
            "yellow",
            "green",
            "aqua",
            "blue",
            "purple",
            "pink",
            "none"
          ],
          "description": "Shared color applied to all groups (can be overridden per group). Use predefined colors or 'none' to clear"
        },
        "tags": {
          "type": "array",
          "description": "Shared tags applied to all groups - FULL REPLACEMENT (can be overridden per group). For incremental changes, use tag_group_add_tags / tag_group_remove_tags",
          "items": {
            "type": "string",
            "description": ""
          }
        },
        "tagGroups": {
          "type": "array",
          "description": "Array of tag groups to update, each containing id and optional override properties",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "Tag group ID",
                "minLength": 1
              },
              "name": {
                "type": "string",
                "description": "Group-specific name (overrides shared name)"
              },
              "description": {
                "type": "string",
                "description": "Group-specific description (overrides shared description)"
              },
              "color": {
                "type": "string",
                "enum": [
                  "red",
                  "orange",
                  "yellow",
                  "green",
                  "aqua",
                  "blue",
                  "purple",
                  "pink",
                  "none"
                ],
                "description": "Group-specific color (overrides shared color). Use predefined colors or 'none' to clear"
              },
              "tags": {
                "type": "array",
                "description": "Group-specific tags - FULL REPLACEMENT (overrides shared tags)",
                "items": {
                  "type": "string",
                  "description": ""
                }
              }
            },
            "required": [
              "id"
            ],
            "additionalProperties": false
          },
          "minItems": 1
        }
      },
      "required": [
        "tagGroups"
      ],
      "additionalProperties": false
    }
  },
  "tag_group_delete": {
    "name": "tag_group_delete",
    "description": "Delete tag groups by ID. This removes the grouping but does not delete the actual tags. Use carefully as this operation cannot be undone.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "ids": {
          "type": "array",
          "description": "Array of tag group IDs to delete",
          "items": {
            "type": "string",
            "description": ""
          },
          "minItems": 1
        }
      },
      "required": [
        "ids"
      ],
      "additionalProperties": false
    }
  },
  "tag_group_add_tags": {
    "name": "tag_group_add_tags",
    "description": "Incrementally add or move tags to tag groups. Use removeFromSource=true to move tags (removes from original groups), or false to just add (tags can exist in multiple groups). Much more efficient than updating the entire tags array.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "operations": {
          "type": "array",
          "description": "Array of add tags operations",
          "items": {
            "type": "object",
            "properties": {
              "groupId": {
                "type": "string",
                "description": "Target tag group ID",
                "minLength": 1
              },
              "tags": {
                "type": "array",
                "description": "Array of tag names to add",
                "items": {
                  "type": "string",
                  "description": ""
                },
                "minItems": 1
              },
              "removeFromSource": {
                "type": "boolean",
                "description": "If true, remove tags from their original groups (move); if false, just add (default)"
              }
            },
            "required": [
              "groupId",
              "tags"
            ],
            "additionalProperties": false
          },
          "minItems": 1
        }
      },
      "required": [
        "operations"
      ],
      "additionalProperties": false
    }
  },
  "tag_group_remove_tags": {
    "name": "tag_group_remove_tags",
    "description": "Remove specific tags from tag groups. This only removes the association between tags and groups - it does not delete the tags themselves or affect items using those tags.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "operations": {
          "type": "array",
          "description": "Array of remove tags operations",
          "items": {
            "type": "object",
            "properties": {
              "groupId": {
                "type": "string",
                "description": "Target tag group ID",
                "minLength": 1
              },
              "tags": {
                "type": "array",
                "description": "Array of tag names to remove from group",
                "items": {
                  "type": "string",
                  "description": ""
                },
                "minItems": 1
              }
            },
            "required": [
              "groupId",
              "tags"
            ],
            "additionalProperties": false
          },
          "minItems": 1
        }
      },
      "required": [
        "operations"
      ],
      "additionalProperties": false
    }
  },
  "tag_get": {
    "name": "tag_get",
    "description": "Query Eagle tags with filtering capabilities. Supports searching by name, usage count, and returns tag statistics. Perfect for tag management and analysis.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "Specific tag name to search for"
        },
        "names": {
          "type": "array",
          "description": "Array of specific tag names",
          "items": {
            "type": "string",
            "description": ""
          }
        },
        "minCount": {
          "type": "number",
          "description": "Minimum usage count filter",
          "minimum": 1
        },
        "coreFieldsOnly": {
          "type": "boolean",
          "description": "Return only core fields (name, count)"
        }
      },
      "additionalProperties": false
    }
  },
  "tag_count": {
    "name": "tag_count",
    "description": "High-performance counting tool for Eagle tags. Returns only the count without loading full tag data. Perfect for analytics, dashboards, and checking tag statistics efficiently.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "minCount": {
          "type": "number",
          "description": "Only count tags with at least this many items",
          "minimum": 1
        }
      },
      "additionalProperties": false
    }
  },
  "tag_update": {
    "name": "tag_update",
    "description": "Batch rename tags across the entire Eagle library. This operation affects all items using the renamed tags. Use carefully as changes are global and permanent.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "tags": {
          "type": "array",
          "description": "Array of tag rename operations",
          "items": {
            "type": "object",
            "properties": {
              "oldName": {
                "type": "string",
                "description": "Current tag name",
                "minLength": 1
              },
              "newName": {
                "type": "string",
                "description": "New tag name",
                "minLength": 1
              }
            },
            "required": [
              "oldName",
              "newName"
            ],
            "additionalProperties": false
          },
          "minItems": 1
        }
      },
      "required": [
        "tags"
      ],
      "additionalProperties": false
    }
  },
  "tag_merge": {
    "name": "tag_merge",
    "description": "Merge tags by renaming source tag to target tag. All items using the source tag will be updated to use the target tag. Also updates tag groups, starred tags, and history tags. This operation is irreversible.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "operations": {
          "type": "array",
          "description": "Array of tag merge operations",
          "items": {
            "type": "object",
            "properties": {
              "source": {
                "type": "string",
                "description": "Source tag name (will be removed)",
                "minLength": 1
              },
              "target": {
                "type": "string",
                "description": "Target tag name (will be kept after merge)",
                "minLength": 1
              }
            },
            "required": [
              "source",
              "target"
            ],
            "additionalProperties": false
          },
          "minItems": 1
        }
      },
      "required": [
        "operations"
      ],
      "additionalProperties": false
    }
  }
};
const CATEGORIES = {
  "app": [
    "get_app_info"
  ],
  "item": [
    "item_query",
    "item_get",
    "item_get_selected",
    "item_update",
    "item_count",
    "item_add",
    "item_move_to_trash",
    "item_add_tags",
    "item_remove_tags",
    "item_add_to_folders",
    "item_remove_from_folders"
  ],
  "folder": [
    "folder_create",
    "folder_get",
    "folder_update"
  ],
  "tag": [
    "tag_get",
    "tag_count",
    "tag_update",
    "tag_merge"
  ],
  "tag_group": [
    "tag_group_create",
    "tag_group_get",
    "tag_group_update",
    "tag_group_delete",
    "tag_group_add_tags",
    "tag_group_remove_tags"
  ],
  "ai_search": [
    "ai_search_status",
    "ai_search_by_text",
    "ai_search_by_item"
  ]
};
const CATEGORY_DESCRIPTIONS = {
  "app": "Application information and system details",
  "item": "Library item management - search, filter, add, update, tag, and organize",
  "folder": "Folder management - create, query, and update folder hierarchy",
  "tag": "Tag management - query, count, rename, and merge tags",
  "tag_group": "Tag group management - create, update, delete groups and manage tag associations",
  "ai_search": "AI-powered semantic search (requires AI Search plugin)"
};
// --- End embedded metadata ---

const DEFAULT_SERVER = 'http://127.0.0.1:41596';

function main() {
  const args = process.argv.slice(2);

  // Parse --server flag (can appear anywhere)
  let serverUrl = process.env.EAGLE_SERVER_URL || DEFAULT_SERVER;
  const serverIdx = args.indexOf('--server');
  if (serverIdx !== -1 && args[serverIdx + 1]) {
    serverUrl = args[serverIdx + 1];
    args.splice(serverIdx, 2);
  }

  const command = args[0];

  if (!command || command === '--help' || command === '-h') {
    printUsage();
    return;
  }

  if (command === 'list') {
    printList();
    return;
  }

  if (command === 'help') {
    const toolName = args[1];
    if (!toolName) {
      console.error('Usage: eagle-api-cli.js help <tool>');
      process.exit(1);
    }
    printToolHelp(toolName);
    return;
  }

  if (command === 'call') {
    const toolName = args[1];
    if (!toolName) {
      console.error('Usage: eagle-api-cli.js call <tool> [--param value ...] [--json \'{...}\']');
      process.exit(1);
    }
    const params = parseCallArgs(args.slice(2));
    callTool(serverUrl, toolName, params);
    return;
  }

  console.error(`Unknown command: ${command}`);
  printUsage();
  process.exit(1);
}

function printUsage() {
  console.log(`Eagle API CLI — Control Eagle via command line

Usage:
  eagle-api-cli.js call <tool> [options]    Call an Eagle API tool
  eagle-api-cli.js list                     List all available tools
  eagle-api-cli.js help <tool>              Show help for a specific tool
  eagle-api-cli.js --help                   Show this help

Call Options:
  --json '{...}'           Pass parameters as JSON string
  --<param> <value>        Pass individual parameters (auto-parses JSON values)
  --server <url>           Server URL (default: ${DEFAULT_SERVER})

Environment:
  EAGLE_SERVER_URL         Override default server URL

Examples:
  eagle-api-cli.js call item_query --json '{"query": "cat"}'
  eagle-api-cli.js call item_query --query "cat"
  eagle-api-cli.js call item_get --tags '["photo","landscape"]' --limit 10
  eagle-api-cli.js call get_app_info
  eagle-api-cli.js list
  eagle-api-cli.js help item_query`);
}

function printList() {
  for (const [category, toolNames] of Object.entries(CATEGORIES)) {
    const desc = CATEGORY_DESCRIPTIONS[category] || '';
    console.log(`\n[${category}] ${desc}`);
    for (const name of toolNames) {
      const meta = TOOLS[name];
      if (meta) {
        // Truncate description to first sentence
        const short = meta.description.split('.')[0] + '.';
        console.log(`  ${name.padEnd(28)} ${short}`);
      } else {
        console.log(`  ${name.padEnd(28)} (not available)`);
      }
    }
  }
  console.log('');
}

function printToolHelp(toolName) {
  const meta = TOOLS[toolName];
  if (!meta) {
    console.error(`Unknown tool: ${toolName}`);
    console.error('Run "eagle-api-cli.js list" to see available tools.');
    process.exit(1);
  }

  console.log(`\n${meta.name}`);
  console.log(`${'='.repeat(meta.name.length)}`);
  console.log(meta.description);

  if (meta.inputSchema && meta.inputSchema.properties) {
    console.log('\nParameters:');
    const props = meta.inputSchema.properties;
    const required = new Set(meta.inputSchema.required || []);

    for (const [key, schema] of Object.entries(props)) {
      const req = required.has(key) ? '(required)' : '(optional)';
      const type = schema.type || 'any';
      const desc = schema.description || '';
      console.log(`  --${key.padEnd(22)} ${type.padEnd(10)} ${req.padEnd(12)} ${desc}`);
    }
  } else {
    console.log('\nNo parameters required.');
  }

  console.log(`\nExample:`);
  console.log(`  eagle-api-cli.js call ${toolName} --json '{}'`);
  console.log('');
}

/**
 * Parse CLI arguments for the call command.
 * Supports --json '{...}' and --key value style.
 */
function parseCallArgs(args) {
  let params = {};
  let i = 0;

  while (i < args.length) {
    const arg = args[i];

    if (arg === '--json' && args[i + 1]) {
      try {
        const jsonParams = JSON.parse(args[i + 1]);
        Object.assign(params, jsonParams);
      } catch (e) {
        console.error(`Error: Invalid JSON for --json: ${e.message}`);
        process.exit(1);
      }
      i += 2;
      continue;
    }

    if (arg.startsWith('--') && args[i + 1] !== undefined) {
      const key = arg.slice(2);
      const val = args[i + 1];
      params[key] = tryParseValue(val);
      i += 2;
      continue;
    }

    // Skip unrecognized arguments
    i++;
  }

  return params;
}

/**
 * Try to parse a string value as JSON (for arrays/objects/numbers/booleans).
 * Falls back to string if JSON.parse fails.
 */
function tryParseValue(val) {
  // Booleans
  if (val === 'true') return true;
  if (val === 'false') return false;

  // Try JSON parse for arrays, objects, numbers
  try {
    const parsed = JSON.parse(val);
    if (typeof parsed === 'object' || typeof parsed === 'number') {
      return parsed;
    }
  } catch (e) {
    // Not JSON, use as string
  }

  return val;
}

/**
 * Call a tool via POST /api/tools/call
 */
function callTool(serverUrl, toolName, params) {
  const url = new URL(serverUrl);
  const body = JSON.stringify({ tool: toolName, params });

  const options = {
    hostname: url.hostname,
    port: url.port || 80,
    path: '/api/tools/call',
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Content-Length': Buffer.byteLength(body),
    },
    timeout: 30000,
  };

  const req = http.request(options, (res) => {
    let data = '';
    res.on('data', chunk => { data += chunk; });
    res.on('end', () => {
      if (res.statusCode >= 200 && res.statusCode < 300) {
        // Output the result to stdout (for Skill consumption)
        process.stdout.write(data + '\n');
      } else {
        console.error(`Error (${res.statusCode}): ${data}`);
        process.exit(1);
      }
    });
  });

  req.on('error', (err) => {
    console.error(`Connection error: ${err.message}`);
    console.error('Make sure Eagle is running with the MCP plugin enabled.');
    process.exit(1);
  });

  req.on('timeout', () => {
    req.destroy();
    console.error('Request timed out.');
    process.exit(1);
  });

  req.write(body);
  req.end();
}

main();


Security scan verdicts — ClawScan: clean | static analysis: suspicious | VirusTotal: clean | SkillSpector: suspicious (MEDIUM)