Skip to main content
Glama
gendosu

Notion MCP Server

by gendosu

API-patch-block-children

Append child content to a Notion block or page using the Notion MCP Server. Specify block ID and array of child blocks to add content after an existing block, enhancing workspace organization.

Instructions

Notion | Append block children

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
afterNoThe ID of the existing block that the new block should be appended after.
block_idYesIdentifier for a [block](ref:block). Also accepts a [page](ref:page) ID.
childrenYesChild content to append to a container block as an array of [block objects](ref:block)

Implementation Reference

  • Generic MCP tool execution handler for all tools derived from OpenAPI spec, including "API-patch-block-children". It resolves the tool name to the corresponding OpenAPI operation (PATCH /v1/blocks/{block_id}/children), executes the HTTP request via HttpClient, and formats the response as MCP content.
    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
      }
    })
  • MCP tool listing handler that registers all OpenAPI-derived tools, constructing names like "API-patch-block-children" from 'API' + operationId 'patch-block-children', including description and inputSchema.
    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 }
    })
  • Generates MCP tool definitions (name, description, inputSchema) from OpenAPI operations, creating the "API-patch-block-children" tool from Notion's patchBlockChildren operation including schema for path param block_id and body.
    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
            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 }
    }
  • Initializes the MCPProxy by converting Notion OpenAPI spec to internal tools map and openApiLookup (used for dispatching), including the entry for "API-patch-block-children".
      const converter = new OpenAPIToMCPConverter(openApiSpec)
      const { tools, openApiLookup } = converter.convertToMCPTools()
      this.tools = tools
      this.openApiLookup = openApiLookup
    
      this.setupHandlers()
    }
  • Dispatches to HttpClient.executeOperation which performs the actual HTTP PATCH request for the tool.
    const response = await this.httpClient.executeOperation(operation, params)
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It states 'Append' which implies a write/mutation operation, but doesn't disclose permissions needed, rate limits, idempotency, or what happens on failure. For a mutation tool with zero annotation coverage, this is inadequate.

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?

The description is extremely concise with just three words, front-loading the key information ('Notion | Append block children'). There's no wasted verbiage, making it efficient for quick scanning.

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?

For a mutation tool with 3 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what the tool returns, error conditions, or important behavioral aspects like whether appending is additive or has side effects. The context demands more 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%, providing detailed documentation for all parameters (block_id, children, after). The description adds no additional parameter semantics beyond what's in the schema, so it meets the baseline of 3 where the schema does the heavy lifting.

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 ('Append') and resource ('block children') with platform context ('Notion'), making the purpose understandable. It doesn't explicitly distinguish from siblings like 'API-update-a-block' or 'API-get-block-children', but the verb 'Append' suggests a specific type of modification rather than full replacement or retrieval.

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 like 'API-update-a-block' (which might replace content) or 'API-get-block-children' (which retrieves). The description implies appending children to blocks, but lacks explicit context about use cases or prerequisites.

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

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