defaults-read
Read macOS system preferences and application settings using the defaults command to access configuration values for domains and keys.
Instructions
use the defaults read <domain> <key> command
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | Domain to read from | |
| key | No | Key to read from |
Implementation Reference
- The handler function that executes the 'defaults-read' tool logic by running the macOS 'defaults read' command with the provided domain and optional key, capturing and formatting the output.def defaults_read(arguments: dict | None) -> list[types.TextContent]: if arguments is None: return [] domain = arguments["domain"] key = arguments.get("key") if key is None: result = subprocess.run(["defaults", "read", domain], capture_output=True) return [types.TextContent(type="text", text=result.stdout.decode("utf-8"))] result = subprocess.run(["defaults", "read", domain, key], capture_output=True) value = result.stdout.decode("utf-8").strip() return [types.TextContent(type="text", text=f"{key}: {value}")]
- src/mcp_server_macos_defaults/server.py:126-143 (registration)Registers the 'defaults-read' tool in the list_tools handler, specifying its name, description, and input schema (domain required, key optional).types.Tool( name="defaults-read", description = "use the `defaults read <domain> <key>` command", inputSchema = { "type": "object", "properties": { "domain": { "type": "string", "description": "Domain to read from", }, "key": { "type": "string", "description": "Key to read from", }, }, "required": ["domain"], }, ),
- JSON schema for the 'defaults-read' tool inputs, defining properties for 'domain' (required) and 'key' (optional).inputSchema = { "type": "object", "properties": { "domain": { "type": "string", "description": "Domain to read from", }, "key": { "type": "string", "description": "Key to read from", }, }, "required": ["domain"], },
- Dispatch logic in the main call_tool handler that routes 'defaults-read' calls to the defaults_read function.elif name == "defaults-read": return defaults_read(arguments)