applescript-mcp
applescript-mcp MCP 服务器
一个模型上下文协议服务器,使 LLM 应用程序能够通过 AppleScript 与 macOS 交互。该服务器为 AI 应用程序提供标准化接口,用于控制系统功能、管理文件、处理通知等。
特征
🗓️ 日历管理(事件、提醒)
📋 剪贴板操作
🔍 Finder 集成
🔔 系统通知
⚙️ 系统控制(音量、暗模式、应用程序)
📟 iTerm 终端集成
📬 邮件(创建新电子邮件、列出电子邮件、获取电子邮件)
🔄 快捷方式自动化
💬 消息(列出聊天、获取消息、搜索消息、发送消息)
🗒️ 笔记(创建格式化笔记、列出笔记、搜索笔记)
📄 页面(创建文档)
计划功能
🧭 Safari(在 Safari 中打开、保存页面内容、获取选定的页面/标签)
✅ 提醒(创建、获取)
Related MCP server: MCP AppleScript
先决条件
macOS 10.15 或更高版本
Node.js 18 或更高版本
可用类别
日历
命令 | 描述 | 参数 |
| 创建日历事件 |
|
| 列出今天的活动 | 没有任何 |
示例
// Create a new calendar event
Create a calendar event titled "Team Meeting" starting tomorrow at 2pm for 1 hour
// List today's events
What events do I have scheduled for today?剪贴板
命令 | 描述 | 参数 |
| 复制到剪贴板 |
|
| 获取剪贴板内容 | 没有任何 |
| 清除剪贴板 | 没有任何 |
示例
// Copy text to clipboard
Copy "Remember to buy groceries" to my clipboard
// Get clipboard contents
What's currently in my clipboard?
// Clear clipboard
Clear my clipboard发现者
命令 | 描述 | 参数 |
| 获取选定的文件 | 没有任何 |
| 搜索文件 |
|
| 预览文件 |
|
示例
// Get selected files in Finder
What files do I currently have selected in Finder?
// Search for files
Find all PDF files in my Documents folder
// Preview a file
Show me a preview of ~/Documents/report.pdf通知
注意:发送通知需要您在系统设置>通知>脚本编辑器中启用通知。
命令 | 描述 | 参数 |
| 显示通知 |
|
| 切换 DND 模式 | 没有任何 |
示例
// Send a notification
Send me a notification with the title "Reminder" and message "Time to take a break"
// Toggle Do Not Disturb
Turn on Do Not Disturb mode系统
命令 | 描述 | 参数 |
| 设置系统音量 |
|
| 获取活动应用程序 | 没有任何 |
| 打开应用程序 |
|
| 关闭应用程序 |
|
| 切换暗模式 | 没有任何 |
示例
// Set system volume
Set my Mac's volume to 50%
// Get active application
What app am I currently using?
// Launch an application
Open Safari
// Quit an application
Close Spotify
// Toggle dark mode
Switch to dark modeiTerm
命令 | 描述 | 参数 |
| 粘贴到 iTerm | 没有任何 |
| 执行命令 |
|
示例
// Paste clipboard to iTerm
Paste my clipboard contents into iTerm
// Run a command in iTerm
Run "ls -la" in iTerm
// Run a command in a new iTerm window
Run "top" in a new iTerm window快捷方式
命令 | 描述 | 参数 |
| 运行快捷方式 |
|
| 列出所有可用的快捷方式 |
|
示例
// List available shortcuts
List all my available shortcuts
// List with limit
Show me my top 5 shortcuts
// Run a shortcut
Run my "Daily Note in Bear" shortcut
// Run a shortcut with input
Run my "Add to-do" shortcut with input "Buy groceries"邮件
命令 | 描述 | 参数 |
| 在 Mail.app 中创建新电子邮件 |
|
| 列出邮箱中的电子邮件 |
|
| 通过搜索获取特定电子邮件 |
|
示例
// Create a new email
Compose an email to john@example.com with subject "Meeting Tomorrow" and body "Hi John, Can we meet tomorrow at 2pm?"
// List emails
Show me my 10 most recent unread emails
// Get a specific email
Find the email from sarah@example.com about "Project Update"消息
命令 | 描述 | 参数 |
| 列出可用的 iMessage 和 SMS 聊天 |
|
| 从“信息”应用获取信息 |
|
| 搜索包含特定文本的消息 |
|
| 打开“信息”应用,输入预填信息或自动发送 |
|
示例
// List available chats
Show me my recent message conversations
// Get recent messages
Show me my last 20 messages
// Search messages
Find messages containing "dinner plans" from John in the last week
// Compose a message
Send a message to 555-123-4567 saying "I'll be there in 10 minutes"笔记
命令 | 描述 | 参数 |
| 创建具有类似 markdown 格式的笔记 |
|
| 创建包含直接 HTML 内容的笔记 |
|
| 列出笔记(可选,来自特定文件夹) |
|
| 根据标题获取特定笔记 |
|
| 搜索包含特定文本的笔记 |
|
示例
// Create a new note with markdown formatting
Create a note titled "Meeting Minutes" with content "# Discussion Points\n- Project timeline\n- Budget review\n- Next steps" and format headings and lists
// Create a note with HTML
Create a note titled "Formatted Report" with HTML content "<h1>Quarterly Report</h1><p>Sales increased by <strong>15%</strong></p>"
// List notes
Show me all my notes in the "Work" folder
// Get a specific note
Show me my note titled "Shopping List"
// Search notes
Find notes containing "recipe" in my "Cooking" folder页面
命令 | 描述 | 参数 |
| 使用纯文本创建新的 Pages 文稿 |
|
示例
// Create a new Pages document
Create a Pages document with the content "Project Proposal\n\nThis document outlines the scope and timeline for the upcoming project."建筑学
applescript-mcp 服务器使用 TypeScript 构建,并遵循模块化架构:
核心组件
AppleScriptFramework (
framework.ts):主服务器类,它:管理 MCP 协议通信
处理工具注册和执行
提供日志记录功能
执行 AppleScript 命令
类别(
src/categories/*.ts):按功能组织的模块化脚本集合:每个类别包含相关脚本(例如日历、系统、笔记)
类别在
index.ts中向框架注册
类型(
src/types/index.ts):TypeScript 接口定义:ScriptDefinition:单个脚本的结构ScriptCategory:相关脚本的集合LogLevel:标准日志记录级别FrameworkOptions:配置选项
执行流程
客户端通过MCP协议发送工具请求
服务器识别适当的类别和脚本
脚本内容生成(静态或通过函数动态生成)
AppleScript 通过 macOS
osascript命令执行结果返回给客户端
日志系统
该框架包括一个全面的日志系统:
记录到 stderr 和 MCP 日志协议
支持多种严重性级别(调试、信息、警告、错误等)
提供详细的执行信息以进行故障排除
发展
设置
# 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);高级脚本开发
对于更复杂的脚本,您可以:
使用动态脚本生成:
script: (args) => { // Process arguments and build script dynamically let scriptContent = `tell application "App"\n`; if (args.condition) { scriptContent += ` // Conditional logic\n`; } scriptContent += `end tell`; return scriptContent; }处理复杂数据:
// Example from Notes category function generateNoteHtml(args: any): string { // Process markdown-like syntax into HTML let processedContent = content; if (format.headings) { processedContent = processedContent.replace(/^# (.+)$/gm, '<h1>$1</h1>'); // ... } return processedContent; }
调试
使用 MCP 检查器
MCP Inspector 提供了一个用于测试和调试服务器的 Web 界面:
npm run inspector日志记录
通过设置环境变量启用调试日志记录:
DEBUG=applescript-mcp* npm start示例配置
运行npm run build后,将以下内容添加到您的mcp.json文件:
{
"mcpServers": {
"applescript-mcp-server": {
"command": "node",
"args": ["/path/to/applescript-mcp/dist/index.js"]
}
}
}常见问题
权限错误:检查系统偏好设置 > 安全和隐私 > 隐私 > 自动化
脚本失败:集成前直接在 Script Editor.app 中测试脚本
通信问题:检查 stdio 流是否被重定向
数据库访问:某些功能(如消息)需要完全磁盘访问权限
资源
贡献
分叉存储库
创建功能分支
提交你的更改
推送到分支
创建拉取请求
执照
MIT 许可证 - 详情请参阅许可证
Available Tools
33 toolscalendar_addC
[Calendar operations] Add a new event to Calendar
Inputs: title (required), startDate (required), endDate (required), calendar.
calendar_listB
[Calendar operations] List all events for today
Inputs: no named parameters.
clipboard_clear_clipboardC
[Clipboard management operations] Clear clipboard content
Inputs: no named parameters.
clipboard_get_clipboardB
[Clipboard management operations] Get current clipboard content
Inputs: type.
clipboard_set_clipboardC
[Clipboard management operations] Set clipboard content
Inputs: content (required).
finder_get_selected_filesB
[Finder and file operations] Get currently selected files in Finder
Inputs: no named parameters.
finder_quick_look_fileB
[Finder and file operations] Preview a file using Quick Look
Inputs: path (required).
finder_search_filesC
[Finder and file operations] Search for files by name
Inputs: query (required), location.
iterm_paste_clipboardB
[iTerm terminal operations] Paste clipboard content into iTerm
Inputs: no named parameters.
iterm_runC
[iTerm terminal operations] Run a command in iTerm
Inputs: command (required), newWindow.
mail_create_emailC
[Mail operations] Create a new email in Mail.app
Inputs: recipient (required), subject (required), body (required).
mail_get_emailC
[Mail operations] Get a specific email by search criteria from Mail.app
Inputs: mailbox, account, subject, sender, +3 more.
mail_list_emailsB
[Mail operations] List emails from a specified mailbox in Mail.app
Inputs: mailbox, account, count, unreadOnly.
messages_compose_messageC
[iMessage operations] Open Messages app with a pre-filled message to a recipient or automatically send a message
Inputs: recipient (required), body, auto.
messages_get_messagesC
[iMessage operations] Get messages from the Messages app
Inputs: limit.
messages_list_chatsC
[iMessage operations] List available iMessage and SMS chats
Inputs: includeParticipantDetails.
messages_search_messagesC
[iMessage operations] Search for messages containing specific text or from a specific sender
Inputs: searchText (required), sender, chatId, limit, +1 more.
notes_createC
[Apple Notes operations] Create a new note with optional formatting
Inputs: title (required), content (required), format.
notes_createRawHtmlC
[Apple Notes operations] Create a new note with direct HTML content
Inputs: title (required), html (required).
notes_getB
[Apple Notes operations] Get a specific note by title
Inputs: title (required), folder.
notes_listC
[Apple Notes operations] List all notes or notes in a specific folder
Inputs: folder.
notes_searchC
[Apple Notes operations] Search for notes containing specific text
Inputs: query (required), folder, limit, includeBody.
notifications_send_notificationC
[Notification management] Send a system notification
Inputs: title (required), message (required), sound.
notifications_toggle_do_not_disturbB
[Notification management] Toggle Do Not Disturb mode using keyboard shortcut
Inputs: no named parameters.
pages_create_documentC
[Pages document operations] Create a new Pages document with plain text content (no formatting)
Inputs: content (required).
shortcuts_list_shortcutsC
[Shortcuts operations] List all available shortcuts with optional limit
Inputs: limit.
shortcuts_run_shortcutA
[Shortcuts operations] Run a shortcut with optional input. Uses Shortcuts Events to run in background without opening the app.
Inputs: name (required), input.
system_get_battery_statusB
[System control and information] Get battery level and charging status
Inputs: no named parameters.
system_get_frontmost_appB
[System control and information] Get the name of the frontmost application
Inputs: no named parameters.
system_launch_appC
[System control and information] Launch an application
Inputs: name (required).
system_quit_appC
[System control and information] Quit an application
Inputs: name (required), force.
system_toggle_dark_modeB
[System control and information] Toggle system dark mode
Inputs: no named parameters.
system_volumeC
[System control and information] Set system volume
Inputs: level (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 33 tools
Tools are well-organized into distinct domains (e.g., Calendar, Clipboard, Finder, Mail, Messages, Notes, Notifications, Pages, Shortcuts, System), with clear purposes within each domain. Minor potential confusion exists between 'notes_create' and 'notes_createRawHtml', which both create notes but with different content formats, but descriptions clarify the distinction.
Tool names follow a highly consistent verb_noun pattern throughout (e.g., calendar_add, clipboard_get_clipboard, finder_search_files). All tools use snake_case consistently, with no deviations in naming conventions, making them predictable and easy to parse.
With 33 tools, the count is borderline high for a single server, potentially overwhelming for agents. However, given the broad scope of automating various macOS applications and system functions, the number is reasonable but could benefit from more modular organization to reduce cognitive load.
The tool set provides comprehensive coverage across multiple macOS domains, with CRUD operations for key apps like Calendar, Mail, Messages, and Notes. Minor gaps exist, such as no update or delete tools for Calendar events or Pages documents, but agents can work around these with existing tools for most workflows.
Maintenance
Related MCP Connectors
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Use your Mac, Windows or Linux computer from ChatGPT, Claude or Codex: files, commands, documents.
MCP connector that lets ChatGPT list, search, and run your Apple Shortcuts via a local Mac agent
- DNS-DATA RemoteDeprecatedcom.dns-data
Connect AI assistants to authorized Windows and macOS devices for files, commands, and management.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables AI agents to interact with macOS applications (Finder, Mail, Contacts, Reminders, Notes, Calendar, TextEdit) using AppleScript. Allows AI assistants to perform tasks like searching contacts, managing files, checking email, and creating reminders through natural language.241MIT
- AlicenseAqualityDmaintenanceEnables Large Language Models to automate macOS applications and execute AppleScript commands through natural language. It features built-in security protections including application allowlists and dangerous pattern detection to prevent unauthorized or risky system operations.227 PyPI1MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI to dynamically discover and control native macOS applications (like Finder, Mail, Safari) through AppleScript/JXA automation without pre-built integrations.3MIT
- AlicenseNot gradedqualityDmaintenanceEnables Claude to automate macOS applications, manage files, control music, send messages, and more through AppleScript.29 npm1GPL 3.0