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.
334 lines (333 loc) • 10.7 kB
JavaScript
// Common schema definitions for rich text blocks
const richTextBlockDef = {
type: "object",
required: ["rich_text"],
additionalProperties: false,
properties: {
rich_text: { $ref: "#/definitions/richTextArray" },
},
};
const richTextArrayDef = {
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",
},
},
},
},
},
};
// Base schema for page content blocks
const pageBlocksSchema = {
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: {
type: "object",
properties: {
type: { const: "paragraph" },
},
},
then: {
type: "object",
required: ["paragraph"],
properties: {
paragraph: { $ref: "#/definitions/richTextBlock" },
},
},
},
{
if: {
type: "object",
properties: {
type: { const: "heading_1" },
},
},
then: {
type: "object",
required: ["heading_1"],
properties: {
heading_1: { $ref: "#/definitions/richTextBlock" },
},
},
},
{
if: {
type: "object",
properties: {
type: { const: "heading_2" },
},
},
then: {
type: "object",
required: ["heading_2"],
properties: {
heading_2: { $ref: "#/definitions/richTextBlock" },
},
},
},
{
if: {
type: "object",
properties: {
type: { const: "heading_3" },
},
},
then: {
type: "object",
required: ["heading_3"],
properties: {
heading_3: { $ref: "#/definitions/richTextBlock" },
},
},
},
{
if: {
type: "object",
properties: {
type: { const: "bulleted_list_item" },
},
},
then: {
type: "object",
required: ["bulleted_list_item"],
properties: {
bulleted_list_item: { $ref: "#/definitions/richTextBlock" },
},
},
},
{
if: {
type: "object",
properties: {
type: { const: "numbered_list_item" },
},
},
then: {
type: "object",
required: ["numbered_list_item"],
properties: {
numbered_list_item: { $ref: "#/definitions/richTextBlock" },
},
},
},
{
if: {
type: "object",
properties: {
type: { const: "to_do" },
},
},
then: {
type: "object",
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: {
type: "object",
properties: {
type: { const: "toggle" },
},
},
then: {
type: "object",
required: ["toggle"],
properties: {
toggle: { $ref: "#/definitions/richTextBlock" },
},
},
},
{
if: {
type: "object",
properties: {
type: { const: "code" },
},
},
then: {
type: "object",
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: {
type: "object",
properties: {
type: { const: "quote" },
},
},
then: {
type: "object",
required: ["quote"],
properties: {
quote: { $ref: "#/definitions/richTextBlock" },
},
},
},
],
},
};
// Schema for creating new pages
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: pageBlocksSchema,
},
definitions: {
richTextBlock: richTextBlockDef,
richTextArray: richTextArrayDef,
},
};
// Schema for editing existing pages
export const NOTION_PAGE_EDITOR_SCHEMA = {
type: "object",
required: ["pageId"],
additionalProperties: false,
properties: {
pageId: {
type: "string",
description: "The ID of the page to edit",
pattern: "^[a-f0-9-]+$",
},
archived: {
type: "boolean",
description: "Whether to archive the page",
},
properties: {
type: "object",
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: pageBlocksSchema,
},
definitions: {
richTextBlock: richTextBlockDef,
richTextArray: richTextArrayDef,
},
};