Skip to main content
Glama

pages

Manage Notion pages by creating, updating, archiving, restoring, duplicating, and retrieving markdown content through lifecycle operations.

Instructions

Page lifecycle: create, get, update, archive, restore, duplicate. Requires parent_id for create. Returns markdown content for get.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction to perform
page_idNoPage ID (required for most actions)
page_idsNoMultiple page IDs for batch operations
titleNoPage title
contentNoMarkdown content
append_contentNoMarkdown to append
prepend_contentNoMarkdown to prepend
parent_idNoParent page or database ID
propertiesNoPage properties (for database pages)
iconNoEmoji icon
coverNoCover image URL
archivedNoArchive status

Implementation Reference

  • Main exported handler function for the 'pages' tool. Dispatches to sub-functions based on input.action for create, get, update, archive/restore, duplicate operations.
    export async function pages(notion: Client, input: PagesInput): Promise<any> {
      return withErrorHandling(async () => {
        switch (input.action) {
          case 'create':
            return await createPage(notion, input)
    
          case 'get':
            return await getPage(notion, input)
    
          case 'update':
            return await updatePage(notion, input)
    
          case 'archive':
          case 'restore':
            return await archivePage(notion, input)
    
          case 'duplicate':
            return await duplicatePage(notion, input)
    
          default:
            throw new NotionMCPError(
              `Unknown action: ${input.action}`,
              'VALIDATION_ERROR',
              'Supported actions: create, get, update, archive, restore, move, duplicate'
            )
        }
      })()
    }
  • TypeScript interface defining the input schema for the pages tool.
    export interface PagesInput {
      action: 'create' | 'get' | 'update' | 'archive' | 'restore' | 'duplicate'
    
      // Common params
      page_id?: string
      page_ids?: string[]
    
      // Create/Update params
      title?: string
      content?: string // Markdown
      append_content?: string
      prepend_content?: string
      parent_id?: string
      properties?: Record<string, any>
      icon?: string
      cover?: string
    
      // Archive/Restore params
      archived?: boolean
    }
  • Tool registration in the TOOLS array, including name, description, and JSON inputSchema used by MCP.
    {
      name: 'pages',
      description:
        'Page lifecycle: create, get, update, archive, restore, duplicate. Requires parent_id for create. Returns markdown content for get.',
      inputSchema: {
        type: 'object',
        properties: {
          action: {
            type: 'string',
            enum: ['create', 'get', 'update', 'archive', 'restore', 'duplicate'],
            description: 'Action to perform'
          },
          page_id: { type: 'string', description: 'Page ID (required for most actions)' },
          page_ids: { type: 'array', items: { type: 'string' }, description: 'Multiple page IDs for batch operations' },
          title: { type: 'string', description: 'Page title' },
          content: { type: 'string', description: 'Markdown content' },
          append_content: { type: 'string', description: 'Markdown to append' },
          prepend_content: { type: 'string', description: 'Markdown to prepend' },
          parent_id: { type: 'string', description: 'Parent page or database ID' },
          properties: { type: 'object', description: 'Page properties (for database pages)' },
          icon: { type: 'string', description: 'Emoji icon' },
          cover: { type: 'string', description: 'Cover image URL' },
          archived: { type: 'boolean', description: 'Archive status' }
        },
        required: ['action']
      }
    },
  • Dispatch in CallToolRequestSchema handler that invokes the pages tool function.
    case 'pages':
      result = await pages(notion, args as any)
      break
  • Import statement for the pages handler from its implementation file.
    import { pages } from './composite/pages.js'

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/n24q02m/better-notion-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server