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

Function handleValidate

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

Source from the content-addressed store, hash-verified

429}
430
431async function handleValidate(args: Record<string, unknown>) {
432 const parsedArgs = validateArgsSchema.safeParse(args)
433 if (!parsedArgs.success) {
434 return {
435 content: [
436 { type: 'text', text: JSON.stringify({ valid: false, error: 'path is required and must be a string' }) },
437 ],
438 }
439 }
440 const filePath = parsedArgs.data.path
441
442 let absolutePath: string
443 let rawBytes: Buffer
444
445 try {
446 absolutePath = path.resolve(filePath)
447 rawBytes = await fs.readFile(absolutePath)
448 } catch (error) {
449 const message = error instanceof Error ? error.message : String(error)
450 return {
451 content: [
452 {
453 type: 'text',
454 text: JSON.stringify({ path: filePath, valid: false, error: `Cannot read file: ${message}` }),
455 },
456 ],
457 }
458 }
459
460 // Parse YAML
461 const yamlContent = decodeUtf8NoBom(rawBytes)
462 let parsed: unknown
463 try {
464 parsed = parseYaml(yamlContent)
465 } catch (error) {
466 const message = error instanceof Error ? error.message : String(error)
467 return {
468 content: [
469 {
470 type: 'text',
471 text: JSON.stringify({
472 path: absolutePath,
473 valid: false,
474 issues: [{ path: '', message: `Invalid YAML: ${message}`, code: 'yaml_parse_error' }],
475 }),
476 },
477 ],
478 }
479 }
480
481 // Validate against schema
482 const result = deepnoteFileSchema.safeParse(parsed)
483
484 if (result.success) {
485 return {
486 content: [
487 {
488 type: 'text',

Callers 1

handleReadingToolFunction · 0.85

Calls 2

decodeUtf8NoBomFunction · 0.90
parseYamlFunction · 0.90

Tested by

no test coverage detected