MCPcopy
hub / github.com/deepnote/deepnote / handleRun

Function handleRun

packages/mcp/src/tools/execution.ts:150–369  ·  view source on GitHub ↗
(args: Record<string, unknown>)

Source from the content-addressed store, hash-verified

148}
149
150async function handleRun(args: Record<string, unknown>) {
151 const parsedArgs = runArgsSchema.safeParse(args)
152 if (!parsedArgs.success) {
153 return {
154 content: [{ type: 'text', text: `Invalid arguments for deepnote_run: ${formatFirstIssue(parsedArgs.error)}` }],
155 isError: true,
156 }
157 }
158 const filePath = parsedArgs.data.path
159 const notebookFilter = parsedArgs.data.notebook
160 const blockIdFilter = parsedArgs.data.blockId
161 const pythonPath = parsedArgs.data.pythonPath
162 const inputs = parsedArgs.data.inputs
163 const dryRun = parsedArgs.data.dryRun
164 const includeOutputSummary = parsedArgs.data.includeOutputSummary !== false
165 const compact = parsedArgs.data.compact
166
167 // Load file (auto-converting if needed) and compose sibling init for native .deepnote files.
168 let resolved: Awaited<ReturnType<typeof resolveRunnableWithInit>>
169 try {
170 resolved = await resolveRunnableWithInit(filePath)
171 } catch (error) {
172 const message = error instanceof Error ? error.message : String(error)
173 let errorCode = getErrorCode(error)
174 if (errorCode === undefined) {
175 if (error instanceof InitNotebookResolutionError) {
176 errorCode = error.kind === 'multiple' ? 'INIT_NOTEBOOK_AMBIGUOUS' : 'INIT_NOTEBOOK_MISSING'
177 } else if (error instanceof LoadRunnableFileError) {
178 errorCode = 'LOAD_RUNNABLE_FILE'
179 }
180 }
181 return {
182 content: [
183 {
184 type: 'text',
185 text: JSON.stringify(
186 {
187 error: message,
188 ...(errorCode ? { code: errorCode } : {}),
189 },
190 null,
191 2
192 ),
193 },
194 ],
195 isError: true,
196 }
197 }
198
199 const { file, originalPath, format, wasConverted, warnings } = resolved
200
201 for (const warning of warnings) {
202 // biome-ignore lint/suspicious/noConsole: Intentional diagnostic logging to stderr
203 console.error(`[deepnote-mcp] ${warning}`)
204 }
205
206 // If blockId is specified, run just that block with its dependencies
207 if (blockIdFilter) {

Callers 1

handleExecutionToolFunction · 0.85

Calls 10

startMethod · 0.95
runProjectMethod · 0.95
stopMethod · 0.95
saveExecutionSnapshotFunction · 0.90
resolveRunnableWithInitFunction · 0.85
getErrorCodeFunction · 0.85
handleRunBlockFunction · 0.85
summarizeBlockOutputsFunction · 0.85
formatOutputFunction · 0.85
formatFirstIssueFunction · 0.70

Tested by

no test coverage detected