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

Function processToolResponse

src/utils/responses/next-steps-renderer.ts:20–51  ·  view source on GitHub ↗
(response: ToolResponse, runtime: RuntimeKind)

Source from the content-addressed store, hash-verified

18}
19
20export function processToolResponse(response: ToolResponse, runtime: RuntimeKind): ToolResponse {
21 const { nextSteps, ...rest } = response;
22
23 if (!nextSteps || nextSteps.length === 0) {
24 return { ...rest };
25 }
26
27 const nextStepsSection = renderNextStepsSection(nextSteps, runtime);
28 const processedContent = [...response.content];
29 let textItemIndex = -1;
30
31 for (let index = processedContent.length - 1; index >= 0; index -= 1) {
32 if (processedContent[index]?.type === 'text') {
33 textItemIndex = index;
34 break;
35 }
36 }
37
38 if (textItemIndex >= 0) {
39 const textItem = processedContent[textItemIndex];
40 if (textItem?.type === 'text') {
41 processedContent[textItemIndex] = {
42 ...textItem,
43 text: textItem.text + '\n\n' + nextStepsSection,
44 };
45 }
46 } else {
47 processedContent.push({ type: 'text', text: nextStepsSection.trim() });
48 }
49
50 return { ...rest, content: processedContent };
51}

Callers 1

Calls 2

renderNextStepsSectionFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected