Skip to content

V2: Token Efficiency

Choose a tag to compare

@conorluddy conorluddy released this 06 Nov 09:06
· 17 commits to main since this release
fe7fe3c

Version 2.0.0

Consolidates the tool namespace from 51 to 28
tools through modular routing patterns, reducing MCP schema
token overhead by 75% from the v1.2.1 baseline. This release
introduces accessibility-first automation workflows and removes
7 tools with limited agent utility.

Token Efficiency

Version Tools Token Count Key Optimization
v1.2.1 51 ~7,850 Baseline (verbose
descriptions)
v1.3.2 51 ~3,000 RTFM progressive disclosure
v2.0.0 28 ~1,980 Operation enum consolidation

Total reduction: 75% fewer tokens, 45% fewer tools.

Breaking Changes

Tool Consolidation

21 individual tools have been consolidated into 6 routers using
operation enums. All consolidated tools now require an
operation parameter.

simctl-device (7 tools → 1 router)

Old Tool New Syntax
simctl-boot simctl-device({ operation: 'boot', ... })
simctl-shutdown `simctl-device({ operation: 'shutdown',
... })`
simctl-create `simctl-device({ operation: 'create', ...
})`
simctl-delete `simctl-device({ operation: 'delete', ...
})`
simctl-erase simctl-device({ operation: 'erase', ... })

|
| simctl-clone | simctl-device({ operation: 'clone', ... })
|
| simctl-rename | simctl-device({ operation: 'rename', ... }) |

simctl-app (4 tools → 1 router)

Old Tool New Syntax
simctl-install simctl-app({ operation: 'install', ... })
|

| simctl-uninstall | simctl-app({ operation: 'uninstall', ... }) |
| simctl-launch | simctl-app({ operation: 'launch', ... }) |
| simctl-terminate | simctl-app({ operation: 'terminate', ... }) |

idb-app (4 tools → 1 router)

Old Tool New Syntax
idb-install idb-app({ operation: 'install', ... })
idb-uninstall idb-app({ operation: 'uninstall', ... })
idb-launch idb-app({ operation: 'launch', ... })
idb-terminate idb-app({ operation: 'terminate', ... })

idb-targets (extended with 2 operations)

Old Tool New Syntax
idb-targets idb-targets({ operation: 'list', ... })
idb-connect idb-targets({ operation: 'connect', ... })
idb-disconnect `idb-targets({ operation: 'disconnect', ...
})` |

New operations: describe, focus

cache (4 tools → 1 router)

Old Tool New Syntax
cache-get-stats cache({ operation: 'get-stats', ... })
cache-get-config cache({ operation: 'get-config', ... })
|

| cache-set-config | cache({ operation: 'set-config', ... })
|
| cache-clear | cache({ operation: 'clear', ... }) |

persistence (3 tools → 1 router)

Old Tool New Syntax
persistence-enable `persistence({ operation: 'enable', ...
})` |

| persistence-disable | persistence({ operation: 'disable', ... }) |
| persistence-status | persistence({ operation: 'status', ... }) |

Removed Tools

The following tools have been removed:

  • xcodebuild-showsdks - Static environment information, agents
    typically use default SDKs
  • simctl-suggest - Agents have explicit device requirements,
    recommendation logic redundant
  • simctl-addmedia - Niche use case for photo picker testing
  • simctl-privacy - Permission testing rarely needed in
    CI/automated workflows
  • simctl-pbcopy - Text input achievable via idb-ui-input
  • simctl-status-bar - Cosmetic screenshot enhancement, not
    required for development
  • list-cached-responses - Meta debugging tool, limited agent
    utility

New Features

Accessibility-First Automation

Three new tools enable semantic UI automation as the primary
interaction method, with screenshots as fallback:

accessibility-quality-check

Assesses UI accessibility tree richness and provides workflow
recommendations.

Returns:

  • Quality classification: rich (>3 tappable elements),
    moderate (2-3), minimal (≤1)
  • Recommendation: accessibility-ready or screenshot-needed
  • Element counts by type
  • Performance metrics

Cost: ~30 tokens, ~80ms

idb-ui-find-element

Searches accessibility tree by label or identifier text
(case-insensitive, partial matching).

Returns:

  • Matched elements with tap coordinates (centerX, centerY)
  • Element metadata (type, label, identifier, enabled state)
  • Frame bounds for visual context

Cost: ~40 tokens, ~100ms

idb-ui-describe

Extended with progressive disclosure for large accessibility
trees.

Returns:

  • Summary with element counts and statistics
  • Full element list or cache ID for progressive access
  • Tappable element highlighting

Cost: ~50 tokens, ~120ms

Performance Comparison

Approach Token Cost Response Time Use Case
Accessibility tree query ~50 120ms Primary automation
method (95% of cases)
Screenshot analysis ~170 2000ms Fallback for custom UI
(5% of cases)

Result: 3.4x cheaper, 16x faster for accessibility-driven
workflows.

New Utilities

element-extraction.ts

Extracts accessibility elements from simulator using simctl
query commands.

