MCPcopy Create free account
hub / github.com/getsentry/XcodeBuildMCP / devicesResourceLogic

Function devicesResourceLogic

src/mcp/resources/devices.ts:16–59  ·  view source on GitHub ↗
(
  executor: CommandExecutor = getDefaultCommandExecutor(),
)

Source from the content-addressed store, hash-verified

14import { renderTranscript } from '../../rendering/render.ts';
15
16export async function devicesResourceLogic(
17 executor: CommandExecutor = getDefaultCommandExecutor(),
18): Promise<{ contents: Array<{ text: string }> }> {
19 const ctx: ToolHandlerContext = {
20 emit: () => {},
21 attach: () => {},
22 };
23
24 try {
25 log('info', 'Processing devices resource request');
26 await handlerContextStorage.run(ctx, () => list_devicesLogic({}, executor));
27 const text = renderTranscript(
28 {
29 structuredOutput: ctx.structuredOutput,
30 nextSteps: ctx.nextSteps,
31 nextStepsRuntime: 'mcp',
32 },
33 'text',
34 { runtime: 'mcp' },
35 );
36 const isError = ctx.structuredOutput?.result.didError === true;
37 if (isError) {
38 throw new Error(text || 'Failed to retrieve device data');
39 }
40 return {
41 contents: [
42 {
43 text: text || 'No device data available',
44 },
45 ],
46 };
47 } catch (error) {
48 const errorMessage = error instanceof Error ? error.message : String(error);
49 log('error', `Error in devices resource handler: ${errorMessage}`);
50
51 return {
52 contents: [
53 {
54 text: `Error retrieving device data: ${errorMessage}`,
55 },
56 ],
57 };
58 }
59}
60
61export async function handler(_uri: URL): Promise<{ contents: Array<{ text: string }> }> {
62 return devicesResourceLogic();

Callers 2

devices.test.tsFile · 0.90
handlerFunction · 0.85

Calls 4

logFunction · 0.90
list_devicesLogicFunction · 0.90
renderTranscriptFunction · 0.90

Tested by

no test coverage detected