exportWhiteboard
Export Heptabase whiteboards in markdown, JSON, or HTML formats with customizable options to include cards, connections, and metadata for efficient data retrieval and analysis.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | markdown | |
| includeCards | No | ||
| includeConnections | No | ||
| includeMetadata | No | ||
| outputPath | Yes | ||
| whiteboardId | Yes |
Implementation Reference
- src/tools/export.ts:21-58 (handler)Core handler function that retrieves whiteboard data, generates export content in markdown/json/html format, writes it to the specified output path, and returns a confirmation message.export async function exportWhiteboard( dataService: HeptabaseDataService, params: z.infer<typeof exportWhiteboardSchema> ) { const data = await dataService.getWhiteboard(params.whiteboardId, { includeCards: params.includeCards, includeConnections: params.includeConnections }); let content = ''; switch (params.format) { case 'markdown': content = await generateMarkdownExport(data, params); break; case 'json': content = JSON.stringify(data, null, 2); break; case 'html': content = await generateHtmlExport(data, params); break; } await fs.mkdir(path.dirname(params.outputPath), { recursive: true }); await fs.writeFile(params.outputPath, content, 'utf8'); const response = [`Exported whiteboard to ${params.outputPath}`]; if (params.includeMetadata) { response.push('Included metadata in export'); } return { content: [{ type: 'text', text: response.join('\n') }] }; }
- src/tools/export.ts:6-13 (schema)Zod schema defining the input parameters for the exportWhiteboard tool, including whiteboard ID, format options, inclusion flags, and output path.export const exportWhiteboardSchema = z.object({ whiteboardId: z.string(), format: z.enum(['markdown', 'json', 'html']).optional().default('markdown'), includeCards: z.boolean().optional().default(true), includeConnections: z.boolean().optional().default(false), includeMetadata: z.boolean().optional().default(false), outputPath: z.string() });
- src/server.ts:671-681 (registration)Registers the exportWhiteboard tool with the MCP server, including schema and wrapper handler that ensures data service initialization before calling the core export function.this.tools.exportWhiteboard = { inputSchema: exportWhiteboardSchema, handler: async (params) => { await this.ensureDataServiceInitialized(); return exportWhiteboard(this.dataService, params); } }; this.server.tool('exportWhiteboard', exportWhiteboardSchema.shape, async (params: z.infer<typeof exportWhiteboardSchema>) => { return this.tools.exportWhiteboard.handler(params); });
- src/tools/export.ts:85-124 (helper)Helper function to generate markdown export content from whiteboard data, including title, metadata, cards, and connections.async function generateMarkdownExport(data: any, params: any): Promise<string> { const lines: string[] = []; lines.push(`# ${data.whiteboard.name}`); lines.push(''); if (params.includeMetadata) { lines.push('## Metadata'); lines.push(`- Created: ${data.whiteboard.createdTime}`); lines.push(`- Last Modified: ${data.whiteboard.lastEditedTime}`); lines.push(`- Created By: ${data.whiteboard.createdBy}`); lines.push(''); } if (data.cards?.length > 0) { lines.push('## Cards'); lines.push(''); for (const card of data.cards) { lines.push(`### ${card.title}`); const content = JSON.parse(card.content); const text = extractTextFromContent(content); lines.push(text); lines.push(''); } } if (data.connections?.length > 0) { lines.push('## Connections'); lines.push(''); for (const connection of data.connections) { lines.push(`- ${connection.beginId} → ${connection.endId}`); } lines.push(''); } return lines.join('\n'); }