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

Function writeJsonOutput

src/cli/register-tool-commands.ts:102–135  ·  view source on GitHub ↗
(
  handlerContext: ToolHandlerContext,
  session: ReturnType<typeof createRenderSession>,
  options: { outputStyle: OutputStyle; verbose?: boolean },
)

Source from the content-addressed store, hash-verified

100const UI_ACTION_RESULT_VERBOSE_SCHEMA_VERSION = '3';
101
102function writeJsonOutput(
103 handlerContext: ToolHandlerContext,
104 session: ReturnType<typeof createRenderSession>,
105 options: { outputStyle: OutputStyle; verbose?: boolean },
106): boolean {
107 const { structuredOutput } = handlerContext;
108 const envelope = structuredOutput
109 ? toStructuredEnvelope(
110 structuredOutput.result,
111 structuredOutput.schema,
112 structuredOutput.schema === UI_ACTION_RESULT_SCHEMA && options.verbose === true
113 ? UI_ACTION_RESULT_VERBOSE_SCHEMA_VERSION
114 : structuredOutput.schemaVersion,
115 {
116 nextSteps: session.getNextSteps?.(),
117 nextStepRuntime: session.getNextStepsRuntime?.(),
118 outputStyle: options.outputStyle,
119 runtimeSnapshot: options.verbose ? 'full' : 'compact',
120 },
121 )
122 : toStructuredEnvelope(
123 createStructuredErrorOutput({
124 category: 'runtime',
125 code: 'STRUCTURED_OUTPUT_MISSING',
126 message: 'Tool did not produce structured output for --output json',
127 }).result,
128 STRUCTURED_ERROR_SCHEMA,
129 STRUCTURED_ERROR_SCHEMA_VERSION,
130 { outputStyle: options.outputStyle },
131 );
132
133 process.stdout.write(JSON.stringify(envelope, null, 2) + '\n');
134 return envelope.didError;
135}
136
137/**
138 * Register all tool commands from the catalog with yargs, grouped by workflow.

Callers 1

registerToolSubcommandFunction · 0.85

Calls 5

toStructuredEnvelopeFunction · 0.90
getNextStepsMethod · 0.80
getNextStepsRuntimeMethod · 0.80
writeMethod · 0.65

Tested by

no test coverage detected