MCPcopy
hub / github.com/codeaashu/claude-code / processCell

Function processCell

src/utils/notebook.ts:83–117  ·  view source on GitHub ↗
(
  cell: NotebookCell,
  index: number,
  codeLanguage: string,
  includeLargeOutputs: boolean,
)

Source from the content-addressed store, hash-verified

81}
82
83function processCell(
84 cell: NotebookCell,
85 index: number,
86 codeLanguage: string,
87 includeLargeOutputs: boolean,
88): NotebookCellSource {
89 const cellId = cell.id ?? `cell-${index}`
90 const cellData: NotebookCellSource = {
91 cellType: cell.cell_type,
92 source: Array.isArray(cell.source) ? cell.source.join('') : cell.source,
93 execution_count:
94 cell.cell_type === 'code' ? cell.execution_count || undefined : undefined,
95 cell_id: cellId,
96 }
97 // Avoid giving text cells the code language.
98 if (cell.cell_type === 'code') {
99 cellData.language = codeLanguage
100 }
101
102 if (cell.cell_type === 'code' && cell.outputs?.length) {
103 const outputs = cell.outputs.map(processOutput)
104 if (!includeLargeOutputs && isLargeOutputs(outputs)) {
105 cellData.outputs = [
106 {
107 output_type: 'stream',
108 text: `Outputs are too large to include. Use ${BASH_TOOL_NAME} with: cat <notebook_path> | jq '.cells[${index}].outputs'`,
109 },
110 ]
111 } else {
112 cellData.outputs = outputs
113 }
114 }
115
116 return cellData
117}
118
119function cellContentToToolResult(cell: NotebookCellSource): TextBlockParam {
120 const metadata = []

Callers 1

readNotebookFunction · 0.85

Calls 1

isLargeOutputsFunction · 0.85

Tested by

no test coverage detected