MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / xcodeIdeStateResourceLogic

Function xcodeIdeStateResourceLogic

src/mcp/resources/xcode-ide-state.ts:22–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20}
21
22export async function xcodeIdeStateResourceLogic(): Promise<{
23 contents: Array<{ text: string }>;
24}> {
25 try {
26 log('info', 'Processing Xcode IDE state resource request');
27
28 const executor = getDefaultCommandExecutor();
29 const cwd = process.cwd();
30
31 const state = await readXcodeIdeState({ executor, cwd });
32
33 const response: XcodeIdeStateResponse = {
34 detected: !state.error && (!!state.scheme || !!state.simulatorId),
35 scheme: state.scheme,
36 simulatorId: state.simulatorId,
37 simulatorName: state.simulatorName,
38 error: state.error,
39 };
40
41 return {
42 contents: [
43 {
44 text: JSON.stringify(response, null, 2),
45 },
46 ],
47 };
48 } catch (error) {
49 const errorMessage = error instanceof Error ? error.message : String(error);
50 log('error', `Error in Xcode IDE state resource handler: ${errorMessage}`);
51
52 const response: XcodeIdeStateResponse = {
53 detected: false,
54 error: errorMessage,
55 };
56
57 return {
58 contents: [
59 {
60 text: JSON.stringify(response, null, 2),
61 },
62 ],
63 };
64 }
65}
66
67export async function handler(_uri: URL): Promise<{ contents: Array<{ text: string }> }> {
68 return xcodeIdeStateResourceLogic();

Callers 2

handlerFunction · 0.85

Calls 3

logFunction · 0.90
readXcodeIdeStateFunction · 0.90

Tested by

no test coverage detected