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

Function handleSnapshotList

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

Source from the content-addressed store, hash-verified

208]
209
210async function handleSnapshotList(args: Record<string, unknown>) {
211 if (args.path === undefined) {
212 return snapshotError('path is required')
213 }
214 const parsedArgs = snapshotListArgsSchema.safeParse(args)
215 if (!parsedArgs.success) {
216 return snapshotError(`Invalid arguments for deepnote_snapshot_list: ${formatFirstIssue(parsedArgs.error)}`)
217 }
218 const { path: filePath, snapshotDir } = parsedArgs.data
219
220 try {
221 const absolutePath = path.resolve(filePath)
222 const projectDir = path.dirname(absolutePath)
223
224 // Read file to get the project ID
225 const content = await fs.readFile(absolutePath, 'utf-8')
226 const file = deserializeDeepnoteFile(content)
227 const projectId = file.project.id
228
229 const notebookId = resolveSnapshotNotebookId(file)
230 const snapshotOptions = { ...(snapshotDir ? { snapshotDir } : {}), ...(notebookId ? { notebookId } : {}) }
231 const snapshots = await findSnapshotsForProject(projectDir, projectId, snapshotOptions)
232 const resolvedSnapshotDir = snapshotDir ? snapshotDir : path.join(projectDir, 'snapshots')
233
234 return {
235 content: [
236 {
237 type: 'text',
238 text: JSON.stringify(
239 {
240 sourcePath: absolutePath,
241 snapshotDir: resolvedSnapshotDir,
242 snapshotsFound: snapshots.length,
243 snapshots: snapshots.map(s => ({
244 path: s.path,
245 slug: s.slug,
246 projectId: s.projectId,
247 timestamp: s.timestamp,
248 isLatest: s.timestamp === 'latest',
249 })),
250 },
251 null,
252 2
253 ),
254 },
255 ],
256 }
257 } catch (error) {
258 const message = error instanceof Error ? error.message : String(error)
259 return {
260 content: [{ type: 'text', text: JSON.stringify({ error: message }) }],
261 }
262 }
263}
264
265async function handleSnapshotLoad(args: Record<string, unknown>) {
266 if (args.path === undefined) {

Callers 1

handleSnapshotToolFunction · 0.85

Calls 5

deserializeDeepnoteFileFunction · 0.90
findSnapshotsForProjectFunction · 0.90
snapshotErrorFunction · 0.85
formatFirstIssueFunction · 0.70

Tested by

no test coverage detected