content_convert
Convert content between markdown and Notion blocks to enable content migration and formatting within the Notion workspace.
Instructions
Convert: markdown-to-blocks, blocks-to-markdown. Most tools handle markdown automatically.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| direction | Yes | Conversion direction | |
| content | Yes | Content to convert (string or array/JSON string) |
Implementation Reference
- src/tools/composite/content.ts:17-57 (handler)The main handler function that implements the content_convert tool, converting between Markdown strings and Notion block arrays based on the direction parameter.export async function contentConvert(input: ContentConvertInput): Promise<any> { return withErrorHandling(async () => { switch (input.direction) { case 'markdown-to-blocks': { if (typeof input.content !== 'string') { throw new Error('Content must be a string for markdown-to-blocks') } const blocks = markdownToBlocks(input.content) return { direction: input.direction, block_count: blocks.length, blocks } } case 'blocks-to-markdown': { let content = input.content // Parse JSON string if needed if (typeof content === 'string') { try { content = JSON.parse(content) } catch { throw new Error('Content must be a valid JSON array or array object for blocks-to-markdown') } } if (!Array.isArray(content)) { throw new Error('Content must be an array for blocks-to-markdown') } const markdown = blocksToMarkdown(content as any) return { direction: input.direction, char_count: markdown.length, markdown } } default: throw new Error(`Unsupported direction: ${input.direction}`) } })() }
- src/tools/composite/content.ts:9-12 (schema)TypeScript interface defining the expected input shape for the contentConvert handler.export interface ContentConvertInput { direction: 'markdown-to-blocks' | 'blocks-to-markdown' content: string | any[] }
- src/tools/registry.ts:204-219 (registration)MCP tool registration in the TOOLS array, defining name, description, and input schema for content_convert.{ name: 'content_convert', description: 'Convert: markdown-to-blocks, blocks-to-markdown. Most tools handle markdown automatically.', inputSchema: { type: 'object', properties: { direction: { type: 'string', enum: ['markdown-to-blocks', 'blocks-to-markdown'], description: 'Conversion direction' }, content: { description: 'Content to convert (string or array/JSON string)' } }, required: ['direction', 'content'] } },
- src/tools/registry.ts:314-316 (registration)Dispatch logic in the tool call handler that invokes the contentConvert function.case 'content_convert': result = await contentConvert(args as any) break
- src/tools/registry.ts:21-21 (registration)Import statement bringing the contentConvert handler into the registry module.import { contentConvert } from './composite/content.js'