update_database
Modify database structure by changing title or updating property schema to add, modify, or delete columns in Notion databases.
Instructions
Updates the database itself (not individual records). Can change database title or update schema (add/modify/delete properties/columns). Note: To update individual records, use update_page instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| databaseId | Yes | The ID of the Notion database to update (32 or 36 character UUID format). Example: "123e4567-e89b-12d3-a456-426614174000" | |
| title | No | New title for the database (optional). Example: "Task Management 2024" | |
| schema | No | Database schema (property definitions) to update (optional). Use property names as keys and property definitions as values. Example (adding a new property): { "Priority": { "select": { "options": [ { "name": "High", "color": "red" }, { "name": "Medium", "color": "yellow" }, { "name": "Low", "color": "gray" } ] } } } |
Input Schema (JSON Schema)
{
"properties": {
"databaseId": {
"description": "The ID of the Notion database to update (32 or 36 character UUID format). Example: \"123e4567-e89b-12d3-a456-426614174000\"",
"type": "string"
},
"schema": {
"description": "Database schema (property definitions) to update (optional). Use property names as keys and property definitions as values.\n\nExample (adding a new property):\n{\n \"Priority\": {\n \"select\": {\n \"options\": [\n { \"name\": \"High\", \"color\": \"red\" },\n { \"name\": \"Medium\", \"color\": \"yellow\" },\n { \"name\": \"Low\", \"color\": \"gray\" }\n ]\n }\n }\n}",
"type": "object"
},
"title": {
"description": "New title for the database (optional). Example: \"Task Management 2024\"",
"type": "string"
}
},
"required": [
"databaseId"
],
"type": "object"
}
Implementation Reference
- src/presentation/mcp/MCPServer.ts:281-315 (registration)Registration of the 'update_database' tool in MCPServer.getTools(), including name, description, and input schema definition.{ name: 'update_database', description: 'Updates the database itself (not individual records). Can change database title or update schema (add/modify/delete properties/columns). Note: To update individual records, use update_page instead.', inputSchema: { type: 'object', properties: { databaseId: { type: 'string', description: 'The ID of the Notion database to update (32 or 36 character UUID format). Example: "123e4567-e89b-12d3-a456-426614174000"', }, title: { type: 'string', description: 'New title for the database (optional). Example: "Task Management 2024"', }, schema: { type: 'object', description: `Database schema (property definitions) to update (optional). Use property names as keys and property definitions as values. Example (adding a new property): { "Priority": { "select": { "options": [ { "name": "High", "color": "red" }, { "name": "Medium", "color": "yellow" }, { "name": "Low", "color": "gray" } ] } } }`, }, }, required: ['databaseId'], }, },
- Handler function for the 'update_database' tool that calls the UpdateDatabaseUseCase and formats the response for MCP.private async handleUpdateDatabase(args: any) { const result = await this.dependencies.updateDatabaseUseCase.execute({ databaseId: args.databaseId, title: args.title, schema: args.schema, }); return { content: [ { type: 'text' as const, text: JSON.stringify( { id: result.id.toString(), title: result.title, schema: result.schema, lastEditedTime: result.lastEditedTime, }, null, 2 ), }, ], }; }
- Type definition for UpdateDatabaseInput used in the use case execute method.export interface UpdateDatabaseInput { databaseId: string; title?: string; schema?: Partial<DatabaseSchema>; }
- Core business logic handler in UpdateDatabaseUseCase that performs the database update via repository.async execute(input: UpdateDatabaseInput): Promise<Database> { const databaseId = new DatabaseId(input.databaseId); return await this.databaseRepository.update(databaseId, { title: input.title, schema: input.schema, }); }