Skip to main content
Glama

comments

Manage Notion page discussions by listing existing comments or creating new ones, using page_id for new discussions and discussion_id for replies.

Instructions

Comments: list, create. Use page_id for new discussion, discussion_id for replies.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
page_idNoPage ID
discussion_idNoDiscussion ID (for replies)
actionYesAction to perform
contentNoComment content (for create)

Implementation Reference

  • The main handler function commentsManage that executes the tool logic for listing comments on a page or creating new comments/replies.
    export async function commentsManage(notion: Client, input: CommentsManageInput): Promise<any> { return withErrorHandling(async () => { switch (input.action) { case 'list': { if (!input.page_id) { throw new Error('page_id required for list action') } const comments = await autoPaginate(async (cursor) => { return await (notion.comments as any).list({ block_id: input.page_id, start_cursor: cursor }) }) return { page_id: input.page_id, total_comments: comments.length, comments: comments.map((comment: any) => ({ id: comment.id, created_time: comment.created_time, created_by: comment.created_by, discussion_id: comment.discussion_id, text: RichText.extractPlainText(comment.rich_text), parent: comment.parent })) } } case 'create': { if (!input.content) { throw new Error('content required for create action') } // Either page_id or discussion_id must be provided if (!input.page_id && !input.discussion_id) { throw new Error('Either page_id or discussion_id is required for create action') } const createParams: any = { rich_text: [RichText.text(input.content)] } // Add parent or discussion_id based on input if (input.discussion_id) { createParams.discussion_id = input.discussion_id } else { createParams.parent = { page_id: input.page_id } } const comment = await (notion.comments as any).create(createParams) return { comment_id: comment.id, discussion_id: comment.discussion_id, created: true } } default: throw new Error(`Unsupported action: ${input.action}`) } })() }
  • TypeScript interface defining the input schema for the comments tool.
    export interface CommentsManageInput { page_id?: string discussion_id?: string action: 'list' | 'create' content?: string // For create action }
  • MCP tool registration including name, description, and inputSchema for the 'comments' tool.
    { name: 'comments', description: 'Comments: list, create. Use page_id for new discussion, discussion_id for replies.', inputSchema: { type: 'object', properties: { page_id: { type: 'string', description: 'Page ID' }, discussion_id: { type: 'string', description: 'Discussion ID (for replies)' }, action: { type: 'string', enum: ['list', 'create'], description: 'Action to perform' }, content: { type: 'string', description: 'Comment content (for create)' } }, required: ['action'] } },
  • Dispatch case in the tool call handler that invokes the commentsManage function.
    case 'comments': result = await commentsManage(notion, args as any)
  • Import statement for the comments handler function.
    import { commentsManage } from './composite/comments.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