JCAppleScript

io.github.johnnyclem由 GitHub 帳號 johnnyclem 發布v2.0.0更新於 Oct 24, 2026

Control macOS apps via AppleScript/JXA: sanitized commands for Messages, Mail, Finder, and more.

概覽

AI 產生的概覽

本機 macOS MCP 伺服器,讓助理透過 AppleScript 與 JXA 控制「訊息」「郵件」「Finder」「備忘錄」「Safari」等 Apple 應用程式。

可以做什麼
執行任意 AppleScript 或 JXA 程式碼,或向指定應用程式送出 tell 指令,並在不執行的情況下檢查腳本語法(安全模式下可停用這些程式碼執行工具)。瀏覽、搜尋並檢視 12 個 macOS 應用程式的內建指令表,並可試跑指令以查看其將執行的確切腳本。執行「訊息」「郵件」「提醒事項」「行事曆」「備忘錄」「Finder」「Safari」「音樂」「終端機」「系統設定」、Xcode 與語音辨識的預設指令。列出正在執行的應用程式,並從 JSON 清單載入額外的社群應用程式定義。
適用情境
適合在 Mac 上讓助理傳送訊息或郵件、管理提醒事項、行事曆事件、備忘錄或檔案、控制「音樂」或 Safari,或透過審核過的快捷指令操作 Xcode 與「終端機」,而非自由撰寫腳本。
執行需求
在 macOS 13.0 或更新版本上以本機程序執行;發行版提供可直接安裝到 Claude Desktop 的通用二進位套件,也可用 Swift 5.9+ 自行建置。未宣告驗證機制。選用環境變數:JCAS_SAFE_MODE 與 JCAS_APP_MANIFESTS。可能需要在 macOS 中為目標應用程式授予自動化權限。
安裝前請注意
execute_applescript、execute_jxa 與 tell_application 工具依設計會執行任意程式碼;只連接可信任的用戶端,或設定 JCAS_SAFE_MODE=1。標記為危險的登錄指令(例如 terminal.run_command 與 safari.run_javascript)會執行 shell 指令或網頁 JavaScript。指令可傳送訊息與郵件、刪除提醒事項、將檔案移至垃圾桶。透過 JCAS_APP_MANIFESTS 載入的社群清單會引入第三方指令定義;執行前請先預覽指令。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 JCAppleScript,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

JCAppleScript

A Swift package for executing AppleScript from macOS applications, featuring a built-in MCP server that lets AI assistants control macOS apps through pre-built command shortcuts.

Overview

JCAppleScript provides three components:

  1. JCAppleScript (library) - Core AppleScript execution engine
  2. AppShortcuts (library) - Registry of pre-built AppleScript commands for popular macOS apps
  3. jcas-mcp (executable) - MCP (Model Context Protocol) server for AI-driven app automation

Installation

Swift Package Manager

Add JCAppleScript to your Package.swift:

swift
dependencies: [    .package(url: "https://github.com/johnnyclem/JCAppleScript.git", from: "2.0.0")]

Then add the targets you need:

