Skip to main content
Glama

API-retrieve-a-comment

Retrieve comments from a Notion block or page to review feedback and discussions. Use block ID to fetch comment threads and manage responses.

Instructions

Retrieve comments

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
block_idYesIdentifier for a Notion block or page
start_cursorNoIf supplied, this endpoint will return a page of results starting after the cursor provided. If not supplied, this endpoint will return the first page of results.
page_sizeNoThe number of items from the full list desired in the response. Maximum: 100

Implementation Reference

  • Core handler logic for executing the 'API-retrieve-a-comment' tool call: resolves OpenAPI operation, invokes Notion API via HttpClient, logs response, updates cache, and returns JSON-formatted result.
    // Find the operation in OpenAPI spec
    const operation = this.findOperation(name)
    if (!operation) {
      const error = `Method ${name} not found.`
      console.error(error)
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              status: 'error',
              message: error,
              code: 404
            }),
          },
        ],
      }
    }
    
    // Optimized parallel processing for API-get-block-children
    if (name === 'API-get-block-children') {
      // Create basic options for logging control
      const blockOptions: RecursiveExplorationOptions = {
        runInBackground: false, // Default to not showing logs for regular API calls
      };
      
      return await this.handleBlockChildrenParallel(operation, params, blockOptions);
    }
    
    // Other regular API calls
    console.log(`Notion API call: ${operation.method.toUpperCase()} ${operation.path}`)
    const response = await this.httpClient.executeOperation(operation, params)
    
    // Log response summary
    console.log('Notion API response code:', response.status)
    if (response.status !== 200) {
      console.error('Response error:', response.data)
    } else {
      console.log('Response success')
    }
    
    // Update cache with response data
    this.updateCacheFromResponse(name, response.data);
    
    // Convert response to MCP format
    return {
      content: [
        {
          type: 'text',
          text: JSON.stringify(response.data),
        },
      ],
  • Registers 'API-retrieve-a-comment' tool in MCP's listTools response by constructing name from OpenAPI-derived tool definitions (toolName='API', method.name='retrieve-a-comment').
    Object.entries(this.tools).forEach(([toolName, def]) => {
      def.methods.forEach(method => {
        const toolNameWithMethod = `${toolName}-${method.name}`;
        const truncatedToolName = this.truncateToolName(toolNameWithMethod);
        tools.push({
          name: truncatedToolName,
          description: method.description,
          inputSchema: method.inputSchema as Tool['inputSchema'],
        })
        console.log(`- ${truncatedToolName}: ${method.description}`)
      })
    })
  • Generates MCP tool schema and metadata for 'API-retrieve-a-comment' from Notion OpenAPI spec operationId 'retrieve-a-comment', including inputSchema from parameters/requestBody and lookup for handler.
    convertToMCPTools(): {
      tools: Record<string, { methods: NewToolMethod[] }>
      openApiLookup: Record<string, OpenAPIV3.OperationObject & { method: string; path: string }>
      zip: Record<string, { openApi: OpenAPIV3.OperationObject & { method: string; path: string }; mcp: NewToolMethod }>
    } {
      const apiName = 'API'
    
      const openApiLookup: Record<string, OpenAPIV3.OperationObject & { method: string; path: string }> = {}
      const tools: Record<string, { methods: NewToolMethod[] }> = {
        [apiName]: { methods: [] },
      }
      const zip: Record<string, { openApi: OpenAPIV3.OperationObject & { method: string; path: string }; mcp: NewToolMethod }> = {}
      for (const [path, pathItem] of Object.entries(this.openApiSpec.paths || {})) {
        if (!pathItem) continue
    
        for (const [method, operation] of Object.entries(pathItem)) {
          if (!this.isOperation(method, operation)) continue
    
          const mcpMethod = this.convertOperationToMCPMethod(operation, method, path)
          if (mcpMethod) {
            const uniqueName = this.ensureUniqueName(mcpMethod.name)
            mcpMethod.name = uniqueName
            tools[apiName]!.methods.push(mcpMethod)
            openApiLookup[apiName + '-' + uniqueName] = { ...operation, method, path }
            zip[apiName + '-' + uniqueName] = { openApi: { ...operation, method, path }, mcp: mcpMethod }
          }
        }
      }
    
      return { tools, openApiLookup, zip }
    }
  • Specific caching logic for 'API-retrieve-a-comment' responses, storing individual comments in commentCache for later use.
    } else if (apiName === 'API-retrieve-a-comment' && data.results) {
      // Cache comments from result list
      data.results.forEach((comment: any) => {
        if (comment.object === 'comment' && comment.id) {
          this.commentCache.set(comment.id, comment);
        }
      });
    } else if (apiName === 'API-retrieve-a-page-property' && data.results) {
  • Supporting utility method retrieveComments that invokes the 'API-retrieve-a-comment' tool internally for recursive page exploration, with additional caching.
    private async retrieveComments(blockId: string, options: RecursiveExplorationOptions): Promise<any> {
      if (options.runInBackground) {
        console.log(`Retrieving comments: ${blockId}`);
      }
      
      // Get comments via API call
      const operation = this.findOperation('API-retrieve-a-comment');
      if (!operation) {
        if (options.runInBackground) {
          console.warn('API-retrieve-a-comment method not found.');
        }
        return Promise.resolve({ results: [] });
      }
      
      try {
        if (options.runInBackground) {
          console.log(`Notion API call: ${operation.method.toUpperCase()} ${operation.path} (blockId: ${blockId})`);
        }
        
        return this.httpClient.executeOperation(operation, { block_id: blockId })
          .then(response => {
            if (response.status !== 200) {
              if (options.runInBackground) {
                console.error('Error retrieving comments:', response.data);
              }
              return { results: [] };
            }
            
            const commentsData = response.data;
            
            // Cache comments
            if (commentsData.results) {
              commentsData.results.forEach((comment: any) => {
                if (comment.id) {
                  this.commentCache.set(comment.id, comment);
                }
              });
            }
            
            return commentsData;
          })
          .catch(error => {
            if (options.runInBackground) {
              console.error('Error retrieving comments:', error);
            }
            return { results: [] };
          });
      } catch (error) {
        if (options.runInBackground) {
          console.error('Error retrieving comments:', error);
        }
        return Promise.resolve({ results: [] });
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Retrieve comments' implies a read-only operation, but it doesn't specify authentication needs, rate limits, error handling, or pagination behavior. The description lacks details on what 'retrieve' entails, such as whether it returns all comments or supports filtering, leaving behavioral traits unclear.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with 'Retrieve comments', which is front-loaded and wastes no words. However, it may be overly brief, risking under-specification. For a tool with three parameters and no annotations, more detail could be beneficial, but the current form is structurally efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 3 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain the return values, error cases, or operational context. For a retrieval tool in a Notion API context, more information on what 'comments' are and how they relate to 'block_id' would enhance completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear documentation for 'block_id', 'start_cursor', and 'page_size'. The description adds no parameter-specific information beyond the schema. Since the schema is comprehensive, a baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract from the schema's clarity.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Retrieve comments' restates the tool name with minimal elaboration. It specifies the action ('retrieve') and resource ('comments'), but lacks detail about scope or context, making it vague. Compared to siblings like 'API-retrieve-a-block' or 'API-retrieve-a-page', it doesn't clearly differentiate what makes retrieving comments unique, beyond the resource type.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites, context, or exclusions. Given siblings like 'API-get-block-children' that might overlap in functionality, the absence of usage guidelines leaves the agent without direction on tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Taewoong1378/notion-readonly-mcp-server'

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