applescript-mcp

by joshrutkowski
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Allows interaction with macOS through AppleScript, including calendar management, clipboard operations, Finder integration, system notifications, system controls, and iTerm terminal integration

  • Required as a prerequisite for running the MCP server

  • Planned feature to allow opening pages in Safari, saving page content, and getting selected page/tab

applescript-mcp MCP 服务器

一个模型上下文协议服务器,使 LLM 应用程序能够通过 AppleScript 与 macOS 交互。该服务器为 AI 应用程序提供标准化接口,用于控制系统功能、管理文件、处理通知等。

特征

  • 🗓️ 日历管理(事件、提醒)
  • 📋 剪贴板操作
  • 🔍 Finder 集成
  • 🔔 系统通知
  • ⚙️ 系统控制(音量、暗模式、应用程序)
  • 📟 iTerm 终端集成

计划功能

  • 📬 邮件(列出电子邮件、保存附件、汇总、发送)
  • 🧭 Safari(在 Safari 中打开、保存页面内容、获取选定的页面/标签)
  • 💬 消息(发送、获取、列表)
  • ✅ 提醒(创建、获取)
  • 🗒️ 注释(创建、获取、列出)

先决条件

  • macOS 10.15 或更高版本
  • Node.js 18 或更高版本

可用类别

日历

命令描述参数
add创建日历事件titlestartDateendDate
list列出今天的活动没有任何

剪贴板

命令描述参数
set_clipboard复制到剪贴板content
get_clipboard获取剪贴板内容没有任何
clear_clipboard清除剪贴板没有任何

发现者

命令描述参数
get_selected_files获取选定的文件没有任何
search_files搜索文件querylocation (可选)
quick_look预览文件path

通知

命令描述参数
send_notification显示通知titlemessagesound (可选)
toggle_do_not_disturb切换 DND 模式没有任何

系统

命令描述参数
volume设置系统音量level (0-100)
get_frontmost_app获取活动应用程序没有任何
launch_app打开应用程序name
quit_app关闭应用程序nameforce (可选)
toggle_dark_mode切换暗模式没有任何

iTerm

命令描述参数
paste_clipboard粘贴到 iTerm没有任何
run执行命令commandnewWindow (可选)

发展

设置

# Install dependencies npm install # Build the server npm run build # Launch MCP Inspector # See: https://modelcontextprotocol.io/docs/tools/inspector npx @modelcontextprotocol/inspector node path/to/server/index.js args...

添加新功能

1. 创建类别文件

创建src/categories/newcategory.ts

import { ScriptCategory } from "../types/index.js"; export const newCategory: ScriptCategory = { name: "category_name", description: "Category description", scripts: [ // Scripts will go here ] };

2.添加脚本

{ name: "script_name", description: "What the script does", schema: { type: "object", properties: { paramName: { type: "string", description: "Parameter description" } }, required: ["paramName"] }, script: (args) => ` tell application "App" // AppleScript code using ${args.paramName} end tell ` }

3. 注册类别

更新src/index.ts

import { newCategory } from "./categories/newcategory.js"; // ... server.addCategory(newCategory);

调试

使用 MCP 检查器

MCP Inspector 提供了一个用于测试和调试服务器的 Web 界面:

npm run inspector

日志记录

通过设置环境变量启用调试日志记录:

DEBUG=applescript-mcp* npm start

常见问题

  • 权限错误:检查系统偏好设置 > 安全和隐私
  • 脚本失败:直接在脚本编辑器中测试脚本。
  • 通信问题:检查 stdio 流是否被重定向

资源

贡献

  1. 分叉存储库
  2. 创建功能分支
  3. 提交你的更改
  4. 推送到分支
  5. 创建拉取请求

执照

MIT 许可证 - 详情请参阅许可证

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

使 LLM 应用程序能够通过 AppleScript 与 macOS 交互。

  1. Features
    1. Planned Features
  2. Prerequisites
    1. Available Categories
      1. Calendar
      2. Clipboard
      3. Finder
      4. Notifications
      5. System
      6. iTerm
    2. Development
      1. Setup
      2. Adding New Functionality
    3. Debugging
      1. Using MCP Inspector
      2. Logging
      3. Common Issues
    4. Resources
      1. Contributing
        1. License
          ID: 0t5gydjcqw