AppleScript字典访问服务

提供对macOS AppleScript字典的细粒度访问,允许客户端按需浏览套件、查找命令和类,以便正确编写AppleScript。

  • by benlenarts
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 benlenarts/sdef-mcp

使用说明

sdef mcp

MCP服务器,允许任何MCP客户端细粒度访问macOS AppleScript字典(SDEF)。客户端可以逐步深入到它需要的套件、命令、类和属性,而不是将整个应用程序字典转储到上下文中。

为什么

大多数macOS桌面应用程序都可以通过AppleScript编写脚本,但LLM不知道它们的API。此MCP允许任何客户端高效地发现Mac上任何应用程序的脚本功能——浏览套件、按需查找命令和类——因此它可以编写正确的AppleScript而无需猜测。

需求

  • macOS(使用 sdef 命令和 mdfind)
  • Node.js 18+

设置

克劳德代码

cd /path/to/sdef-mcp
npm install && npm run build
claude mcp add sdef-reader -- node /path/to/sdef-mcp/dist/bundle.cjs

克劳德桌面

构建 .mcpb bundle,然后将其拖放到Claude Desktop设置中的Extensions部分:

npm run pack

工具

工具 目的 代币成本
list_scriptable_apps 在系统上查找可编写脚本的应用程序 低
get_app_suites 套房名称+描述+数量 低
get_suite_detail 套件中的所有命令/类/枚举 中等
get_command 完整命令签名+参数+类型 低
get_class 属性、元素、继承 Low Med
get_enumeration 枚举类型的所有值 低
search_dictionary 所有内容的关键字搜索 各不相同

典型流量

1. get_app_suites("Mail")
   → see suites: Standard Suite, Mail Suite, ...

2. get_suite_detail("Mail", "Mail Suite")
   → see all commands and classes at a glance

3. get_class("Mail", "message")
   → full property list, elements, what commands it responds to

4. get_command("Mail", "send")
   → exact parameter signature

输出格式

紧凑的纯文本,针对LLM消费进行了优化。例子:

COMMAND: make  [Standard Suite]
  Create a new object
  Direct param: type [class name]
  Params:
    new: type — the class of the new object
    at: location specifier [optional] — the location at which to insert
    with data: any [optional] — the initial data
    with properties: record [optional] — the initial property values
  Returns: specifier — to the new object
CLASS: tab  [Safari Suite]
  Inherits: item
  Plural: tabs
  A tab in a window
  Properties:
    source: text — the URL of the page currently loaded
    URL: text — the URL of the page currently loaded
    index: integer [r] — the index of the tab
    text: text [r] — the text of the page currently loaded
    visible: boolean [r] — whether the tab is currently visible
    name: text [r] — the name of the tab
  Elements: (none)
  Responds to: close, print, save