export_markdown
Convert Tiptap JSON content into Markdown or GitHub Flavored Markdown (GFM) format using the Tiptap Conversion API, enabling structured document export for collaborative workflows.
Instructions
Convert Tiptap JSON content to Markdown format using the Tiptap Conversion API
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appId | Yes | Your Tiptap App ID for the conversion service | |
| content | Yes | Tiptap JSON content to convert to Markdown | |
| format | No | Output format: md (standard) or gfm (GitHub Flavored Markdown). Default: md |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"appId": {
"description": "Your Tiptap App ID for the conversion service",
"type": "string"
},
"content": {
"additionalProperties": false,
"description": "Tiptap JSON content to convert to Markdown",
"properties": {},
"type": "object"
},
"format": {
"description": "Output format: md (standard) or gfm (GitHub Flavored Markdown). Default: md",
"enum": [
"md",
"gfm"
],
"type": "string"
}
},
"required": [
"content",
"appId"
],
"type": "object"
}
Implementation Reference
- src/tools/export-markdown.ts:17-67 (handler)The handler function that calls the Tiptap conversion API to export JSON content to Markdown or GFM format, handling errors and returning formatted text content.async ({ content, format = 'md', appId }) => { try { const headers: Record<string, string> = { 'User-Agent': 'tiptap-collaboration-mcp', 'Content-Type': 'application/json', 'X-App-Id': appId, }; const token = getToken(); if (token) headers['Authorization'] = `Bearer ${token}`; const response = await fetch(`${getBaseUrl()}/api/convert/export`, { method: 'POST', headers, body: JSON.stringify({ content, format }), }); if (!response.ok) { return { content: [ { type: 'text', text: `Failed to export to markdown. HTTP error: ${response.status} ${response.statusText}. Make sure you have a valid JWT token and App ID for the Tiptap Conversion service.`, }, ], }; } const markdownContent = await response.text(); return { content: [ { type: 'text', text: `Tiptap JSON exported to ${format.toUpperCase()} successfully:\n\n${markdownContent}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error exporting to markdown: ${ error instanceof Error ? error.message : 'Unknown error' }`, }, ], }; } }
- src/tools/export-markdown.ts:12-16 (schema)Zod schema defining input parameters: content (Tiptap JSON), optional format (md/gfm), and appId.{ content: z.object({}).describe('Tiptap JSON content to convert to Markdown'), format: z.enum(['md', 'gfm']).optional().describe('Output format: md (standard) or gfm (GitHub Flavored Markdown). Default: md'), appId: z.string().describe('Your Tiptap App ID for the conversion service'), },
- src/tools/export-markdown.ts:4-69 (registration)The registration function that defines and registers the 'export-markdown' tool on the MCP server, including schema and handler.export default function registerExportMarkdown( server: McpServer, getBaseUrl: () => string, getToken: () => string | undefined ) { server.tool( 'export-markdown', 'Export Tiptap JSON content to Markdown format', { content: z.object({}).describe('Tiptap JSON content to convert to Markdown'), format: z.enum(['md', 'gfm']).optional().describe('Output format: md (standard) or gfm (GitHub Flavored Markdown). Default: md'), appId: z.string().describe('Your Tiptap App ID for the conversion service'), }, async ({ content, format = 'md', appId }) => { try { const headers: Record<string, string> = { 'User-Agent': 'tiptap-collaboration-mcp', 'Content-Type': 'application/json', 'X-App-Id': appId, }; const token = getToken(); if (token) headers['Authorization'] = `Bearer ${token}`; const response = await fetch(`${getBaseUrl()}/api/convert/export`, { method: 'POST', headers, body: JSON.stringify({ content, format }), }); if (!response.ok) { return { content: [ { type: 'text', text: `Failed to export to markdown. HTTP error: ${response.status} ${response.statusText}. Make sure you have a valid JWT token and App ID for the Tiptap Conversion service.`, }, ], }; } const markdownContent = await response.text(); return { content: [ { type: 'text', text: `Tiptap JSON exported to ${format.toUpperCase()} successfully:\n\n${markdownContent}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error exporting to markdown: ${ error instanceof Error ? error.message : 'Unknown error' }`, }, ], }; } } ); }
- src/server.ts:51-51 (registration)Invocation of the registerExportMarkdown function to register the tool on the main server instance.registerExportMarkdown(server, getBaseUrl, getToken);