create-link-preview
Generate and embed link previews in Notion pages by providing a URL and page ID to display content summaries directly within your workspace.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The URL to create a preview for | |
| page_id | No | The ID of the page to add the preview to |
Implementation Reference
- src/lib/mcp-server.ts:797-827 (handler)The main handler function for the 'create-link-preview' tool. It invokes the NotionService to create the link preview and returns a formatted text content response or an error message.async ({ url, page_id }) => { try { const result = await this.notionService.createLinkPreview({ url, page_id, }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { console.error("Error in create-link-preview tool:", error); return { content: [ { type: "text", text: `Error: Failed to create link preview - ${ (error as Error).message }`, }, ], isError: true, }; } } );
- src/lib/mcp-server.ts:786-828 (registration)The registerLinkPreviewTools method where the 'create-link-preview' tool is registered with the MCP server, including inline schema and handler.private registerLinkPreviewTools(): void { // Create link preview this.server.tool( "create-link-preview", { url: z.string().url().describe("The URL to create a preview for"), page_id: z .string() .optional() .describe("The ID of the page to add the preview to"), }, async ({ url, page_id }) => { try { const result = await this.notionService.createLinkPreview({ url, page_id, }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { console.error("Error in create-link-preview tool:", error); return { content: [ { type: "text", text: `Error: Failed to create link preview - ${ (error as Error).message }`, }, ], isError: true, }; } } ); }
- src/lib/mcp-server.ts:790-796 (schema)Inline Zod schema defining input parameters for the create-link-preview tool.{ url: z.string().url().describe("The URL to create a preview for"), page_id: z .string() .optional() .describe("The ID of the page to add the preview to"), },
- src/types/notion.ts:134-139 (schema)Zod schema and TypeScript type for LinkPreview parameters, matching the tool input schema and used in NotionService.createLinkPreview.export const LinkPreviewSchema = z.object({ url: z.string().url(), page_id: z.string().optional(), }); export type LinkPreview = z.infer<typeof LinkPreviewSchema>;
- src/lib/notion.ts:353-364 (helper)Supporting method in NotionService called by the tool handler. Currently a placeholder that throws an error as the feature is not implemented in the Notion SDK.async createLinkPreview(params: LinkPreview) { try { // The Notion API doesn't have a direct method for link previews yet // This is a placeholder for when the feature becomes available in the SDK throw new NotionAPIError( "Link Preview API is not yet available in the official Notion SDK", "NOT_IMPLEMENTED" ); } catch (error) { this.handleError(error); } }