UNPKG

systemprompt-mcp-notion

Version:

A specialized Model Context Protocol (MCP) server that integrates Notion into your AI workflows. This server enables seamless access to Notion through MCP, allowing AI agents to interact with pages, databases, and comments.

676 lines (659 loc) 26 kB
// Validate arguments at compile time const createPageArgs = [ { name: "databaseId", description: "The ID of the database to create the page in", required: true, }, { name: "userInstructions", description: "Basic instructions or outline for the page content that will be expanded into a comprehensive structure", required: true, }, ]; export const NOTION_PAGE_CREATOR_INSTRUCTIONS = `You are an expert at creating Notion pages using the Notion API. Your task is to generate a rich, detailed Notion API request that expands upon basic user instructions to create comprehensive, well-structured pages. INPUT PARAMETERS: The user message will include these parameters: 1. databaseId: The ID of the database to create the page in (required) 2. userInstructions: Basic guidance for creating the page (required) YOUR ROLE: You should act as a content enhancer and structure expert by: 1. Taking the basic instructions and expanding them into a comprehensive page structure 2. Breaking down simple content into well-organized sections with appropriate headers 3. Adding relevant supplementary sections where appropriate 4. Using the full range of Notion blocks to create engaging, readable content 5. Maintaining the original intent while adding depth and clarity PARAMETER HANDLING: 1. Instructions: Parse the userInstructions to determine: - The page title (required) - The intended purpose and scope of the page - Opportunities for additional relevant sections 2. Content Enhancement: - Break content into logical sections with clear headers - Add appropriate formatting and structure - Include supplementary sections where valuable - Use varied block types to improve readability RESPONSE FORMAT: You must return a valid JSON object that matches this exact schema: { "parent": { "database_id": string, // ID of the database to create the page in }, "properties": { "title": [{ "text": { "content": string // Extract title from user instructions } }] }, "children": [ // Array of content blocks { "object": "block", "type": string, // The block type (paragraph, heading_1, etc.) [blockType]: { // Object matching the block type "rich_text": [{ "text": { "content": string // The block's content } }] } } ] } CONTENT FORMATTING RULES: 1. Title: Create a clear, descriptive title that captures the page's purpose 2. Structure: Create a logical hierarchy of content using: - heading_1 for main sections - heading_2 for subsections - heading_3 for detailed breakdowns 3. Content Enhancement: - Break long paragraphs into digestible chunks - Use bulleted_list_item for key points and features - Use numbered_list_item for sequential steps or priorities - Use quote blocks to highlight important information - Use code blocks for technical content - Use toggle blocks for supplementary information 4. Rich Text: Always wrap text content in the rich_text array format BLOCK TYPE REFERENCE: - paragraph: Regular text content - heading_1/2/3: Section headers (3 levels) - bulleted_list_item: Unordered list items - numbered_list_item: Ordered list items - to_do: Checkable items (- [ ] or - [x]) - toggle: Collapsible content - code: Code snippets with syntax highlighting - quote: Block quotes Remember: Your goal is to create a comprehensive, well-structured page that expands upon the basic input while maintaining its core purpose. Don't just replicate the input - enhance it with appropriate structure and supplementary content.`; export const NOTION_PAGE_CREATOR_SCHEMA = { type: "object", required: ["parent", "properties"], additionalProperties: false, properties: { parent: { type: "object", properties: { database_id: { type: "string", description: "The ID of the database to create the page in", }, }, required: ["database_id"], additionalProperties: false, }, properties: { type: "object", required: ["title"], additionalProperties: false, properties: { title: { type: "array", items: { type: "object", required: ["text"], additionalProperties: false, properties: { text: { type: "object", required: ["content"], additionalProperties: false, properties: { content: { type: "string", description: "The title text of the page", }, }, }, }, }, }, }, }, children: { type: "array", items: { type: "object", required: ["object", "type"], properties: { object: { type: "string", const: "block", }, type: { type: "string", enum: [ "paragraph", "heading_1", "heading_2", "heading_3", "bulleted_list_item", "numbered_list_item", "to_do", "toggle", "code", "quote", ], }, }, allOf: [ { if: { properties: { type: { const: "paragraph" } } }, then: { required: ["paragraph"], properties: { paragraph: { $ref: "#/definitions/richTextBlock" }, }, }, }, { if: { properties: { type: { const: "heading_1" } } }, then: { required: ["heading_1"], properties: { heading_1: { $ref: "#/definitions/richTextBlock" }, }, }, }, { if: { properties: { type: { const: "heading_2" } } }, then: { required: ["heading_2"], properties: { heading_2: { $ref: "#/definitions/richTextBlock" }, }, }, }, { if: { properties: { type: { const: "heading_3" } } }, then: { required: ["heading_3"], properties: { heading_3: { $ref: "#/definitions/richTextBlock" }, }, }, }, { if: { properties: { type: { const: "bulleted_list_item" } } }, then: { required: ["bulleted_list_item"], properties: { bulleted_list_item: { $ref: "#/definitions/richTextBlock" }, }, }, }, { if: { properties: { type: { const: "numbered_list_item" } } }, then: { required: ["numbered_list_item"], properties: { numbered_list_item: { $ref: "#/definitions/richTextBlock" }, }, }, }, { if: { properties: { type: { const: "to_do" } } }, then: { required: ["to_do"], properties: { to_do: { type: "object", required: ["rich_text", "checked"], additionalProperties: false, properties: { rich_text: { $ref: "#/definitions/richTextArray" }, checked: { type: "boolean", description: "Whether the to-do is checked", }, }, }, }, }, }, { if: { properties: { type: { const: "toggle" } } }, then: { required: ["toggle"], properties: { toggle: { $ref: "#/definitions/richTextBlock" } }, }, }, { if: { properties: { type: { const: "code" } } }, then: { required: ["code"], properties: { code: { type: "object", required: ["rich_text", "language"], additionalProperties: false, properties: { rich_text: { $ref: "#/definitions/richTextArray" }, language: { type: "string", description: "The programming language of the code block", }, }, }, }, }, }, { if: { properties: { type: { const: "quote" } } }, then: { required: ["quote"], properties: { quote: { $ref: "#/definitions/richTextBlock" } }, }, }, ], }, }, }, definitions: { richTextBlock: { type: "object", required: ["rich_text"], additionalProperties: false, properties: { rich_text: { $ref: "#/definitions/richTextArray" }, }, }, richTextArray: { type: "array", items: { type: "object", required: ["text"], additionalProperties: false, properties: { text: { type: "object", required: ["content"], additionalProperties: false, properties: { content: { type: "string", description: "The text content", }, }, }, }, }, }, }, }; export const NOTION_PAGE_CREATOR_PROMPT = { name: "Notion Page Creator", description: "Generates a rich, detailed Notion page that expands upon basic inputs into comprehensive, well-structured content", arguments: createPageArgs, messages: [ { role: "assistant", content: { type: "text", text: NOTION_PAGE_CREATOR_INSTRUCTIONS, }, }, { role: "user", content: { type: "text", text: ` <input> <requestParams> <databaseId>{{databaseId}}</databaseId> <userInstructions>{{userInstructions}}</userInstructions> </requestParams> </input>`, }, }, ], _meta: { complexResponseSchema: NOTION_PAGE_CREATOR_SCHEMA, callback: "systemprompt_create_notion_page_complex", }, }; export const NOTION_PAGE_EDITOR_SCHEMA = { type: "object", required: ["pageId", "properties", "children"], additionalProperties: false, properties: { pageId: { type: "string", description: "The ID of the page to edit", }, properties: { type: "object", required: ["title"], additionalProperties: false, properties: { title: { type: "array", items: { type: "object", required: ["text"], additionalProperties: false, properties: { text: { type: "object", required: ["content"], additionalProperties: false, properties: { content: { type: "string", description: "The title text of the page", }, }, }, }, }, }, }, }, children: { type: "array", items: { type: "object", required: ["object", "type"], properties: { object: { type: "string", const: "block", }, type: { type: "string", enum: [ "paragraph", "heading_1", "heading_2", "heading_3", "bulleted_list_item", "numbered_list_item", "to_do", "toggle", "code", "quote", ], }, }, allOf: [ { if: { properties: { type: { const: "paragraph" } } }, then: { required: ["paragraph"], properties: { paragraph: { $ref: "#/definitions/richTextBlock" }, }, }, }, { if: { properties: { type: { const: "heading_1" } } }, then: { required: ["heading_1"], properties: { heading_1: { $ref: "#/definitions/richTextBlock" }, }, }, }, { if: { properties: { type: { const: "heading_2" } } }, then: { required: ["heading_2"], properties: { heading_2: { $ref: "#/definitions/richTextBlock" }, }, }, }, { if: { properties: { type: { const: "heading_3" } } }, then: { required: ["heading_3"], properties: { heading_3: { $ref: "#/definitions/richTextBlock" }, }, }, }, { if: { properties: { type: { const: "bulleted_list_item" } } }, then: { required: ["bulleted_list_item"], properties: { bulleted_list_item: { $ref: "#/definitions/richTextBlock" }, }, }, }, { if: { properties: { type: { const: "numbered_list_item" } } }, then: { required: ["numbered_list_item"], properties: { numbered_list_item: { $ref: "#/definitions/richTextBlock" }, }, }, }, { if: { properties: { type: { const: "to_do" } } }, then: { required: ["to_do"], properties: { to_do: { type: "object", required: ["rich_text", "checked"], additionalProperties: false, properties: { rich_text: { $ref: "#/definitions/richTextArray" }, checked: { type: "boolean", description: "Whether the to-do is checked", }, }, }, }, }, }, { if: { properties: { type: { const: "toggle" } } }, then: { required: ["toggle"], properties: { toggle: { $ref: "#/definitions/richTextBlock" } }, }, }, { if: { properties: { type: { const: "code" } } }, then: { required: ["code"], properties: { code: { type: "object", required: ["rich_text", "language"], additionalProperties: false, properties: { rich_text: { $ref: "#/definitions/richTextArray" }, language: { type: "string", description: "The programming language of the code block", }, }, }, }, }, }, { if: { properties: { type: { const: "quote" } } }, then: { required: ["quote"], properties: { quote: { $ref: "#/definitions/richTextBlock" } }, }, }, ], }, }, }, definitions: { richTextBlock: { type: "object", required: ["rich_text"], additionalProperties: false, properties: { rich_text: { $ref: "#/definitions/richTextArray" }, }, }, richTextArray: { type: "array", items: { type: "object", required: ["text"], additionalProperties: false, properties: { text: { type: "object", required: ["content"], additionalProperties: false, properties: { content: { type: "string", description: "The text content", }, }, }, }, }, }, }, }; export const NOTION_PAGE_EDITOR_INSTRUCTIONS = `You are an expert at editing Notion pages using the Notion API. Your task is to generate a rich, detailed Notion API request that updates an existing page based on user instructions. INPUT PARAMETERS: The user message will include these parameters: 1. pageId: The ID of the page to edit (required) 2. userInstructions: Basic guidance for editing the page (required) YOUR ROLE: You should act as a content enhancer and structure expert by: 1. Taking the basic instructions and transforming them into a comprehensive page update 2. Breaking down content into well-organized sections with appropriate headers 3. Adding relevant supplementary sections where appropriate 4. Using the full range of Notion blocks to create engaging, readable content 5. Maintaining the original intent while adding depth and clarity PARAMETER HANDLING: 1. Instructions: Parse the userInstructions to determine: - The updated page title (if needed) - The intended changes and scope - Opportunities for additional relevant sections 2. Content Enhancement: - Break content into logical sections with clear headers - Add appropriate formatting and structure - Include supplementary sections where valuable - Use varied block types to improve readability RESPONSE FORMAT: You must return a valid JSON object that matches this exact schema: { "pageId": string, // ID of the page to edit "properties": { "title": [{ "text": { "content": string // Updated title from user instructions } }] }, "children": [ // Array of content blocks { "object": "block", "type": string, // The block type (paragraph, heading_1, etc.) [blockType]: { // Object matching the block type "rich_text": [{ "text": { "content": string // The block's content } }] } } ] } CONTENT FORMATTING RULES: 1. Title: Update the title if specified in instructions 2. Structure: Create a logical hierarchy of content using: - heading_1 for main sections - heading_2 for subsections - heading_3 for detailed breakdowns 3. Content Enhancement: - Break long paragraphs into digestible chunks - Use bulleted_list_item for key points and features - Use numbered_list_item for sequential steps or priorities - Use quote blocks to highlight important information - Use code blocks for technical content - Use toggle blocks for supplementary information 4. Rich Text: Always wrap text content in the rich_text array format BLOCK TYPE REFERENCE: - paragraph: Regular text content - heading_1/2/3: Section headers (3 levels) - bulleted_list_item: Unordered list items - numbered_list_item: Ordered list items - to_do: Checkable items (- [ ] or - [x]) - toggle: Collapsible content - code: Code snippets with syntax highlighting - quote: Block quotes Remember: Your goal is to update the page while maintaining its core purpose and enhancing it with appropriate structure and supplementary content.`; // Validate arguments at compile time const editPageArgs = [ { name: "pageId", description: "The ID of the page to edit", required: true, }, { name: "userInstructions", description: "Basic instructions for editing the page that will be expanded into a comprehensive structure", required: true, }, ]; export const NOTION_PAGE_EDITOR_PROMPT = { name: "Notion Page Editor", description: "Updates a Notion page with rich, detailed content that expands upon basic inputs into comprehensive, well-structured content", arguments: editPageArgs, messages: [ { role: "assistant", content: { type: "text", text: NOTION_PAGE_EDITOR_INSTRUCTIONS, }, }, { role: "user", content: { type: "text", text: ` <input> <requestParams> <pageId>{{pageId}}</pageId> <userInstructions>{{userInstructions}}</userInstructions> </requestParams> </input>`, }, }, ], _meta: { complexResponseSchema: NOTION_PAGE_EDITOR_SCHEMA, callback: "systemprompt_edit_notion_page_complex", }, }; export const NOTION_PROMPTS = [ NOTION_PAGE_CREATOR_PROMPT, NOTION_PAGE_EDITOR_PROMPT, ];