Features:

  • Queries 8 element types (Button, TextField, SecureTextField,
    Switch, Slider, StaticText, Link, PickerWheel)
  • Parses bounds from AXFrame format
  • Handles malformed output gracefully
  • Returns coordinate-ready elements for tap operations

idb-device-detection.ts

Handles UDID resolution and device validation for IDB
operations.

Functions:

  • resolveIdbUdid() - Auto-detects UDID when not provided,
    falls back to last-used target
  • validateDeviceReady() - Validates IDB companion connection
    for physical devices
  • validateTargetBooted() - Ensures target is in Booted state
    before operations

Test Coverage

Added 119 tests across 5 new test suites:

  • idb-ui-find-element.test.ts - 22 tests for semantic element
    search
  • idb-accessibility-quality-check.test.ts - 25 tests for
    quality assessment logic
  • element-extraction.test.ts - 23 tests for accessibility
    element parsing
  • idb-device-detection.test.ts - 21 tests for UDID resolution
    and validation
  • idb-ui-describe.test.ts - 34 tests for UI tree querying with
    progressive disclosure

Total test count: 1,136 tests passing
Coverage: 52.77% → 60.28%

Documentation

README.md

Complete rewrite with:

  • Token efficiency evolution table
  • Accessibility-first philosophy explanation with performance
    data
  • Progressive disclosure pattern examples
  • RTFM on-demand documentation workflow
  • Tool reference organized by category
  • CLAUDE.md template for end users

CLAUDE.md

Targeted updates:

  • Project overview with v2.0.0 metrics
  • Accessibility-first workflow section with decision tree
  • V2.0 migration notes with complete tool consolidation mapping
  • Updated coverage requirements (80% → 60%)

RTFM Tool Documentation

All tool documentation updated with:

  • Operation enum specifications for consolidated routers
  • Migration examples for v1.x → v2.0
  • Accurate tool counts (fixed: 33 → 28 tools)

Architecture Changes

Router Pattern

Consolidated routers follow consistent architecture:

  • Thin routing layer (~100-200 lines)
  • Operation enum for type safety
  • Delegates to original tool implementations
  • Preserves modularity of individual tool files

Example router structure:

export async function simctlDeviceTool(args: SimctlDeviceArgs) {
  const { operation } = args;

  switch (operation) {
    case 'boot': return simctlBootTool(args);
    case 'shutdown': return simctlShutdownTool(args);
    // ... other operations
  }
}

Progressive Disclosure

RTFM tool provides on-demand documentation access:

  • Minimal tool descriptions in MCP schema (~70 tokens each)
  • Full documentation with examples available via rtfm({ toolName })
  • Category browsing via rtfm({ categoryName })
  • Suggestion system for typos/partial matches

Installation

npm

npm install xc-mcp@2.0.0

MCP Configuration

Claude Desktop configuration (claude_desktop_config.json):

{
  "mcpServers": {
    "xc-mcp": {
      "command": "npx",
      "args": ["-y", "xc-mcp@2.0.0"]
    }
  }
}

Local development configuration:

{
  "mcpServers": {
    "xc-mcp": {
      "command": "node",
      "args": ["/path/to/xc-mcp/dist/index.js"]
    }
  }
}

Migration Guide

For AI Agents

  1. Update tool calls to include operation parameter for
    consolidated routers
  2. Adopt accessibility-first workflow:
    • Call accessibility-quality-check before screenshot
    • Use idb-ui-find-element for semantic element search
    • Fall back to screenshot only when accessibility data is
      insufficient
  3. Replace removed tools:
    • simctl-privacy → Manual permission configuration in Xcode
    • simctl-pbcopy → Use idb-ui-input({ operation: 'text' })
    • simctl-suggest → Use simctl-list with explicit
      filtering
    • list-cached-responses → Remove from workflows

For CLAUDE.md Files

Replace project-specific CLAUDE.md instructions with template
from README.md:

## XC-MCP Integration

This project uses XC-MCP v2.0 for iOS development automation.

**Tool Count**: 28 tools (~1,980 tokens)
**Workflow**: Accessibility-first automation with screenshot
fallback

Key tools:
- `accessibility-quality-check` - Assess UI automation readiness
- `idb-ui-find-element` - Search elements by label/identifier
- `simctl-device` - Device lifecycle
(boot/shutdown/create/delete/erase/clone/rename)
- `simctl-app` - App management
(install/uninstall/launch/terminate)
- `rtfm` - On-demand tool documentation

Verification

After updating, verify migration success:

  1. Check MCP server starts: node dist/index.js (should not
    error)
  2. Verify tool count: Use rtfm({}) to list all 28 tools
  3. Test consolidated router: Call simctl-device({ operation: 'list' })
  4. Confirm accessibility tools available: rtfm({ toolName: 'accessibility-quality-check' })

Known Issues

None at release time.

Future Roadmap

Potential enhancements for future releases:

  • Session logging with artifact indexing for workflow
    reconstruction
  • Video recording with scene markers and metadata
  • Test result summaries with structured comparison
  • Media library with semantic indexing
  • Additional IDB UI automation patterns

See docs/LLM_OPTIMIZATION.md for comprehensive optimization
patterns under consideration.

Credits

Developed by Conor Luddy with Claude Code assistance.

Links