MCPcopy Index your code
hub / github.com/deepnote/deepnote / handleCreate

Function handleCreate

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

Source from the content-addressed store, hash-verified

436}
437
438async function handleCreate(args: Record<string, unknown>) {
439 const parsedArgs = createArgsSchema.safeParse(args)
440 if (!parsedArgs.success) {
441 return writingError(`Invalid args in handleCreate: ${formatFirstIssue(parsedArgs.error)}`)
442 }
443 const { outputPath, projectName, notebooks, dryRun } = parsedArgs.data
444
445 const projectId = randomUUID()
446
447 const file: DeepnoteFile = {
448 version: '1.0.0',
449 metadata: {
450 createdAt: new Date().toISOString(),
451 modifiedAt: new Date().toISOString(),
452 },
453 project: {
454 id: projectId,
455 name: projectName,
456 notebooks: notebooks.map(nb => {
457 const notebookId = randomUUID()
458 return {
459 id: notebookId,
460 name: nb.name,
461 blocks: nb.blocks.map((block, index) => createBlock(block, index)),
462 }
463 }),
464 },
465 }
466
467 if (dryRun) {
468 const content = serializeDeepnoteFile(file)
469 return {
470 content: [
471 {
472 type: 'text',
473 text: `Would create file at: ${outputPath}\n\nContent:\n${content}`,
474 },
475 ],
476 }
477 }
478
479 await saveDeepnoteFile(outputPath, file)
480
481 return {
482 content: [
483 {
484 type: 'text',
485 text: JSON.stringify(
486 {
487 success: true,
488 path: outputPath,
489 projectName,
490 notebookCount: notebooks.length,
491 totalBlocks: notebooks.reduce((sum, nb) => sum + nb.blocks.length, 0),
492 },
493 null,
494 2
495 ),

Callers 1

handleWritingToolFunction · 0.85

Calls 5

serializeDeepnoteFileFunction · 0.90
writingErrorFunction · 0.85
saveDeepnoteFileFunction · 0.85
formatFirstIssueFunction · 0.70
createBlockFunction · 0.70

Tested by

no test coverage detected