Skip to main content
Glama
makenotion
by makenotion

API-create-a-database

Create structured databases in Notion by defining properties and parent pages. Integrates with the Notion MCP Server to enable automated database creation through API interactions.

Instructions

Notion | Create a database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
parentYes
propertiesYesProperty schema of database. The keys are the names of properties as they appear in Notion and the values are [property schema objects](https://developers.notion.com/reference/property-schema-object).
titleNo

Implementation Reference

  • Generic handler that implements the execution logic for the 'API-create-a-database' tool by resolving the tool name to the corresponding OpenAPI operation and proxying the HTTP call via HttpClient.
    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 input/output schemas and tool metadata for 'API-create-a-database' (when operationId is 'create-a-database') from OpenAPI paths/operations. Constructs lookup key 'API-create-a-database'.
    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 }
    }
  • Registers the dynamic tool listing functionality, which exposes 'API-create-a-database' and its schema based on the parsed OpenAPI spec.
    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 }
    })
  • Initializes the MCP server, converts OpenAPI spec to internal tools list (including 'API-create-a-database') and lookup, and sets up MCP request handlers.
    constructor(name: string, openApiSpec: OpenAPIV3.Document) {
      this.server = new Server({ name, version: '1.0.0' }, { capabilities: { tools: {} } })
      const baseUrl = openApiSpec.servers?.[0].url
      if (!baseUrl) {
        throw new Error('No base URL found in OpenAPI spec')
      }
      this.httpClient = new HttpClient(
        {
          baseUrl,
          headers: this.parseHeadersFromEnv(),
        },
        openApiSpec,
      )
    
      // Convert OpenAPI spec to MCP tools
      const converter = new OpenAPIToMCPConverter(openApiSpec)
      const { tools, openApiLookup } = converter.convertToMCPTools()
      this.tools = tools
      this.openApiLookup = openApiLookup
    
      this.setupHandlers()
    }
  • Entry point to create the MCPProxy instance loaded with the Notion OpenAPI spec, making all tools like 'API-create-a-database' available.
    export async function initProxy(specPath: string, baseUrl: string |undefined) {
      const openApiSpec = await loadOpenApiSpec(specPath, baseUrl)
      const proxy = new MCPProxy('Notion API', openApiSpec)
    
      return proxy
    }
Behavior2/5

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

With no annotations, the description carries full burden but only states the action without behavioral details. It doesn't disclose that this is a write operation requiring permissions, potential rate limits, or what happens on success/failure. The description adds minimal context beyond the basic action, leaving key behavioral traits unspecified.

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-loaded with the platform and action. There's zero wasted text, and it efficiently communicates the core purpose without unnecessary elaboration, making it easy to scan.

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 tool with 3 parameters, low schema coverage (33%), no annotations, and no output schema, the description is incomplete. It doesn't address parameter meanings, behavioral aspects like permissions or effects, or what the tool returns. Given the complexity and lack of structured data, the description should provide more context to be useful.

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

Parameters2/5

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

Schema description coverage is low at 33%, and the description provides no parameter information. It doesn't explain the meaning of 'parent', 'properties', or 'title' parameters, nor their relationships. The description fails to compensate for the schema's lack of coverage, leaving most parameters semantically unclear.

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

Purpose3/5

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

The description 'Notion | Create a database' states the action (create) and resource (database) with platform context (Notion), but it's vague about what exactly is created and doesn't distinguish from siblings like API-post-database-query or API-retrieve-a-database. It lacks specificity about the database creation scope or purpose.

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 on when to use this tool versus alternatives is provided. The description doesn't mention prerequisites, such as needing a parent page, or when to choose this over other database-related tools like API-retrieve-a-database or API-update-a-database. Usage context is implied but not explicit.

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