Skip to main content
Glama
makenotion
by makenotion

API-retrieve-a-comment

Retrieve comments from a Notion block or page by specifying its block ID. Supports pagination with start cursor and page size to manage large datasets efficiently.

Instructions

Notion | Retrieve comments

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
block_idYesIdentifier for a Notion block or page
page_sizeNoThe number of items from the full list desired in the response. Maximum: 100
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.

Implementation Reference

  • Tool registration via ListToolsRequestSchema handler. Constructs tool names as 'API-{operationId}' (e.g., 'API-retrieve-a-comment') from OpenAPI operations and provides input schemas and descriptions.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => {
      const tools: Tool[] = []
    
      // Add methods as separate tools to match the MCP format
      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'],
          })
        })
      })
    
      return { tools }
    })
  • Tool handler for executing 'API-retrieve-a-comment'. Resolves the OpenAPI operation from the tool name using openApiLookup and calls httpClient.executeOperation with parameters.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: params } = request.params
    
      // Find the operation in OpenAPI spec
      const operation = this.findOperation(name)
      if (!operation) {
        throw new Error(`Method ${name} not found`)
      }
    
      try {
        // Execute the operation
        const response = await this.httpClient.executeOperation(operation, params)
    
        // Convert response to MCP format
        return {
          content: [
            {
              type: 'text', // currently this is the only type that seems to be used by mcp server
              text: JSON.stringify(response.data), // TODO: pass through the http status code text?
            },
          ],
        }
      } catch (error) {
        console.error('Error in tool call', error)
        if (error instanceof HttpClientError) {
          console.error('HttpClientError encountered, returning structured error', error)
          const data = error.data?.response?.data ?? error.data ?? {}
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify({
                  status: 'error', // TODO: get this from http status code?
                  ...(typeof data === 'object' ? data : { data: data }),
                }),
              },
            ],
          }
        }
        throw error
      }
    })
  • Generates MCP tool definitions from OpenAPI spec, including input schemas via convertOperationToMCPMethod. Creates lookup keys as 'API-{operationId}' for tools like 'API-retrieve-a-comment'.
      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
            mcpMethod.description = this.getDescription(operation.summary || operation.description || '')
            tools[apiName]!.methods.push(mcpMethod)
            openApiLookup[apiName + '-' + uniqueName] = { ...operation, method, path }
            zip[apiName + '-' + uniqueName] = { openApi: { ...operation, method, path }, mcp: mcpMethod }
          }
        }
      }
    
      return { tools, openApiLookup, zip }
    }
  • Helper function that performs the actual HTTP execution for the resolved OpenAPI operation corresponding to the tool 'API-retrieve-a-comment'.
    async executeOperation<T = any>(
      operation: OpenAPIV3.OperationObject & { method: string; path: string },
      params: Record<string, any> = {},
    ): Promise<HttpClientResponse<T>> {
      const api = await this.api
      const operationId = operation.operationId
      if (!operationId) {
        throw new Error('Operation ID is required')
      }
    
      // Handle file uploads if present
      const formData = await this.prepareFileUpload(operation, params)
    
      // Separate parameters based on their location
      const urlParameters: Record<string, any> = {}
      const bodyParams: Record<string, any> = formData || { ...params }
    
      // Extract path and query parameters based on operation definition
      if (operation.parameters) {
        for (const param of operation.parameters) {
          if ('name' in param && param.name && param.in) {
            if (param.in === 'path' || param.in === 'query') {
              if (params[param.name] !== undefined) {
                urlParameters[param.name] = params[param.name]
                if (!formData) {
                  delete bodyParams[param.name]
                }
              }
            }
          }
        }
      }
    
      // Add all parameters as url parameters if there is no requestBody defined
      if (!operation.requestBody && !formData) {
        for (const key in bodyParams) {
          if (bodyParams[key] !== undefined) {
            urlParameters[key] = bodyParams[key]
            delete bodyParams[key]
          }
        }
      }
    
      const operationFn = (api as any)[operationId]
      if (!operationFn) {
        throw new Error(`Operation ${operationId} not found`)
      }
    
      try {
        // If we have form data, we need to set the correct headers
        const hasBody = Object.keys(bodyParams).length > 0
        const headers = formData
          ? formData.getHeaders()
          : { ...(hasBody ? { 'Content-Type': 'application/json' } : { 'Content-Type': null }) }
        const requestConfig = {
          headers: {
            ...headers,
          },
        }
    
        // first argument is url parameters, second is body parameters
        const response = await operationFn(urlParameters, hasBody ? bodyParams : undefined, requestConfig)
    
        // Convert axios headers to Headers object
        const responseHeaders = new Headers()
        Object.entries(response.headers).forEach(([key, value]) => {
          if (value) responseHeaders.append(key, value.toString())
        })
    
        return {
          data: response.data,
          status: response.status,
          headers: responseHeaders,
        }
      } catch (error: any) {
        if (error.response) {
          console.error('Error in http client', error)
          const headers = new Headers()
          Object.entries(error.response.headers).forEach(([key, value]) => {
            if (value) headers.append(key, value.toString())
          })
    
          throw new HttpClientError(error.response.statusText || 'Request failed', error.response.status, error.response.data, headers)
        }
        throw error
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'Retrieve' but doesn't disclose behavioral traits like pagination (implied by start_cursor/page_size in schema), rate limits, authentication needs, or response format. For a read operation with 3 parameters, this leaves significant gaps.

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

Conciseness5/5

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

Extremely concise with 'Notion | Retrieve comments'—front-loaded, zero waste, and appropriately sized for a simple retrieval tool. Every word earns its place by specifying platform and action.

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 no annotations, no output schema, and 3 parameters (with 100% schema coverage), the description is incomplete. It lacks context on behavior (e.g., pagination, error handling), output format, or usage scenarios, making it inadequate for a tool with potential complexity like paginated comment retrieval.

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%, so the schema fully documents parameters (block_id, page_size, start_cursor). The description adds no additional meaning beyond what's in the schema, such as clarifying comment retrieval specifics. Baseline 3 is appropriate when schema does all the work.

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

Purpose4/5

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

The description clearly states the action ('Retrieve') and resource ('comments'), with 'Notion' providing context. It distinguishes from siblings like API-create-a-comment (create vs. retrieve) and API-retrieve-a-block (comments vs. blocks), but could be more specific about scope (e.g., 'retrieve comments on a block/page').

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 explicit guidance on when to use this tool versus alternatives like API-retrieve-a-page-property or API-post-search for comments. The description implies it's for fetching comments, but lacks context on prerequisites, typical use cases, or exclusions.

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

Related 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/makenotion/notion-mcp-server'

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