How steipete/macos-automator-mcp works
1. This repository is a Node.js/TypeScript MCP server for macOS automation. Its core job is to expose a small set of MCP tools that execute AppleScript, JavaScript for Automation (JXA), and accessibility-driven UI actions on the local Mac. The runtime boundary is the host machine running the server; the server talks outward to macOS automation APIs and the accessibility framework.
2. The main external interface is the MCP protocol over stdio. The test file tests/mcp-stdio.test.ts and the presence of src/server.ts indicate the server is packaged as a command-line MCP endpoint rather than a browser or HTTP app. The published entrypoint is likely the start.sh wrapper, which chooses between compiled output and direct TypeScript execution during development.
3. The server exposes three primary capability groups. execute_script is the script runner for AppleScript/JXA. get_scripting_tips is the knowledge-base lookup tool that returns human-readable automation recipes. accessibility_query is a separate UI-automation path that queries or performs actions against macOS accessibility elements via an ax-style backend. These are distinct execution paths with different inputs, output shapes, and permission requirements.
4. Script execution is the central runtime subsystem. src/ScriptExecutor.ts likely shells out to osascript or equivalent, applies language-specific formatting, enforces timeouts, and returns normalized stdout/stderr content. The README shows support for inline scripts, file-based scripts, and knowledge-base script IDs, so the executor must resolve the source first, substitute inputs, then dispatch to the macOS scripting runtime.
5. The knowledge base is the repo’s largest architectural component, and it is content-driven rather than code-driven. knowledge_base/ contains hundreds of markdown automation recipes organized by domain: core AppleScript/JXA concepts, system actions, files, terminal, browsers, editors, productivity apps, creative apps, advanced workflows, networking, and developer tools. This content is the server’s built-in automation catalog, not just documentation.
6. Knowledge-base loading is handled by src/services/kbLoader.ts, src/services/KnowledgeBaseManager.ts, and src/services/knowledgeBaseService.ts. Based on the README, this layer supports lazy or eager parsing, category indexing, lookup by script ID or search term, and local overrides from ~/.macos-automator/knowledge_base or LOCAL_KB_PATH. That means the KB layer is both a content registry and a merge/override system.
7. Placeholder substitution is a separate data-preparation step before execution. src/placeholderSubstitutor.ts and the schema/type files suggest knowledge-base scripts can declare argument prompts and input placeholders that are replaced with user-supplied arguments or structured input_data. This creates a boundary between reusable recipe templates and the final executable script text.
8. Validation and tooling are first-class subsystems because the repo is mostly curated content. The scripts/ directory contains validators and report generators for knowledge-base files, categories, paths, and script syntax. That implies the repository treats the KB as a schema-checked asset pipeline, with automated checks for structure, metadata, and script correctness before publish.
9. The docs directory is part of the architecture because it captures executable knowledge patterns. Files like docs/applescript_*.md, docs/kb_validation.md, and docs/spec.md describe the supported automation patterns and the KB contract. The knowledge_base/_shared_handlers directory shows another reuse boundary: shared AppleScript/JXA helpers that can be imported across tips.
10. The repo’s operational boundary is macOS permissions. The README explicitly calls out Automation and Accessibility permissions, which are required for controlling apps or querying UI elements. This matters architecturally because the server cannot self-elevate; the host application running the MCP server must already be trusted by macOS for the target apps and accessibility APIs.
11. Tooling and release flow are standard TypeScript package infrastructure. package.json, pnpm-lock.yaml, .github/workflows/ci.yml, and .github/workflows/publish.yml show pnpm-based builds/tests and npm publishing. The source/runtime split, plus start.sh, implies the repo supports both local development against src/ and packaged execution from a build artifact.
12. In diagram terms, the cleanest high-level flow is: MCP client sends a tool request to the server; the server routes to script execution, KB search, or accessibility querying; the KB layer resolves recipes and substitutions when needed; execution then delegates to macOS-native automation runtimes; results return back through MCP as text content and error flags. The content repository, validators, and docs sit alongside that runtime path as the knowledge and quality-control layers.
Main entry points: server.ts MCP server · validate-kb.ts Validators · KnowledgeBaseManager.ts KB manager · ScriptExecutor.ts Script exec
Components 18
Runtime
MCP server execution and macOS automation
- start.sh · Launches compiled server or dev TypeScript runtime
start.sh - MCP server · Main MCP server and tool router
src/server.ts - Schemas · Shared request and response shapes
src/schemas.ts - Script exec · Runs AppleScript and JXA payloads on macOS
src/ScriptExecutor.ts - Placeholders · Resolves recipe arguments into executable script text
src/placeholderSubstitutor.ts - macOS APIs · AppleScript, JXA, Accessibility, and system automation APIs
- Accessibility · Accessibility-driven UI queries and actions
Knowledge Base
Curated automation recipes and lookup services
- KB service · High-level knowledge-base search and retrieval
src/services/knowledgeBaseService.ts - KB manager · Indexes recipes and resolves IDs and categories
src/services/KnowledgeBaseManager.ts - KB loader · Loads local and override knowledge-base content
src/services/kbLoader.ts - KB types · Knowledge-base data structures and metadata types
src/services/scriptingKnowledge.types.ts - Recipes · Markdown automation recipes and shared handlers
knowledge_base
Tooling
Validation, testing, and release support
- Validators · KB structure, path, category, and script validation
scripts/validate-kb.ts - Script validator · Checks script examples and automation snippets
scripts/scriptValidator.ts - KB reports · Generates validation and inventory reports
scripts/kbReport.ts - MCP test · Exercises the stdio MCP server boundary
tests/mcp-stdio.test.ts
Docs
Executable documentation and specs
- Spec · Defines the MCP and knowledge-base contract
docs/spec.md - KB validation · Documents validation rules and workflow
docs/kb_validation.md
Connections 20
- start.sh → MCP server: launches · Wrapper starts the MCP server process
- MCP server → Schemas: uses · Server validates tool I/O against shared schemas
- MCP server → Script exec: routes · Tool requests that execute scripts flow to the executor
- MCP server → KB service: routes · Scripting-tip lookups flow to knowledge-base service
- MCP server → Accessibility: routes · Accessibility tool requests flow to UI automation path
- Script exec → Placeholders: prepares · Template inputs are substituted before execution
- Placeholders → KB manager: resolves · Recipe templates and IDs are resolved through KB metadata
- KB service → KB manager: queries · Search and lookup are served through the registry
- KB manager → KB loader: loads · Manager depends on loader for content ingestion
- KB loader → Recipes: reads · Loader parses markdown recipe files and overrides
- KB manager → KB types: structures · Manager uses KB data model and metadata types
- Recipes → macOS APIs: describes · Recipes encode scripts that run on macOS automation runtimes
- Script exec → macOS APIs: delegates · Execution shells out to native AppleScript/JXA tooling
- Accessibility → macOS APIs: uses · Accessibility automation talks to the host macOS UI layer
- Validators → Script validator: includes · KB validation pipeline incorporates script checks
- Validators → KB reports: produces · Validation tooling also emits reports and inventories
- Validators → Recipes: checks · Validators inspect the knowledge-base content tree
- MCP test → MCP server: exercises · Integration test covers stdio server behavior
- Spec → MCP server: defines · Spec documents the server and tool contract
- KB validation → Validators: documents · Docs explain the KB validation workflow