Complete Call Flow Example
User Input
"Send an email to alice@example.com with subject 'Hello' using Mail"
Agent Behavior
- Call
resources/list-> Discoverapp:com.apple.mail - Call
resources/read(app:com.apple.mail)-> Getsend_emailtool - Construct MCP
tools/callrequest
Gateway Behavior (macOS Example)
- Parse
aai.json - Replace parameters in script template:applescript
tell application "Mail" set newMessage to make new outgoing message with properties {subject:"Hello", content:"Hi Alice...", visible:false} tell newMessage make new to recipient at beginning of to recipients with properties {address:"alice@example.com"} send end tell end tell return "{\"success\":true, \"message_id\":\"generated\"}" - Execute AppleScript:bash
osascript -e 'tell application "Mail"...' - If it's the first call, macOS pops up TCC authorization dialog
- After user authorizes, script executes successfully
- Parse return value (JSON string)
- Return result:
json
{
"jsonrpc": "2.0",
"id": 3,
"result": {
"content": [
{
"type": "text",
"text": "Email sent successfully. Message ID: generated"
}
]
}
}User Experience
- macOS pops up TCC authorization dialog on first use
- User clicks [OK]
- Subsequent calls execute silently