swift
.target(    name: "YourTarget",    dependencies: [        "JCAppleScript",     // Core engine only        "AppShortcuts",      // App command registry    ])

Quick Start

Using the Core Engine

swift
import JCAppleScript
let engine = AppleScriptEngine.shared
// Execute raw AppleScriptlet result = try engine.execute("""    tell application "Finder"        display dialog "Hello from Swift!"    end tell""")
// Send a command to an applicationlet output = try engine.tell(application: "Music", command: "play")
// Execute a script file with variable substitutionlet fileResult = try engine.executeFile(at: "/path/to/script.scpt", variables: ["Alice", "Hello!"])
// Execute JavaScript for Automation (JXA)let jxa = try engine.execute("Application('Music').play()", language: .javaScript)
// Check syntax without executingtry engine.checkSyntax("tell application \"Finder\" to activate")
// All execution APIs also have async variantslet asyncResult = try await engine.execute("return 40 + 2")

When embedding untrusted values in script source, escape them first:

swift
let userInput = "…"let script = "display dialog \(AppleScriptString.quoted(userInput))"

Using App Shortcuts

swift
import AppShortcuts
let registry = AppRegistry.shared
// Execute a pre-built commandlet result = try registry.executeCommand("messages.send_message", arguments: [    "recipient": "+15551234567",    "message": "Hello from JCAppleScript!"])
// Discover available commandslet commands = registry.commands(forApp: "Reminders")for cmd in commands {    print("\(cmd.id): \(cmd.name) - \(cmd.description)")}
// Search across all appslet results = registry.searchCommands("send")

Using the MCP Server

The jcas-mcp executable is a Model Context Protocol server that AI assistants (Claude, GPT, etc.) can use to control macOS applications.

It is published to the official MCP registry as io.github.johnnyclem/jcas-mcp, and each GitHub release ships a prebuilt jcas-mcp.mcpb bundle (universal macOS binary) that can be installed directly in Claude Desktop via Settings → Extensions.

Setup with Claude Desktop

Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):

json
{  "mcpServers": {    "applescript": {      "command": "/path/to/jcas-mcp"    }  }}

Build the server:

bash
swift build -c release# Binary at: .build/release/jcas-mcp
Available MCP Tools
ToolDescription
execute_applescriptExecute arbitrary AppleScript code †
execute_jxaExecute JavaScript for Automation (JXA) code †
tell_applicationSend a command to a specific app via tell block †
check_script_syntaxCompile a script (AppleScript or JXA) without executing it
list_running_applicationsGet currently running applications
list_registered_appsBrowse all registered app command sheets
search_commandsSearch for commands by keyword
run_app_commandExecute a pre-built command by ID
preview_app_commandDry-run: show the exact script a command would execute
get_app_commandsGet detailed command info for a specific app

† Hidden and disabled when the server runs in safe mode (see below).

Server Configuration
Environment variableEffect
JCAS_SAFE_MODE=1Disables the arbitrary-code tools (execute_applescript, execute_jxa, tell_application) and registry commands flagged dangerous (e.g. terminal.run_command, safari.run_javascript). Only pre-built, sanitized registry commands remain available.
JCAS_APP_MANIFESTS=a.json:b.jsonColon-separated JSON manifest files with additional community app definitions to load at startup.

CLI flags: jcas-mcp --manifest prints the full registry as JSON, --version prints the server version, --help shows usage.

Example AI Interaction
User: "Send a message to John saying I'll be late"AI uses tool: run_app_command  command_id: "messages.send_message"  arguments: { "recipient": "John", "message": "I'll be late" }

Supported Applications

JCAppleScript ships with command sheets for 12 built-in macOS apps:

AppCategoryCommandsExamples
MessagesCommunication6Send message, list chats, get participants
MailCommunication7Compose email, search, check mail, list accounts
RemindersProductivity7Create/complete/delete reminders, search, list
CalendarProductivity6Create events, list today's events, upcoming
NotesProductivity8Create/search/append notes, manage folders
FinderSystem12File operations, folder contents, labels, trash
SafariInternet10Open URLs, manage tabs, run JavaScript, get page content
MusicMedia13Playback control, playlists, library search, ratings
TerminalDevelopment8Run commands, manage windows/tabs, profiles
System SettingsSystem13Dark mode, volume, notifications, dialogs, system info
XcodeDevelopment20+Open/build/run/test projects, schemes, build logs, debugging
Speech RecognitionSystem3Listen for spoken phrases via the system speech engine

Adding Custom App Support

Implement the ScriptableApp protocol to add support for any scriptable macOS app:

swift
import AppShortcuts
struct MyApp: ScriptableApp {    static let bundleIdentifier = "com.example.myapp"    static let appName = "MyApp"    static let description = "My custom application"    static let category = AppCategory.productivity
    static let commands: [AppCommand] = [        AppCommand(            id: "myapp.do_thing",            name: "Do Thing",            description: "Performs the thing",            parameters: [                CommandParameter(name: "input", description: "The input value"),            ]        ) { args in            let input = args["input", default: ""]            return """            tell application "MyApp"                do thing with "\(input)"            end tell            """        },    ]}
// Register at runtimeAppRegistry.shared.register(MyApp.self)

Community App Registry

JCAppleScript is designed to grow through community contributions. The app shortcut system uses a standard protocol (ScriptableApp) that makes it easy to:

  • Add new applications - Implement ScriptableApp for any scriptable macOS app
  • Extend existing apps - Submit new commands for already-registered apps
  • Share command sheets - Export/import app definitions via JSON manifests

We're building a browsable registry (similar to npmjs.org) where you can:

  • Browse applications and their supported AppleScript commands
  • Submit new commands for existing apps
  • Add entirely new applications to the registry
  • Generate JSON manifests for integration with other tools

Exporting and Importing the Registry

swift
// Export all registered apps as manifest JSONlet json = try AppRegistry.shared.exportManifestJSON()
// Import community app definitions from a JSON manifest.// Manifest commands are declarative script templates with ${param}// placeholders; argument values are sanitized before substitution.try AppRegistry.shared.loadManifest(contentsOf: URL(fileURLWithPath: "community.json"))

Example manifest:

json
[  {    "name": "CoolApp",    "bundleIdentifier": "com.example.coolapp",    "description": "A community-contributed app",    "category": "Productivity",    "commands": [      {        "id": "coolapp.greet",        "name": "Greet",        "description": "Show a greeting",        "script": "tell application \"CoolApp\"\n    greet \"${who}\"\nend tell",        "parameters": [          {"name": "who", "description": "Who to greet", "required": true, "type": "string"}        ]      }    ]  }]

The MCP server loads extra manifests from the JCAS_APP_MANIFESTS environment variable at startup.

Security Model

Registry command arguments are sanitized before script generation:

  • String, file-path, and date arguments are escaped (\, ", and control characters) so they cannot break out of AppleScript string literals.
  • Integer and boolean arguments are strictly validated/normalized — malformed values are rejected at validation and fall back to declared defaults during generation.
  • Values outside a parameter's allowedValues list are dropped.
  • Arguments that don't correspond to a declared parameter are discarded.

Commands that execute caller-supplied code (Terminal shell commands, Safari JavaScript) are flagged dangerous and can be disabled wholesale with JCAS_SAFE_MODE=1. Use the preview_app_command tool to inspect the exact script a command will run before executing it.

Note that execute_applescript, execute_jxa, and tell_application execute arbitrary code by design — only expose them to clients you trust, or run the server in safe mode.

Architecture

JCAppleScript/├── Sources/│   ├── JCAppleScript/           # Core engine│   │   ├── AppleScriptEngine.swift│   │   ├── AppleScriptSanitizer.swift│   │   ├── ScriptResult.swift│   │   └── ScriptError.swift│   ├── AppShortcuts/            # App command registry│   │   ├── AppProtocol.swift    # ScriptableApp protocol│   │   ├── AppCommand.swift     # Command & parameter types + sanitization│   │   ├── AppDefinition.swift  # Instance-based app description│   │   ├── AppManifest.swift    # JSON import/export│   │   ├── AppRegistry.swift    # Central registry│   │   └── Apps/                # Built-in app sheets│   │       ├── MessagesApp.swift│   │       ├── RemindersApp.swift│   │       ├── FinderApp.swift│   │       ├── SafariApp.swift│   │       ├── MailApp.swift│   │       ├── CalendarApp.swift│   │       ├── NotesApp.swift│   │       ├── MusicApp.swift│   │       ├── TerminalApp.swift│   │       └── SystemSettingsApp.swift│   └── JCAppleScriptMCP/       # MCP server│       ├── main.swift│       ├── MCPServer.swift│       ├── MCPTransport.swift│       └── MCPTypes.swift├── Tests/├── Legacy/                      # Original Obj-C implementation├── Package.swift└── LICENSE

Requirements

  • macOS 13.0+
  • Swift 5.9+

Legacy

The original Objective-C implementation (2013) is preserved in the Legacy/ directory for reference. It provided basic NSAppleScript wrapping with variable substitution. The new Swift implementation builds on those concepts while adding the MCP server, app registry, and modern Swift patterns.

License

MIT License - Copyright (c) 2013 John Clem. See LICENSE for details.

來源:README.md,提交 57e718e

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v2.0.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分