MCPcopy
hub / github.com/deepnote/deepnote / handleRunBlock

Function handleRunBlock

packages/mcp/src/tools/execution.ts:375–477  ·  view source on GitHub ↗

* Run a single block by ID within an already-loaded file. * Called from handleRun when blockId is specified.

(
  file: DeepnoteFile,
  originalPath: string,
  blockId: string,
  notebookFilter: string | undefined,
  pythonPath: string | undefined,
  inputs: Record<string, unknown> | undefined,
  options: { dryRun: boolean }
)

Source from the content-addressed store, hash-verified

373 * Called from handleRun when blockId is specified.
374 */
375async function handleRunBlock(
376 file: DeepnoteFile,
377 originalPath: string,
378 blockId: string,
379 notebookFilter: string | undefined,
380 pythonPath: string | undefined,
381 inputs: Record<string, unknown> | undefined,
382 options: { dryRun: boolean }
383) {
384 // Find the block
385 let targetBlock = null
386 let targetNotebook = null
387
388 for (const notebook of file.project.notebooks) {
389 if (notebookFilter && notebook.name !== notebookFilter && notebook.id !== notebookFilter) {
390 continue
391 }
392 const block = notebook.blocks.find(b => b.id === blockId || b.id.startsWith(blockId))
393 if (block) {
394 targetBlock = block
395 targetNotebook = notebook
396 break
397 }
398 }
399
400 if (!targetBlock || !targetNotebook) {
401 return {
402 content: [{ type: 'text', text: `Block not found: ${blockId}` }],
403 isError: true,
404 }
405 }
406
407 if (options.dryRun) {
408 return {
409 content: [
410 {
411 type: 'text',
412 text: JSON.stringify(
413 {
414 dryRun: true,
415 level: 'block',
416 notebook: targetNotebook.name,
417 block: {
418 id: targetBlock.id.slice(0, 8),
419 fullId: targetBlock.id,
420 type: targetBlock.type,
421 },
422 inputs: inputs || {},
423 },
424 null,
425 2
426 ),
427 },
428 ],
429 }
430 }
431
432 // Run the specific block

Callers 1

handleRunFunction · 0.85

Calls 3

startMethod · 0.95
runProjectMethod · 0.95
stopMethod · 0.95

Tested by

no test coverage detected