defaults-write
Modify macOS system preferences and application settings by writing values to specific domains and keys using the defaults command.
Instructions
use the defaults write <domain> <key> <value> command
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | Domain to write to | |
| key | Yes | Key to write to | |
| value | Yes | Value to write |
Implementation Reference
- The 'defaults_write' function implements the core logic of the 'defaults-write' tool by parsing arguments and executing subprocess.run(['defaults', 'write', domain, key, value]).def defaults_write(arguments: dict | None) -> list[types.TextContent]: if arguments is None: return [] domain = arguments["domain"] key = arguments["key"] value = arguments["value"] # TODO do I need to notify client that resource changed? can't it just ask for it again? result = subprocess.run(["defaults", "write", domain, key, value], capture_output=True) return [types.TextContent(type="text", text=result.stdout.decode("utf-8"))]
- Tool schema definition returned by list_tools(), specifying required string parameters: domain, key, value.types.Tool( name="defaults-write", description = "use the `defaults write <domain> <key> <value>` command", inputSchema = { "type": "object", "properties": { "domain": { "type": "string", "description": "Domain to write to", }, "key": { "type": "string", "description": "Key to write to", }, "value": { "type": "string", "description": "Value to write", }, }, "required": ["domain", "key", "value"], }, ),
- src/mcp_server_macos_defaults/server.py:224-225 (registration)Registration of the tool handler within the @server.call_tool() dispatcher function.elif name == "defaults-write": return defaults_write(arguments)