Skip to main content
Glama

XC-MCP: XCode CLI wrapper

by conorluddy
screenshot-inline.test.ts2.31 kB
import { simctlScreenshotInlineTool } from '../../../src/tools/simctl/screenshot-inline.js'; import { McpError } from '@modelcontextprotocol/sdk/types.js'; // Mock dependencies jest.mock('../../../src/utils/device-detection.js', () => ({ resolveDeviceId: jest.fn(), })); jest.mock('../../../src/state/simulator-cache.js', () => ({ simulatorCache: { findSimulatorByUdid: jest.fn(), }, })); const { resolveDeviceId } = require('../../../src/utils/device-detection.js'); const { simulatorCache } = require('../../../src/state/simulator-cache.js'); describe('simctlScreenshotInlineTool', () => { const validUdid = 'device-iphone16pro'; const mockSimulator = { name: 'iPhone 16 Pro', udid: validUdid, state: 'Booted', }; beforeEach(() => { jest.clearAllMocks(); resolveDeviceId.mockResolvedValue(validUdid); simulatorCache.findSimulatorByUdid.mockResolvedValue(mockSimulator); }); describe('argument validation', () => { it('should reject with McpError if device not found', async () => { simulatorCache.findSimulatorByUdid.mockResolvedValue(null); await expect( simctlScreenshotInlineTool({ udid: 'unknown-device', }) ).rejects.toThrow(McpError); }); it('should call resolveDeviceId with provided UDID', async () => { simulatorCache.findSimulatorByUdid.mockResolvedValue(null); try { await simctlScreenshotInlineTool({ udid: 'test-udid' }); } catch { // Expected to throw } expect(resolveDeviceId).toHaveBeenCalledWith('test-udid'); }); it('should auto-detect UDID when not provided', async () => { simulatorCache.findSimulatorByUdid.mockResolvedValue(null); try { await simctlScreenshotInlineTool({}); } catch { // Expected to throw } expect(resolveDeviceId).toHaveBeenCalledWith(undefined); }); }); describe('simulator resolution', () => { it('should validate simulator exists', async () => { simulatorCache.findSimulatorByUdid.mockResolvedValue(null); const error = await simctlScreenshotInlineTool({ udid: validUdid, }).catch(e => e); expect(error).toBeInstanceOf(McpError); expect(error.message).toContain('not found'); }); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/conorluddy/xc-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server