get_database
Retrieve detailed information about a Notion database including title, schema, property definitions, and timestamps to understand its structure and contents.
Instructions
Retrieves detailed information about a specific Notion database by its ID. Returns database title, schema (property definitions), creation time, last edited time, and more. Use this to understand database structure.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| databaseId | Yes | The ID of the Notion database to retrieve (32 or 36 character UUID format). Example: "123e4567-e89b-12d3-a456-426614174000" |
Implementation Reference
- Core execution logic for the get_database tool. Converts input databaseId to DatabaseId value object and delegates to repository to fetch the database.export class GetDatabaseUseCase { constructor(private readonly databaseRepository: IDatabaseRepository) {} async execute(input: GetDatabaseInput): Promise<Database | null> { const databaseId = new DatabaseId(input.databaseId); return await this.databaseRepository.findById(databaseId); } }
- src/presentation/mcp/MCPServer.ts:259-272 (registration)Registers the 'get_database' tool with the MCP server, including name, description, and input schema validation.{ name: 'get_database', description: 'Retrieves detailed information about a specific Notion database by its ID. Returns database title, schema (property definitions), creation time, last edited time, and more. Use this to understand database structure.', inputSchema: { type: 'object', properties: { databaseId: { type: 'string', description: 'The ID of the Notion database to retrieve (32 or 36 character UUID format). Example: "123e4567-e89b-12d3-a456-426614174000"', }, }, required: ['databaseId'], }, },
- MCP server handler method that invokes the GetDatabaseUseCase and formats the response as JSON or handles not found.private async handleGetDatabase(args: any) { const result = await this.dependencies.getDatabaseUseCase.execute({ databaseId: args.databaseId, }); if (!result) { return { content: [ { type: 'text' as const, text: 'Database not found', }, ], }; } return { content: [ { type: 'text' as const, text: JSON.stringify( { id: result.id.toString(), title: result.title, schema: result.schema, createdTime: result.createdTime, lastEditedTime: result.lastEditedTime, archived: result.archived, }, null, 2 ), }, ], }; }
- src/shared/DIContainer.ts:89-91 (helper)Dependency injection factory method that instantiates the GetDatabaseUseCase with the NotionDatabaseRepository.getGetDatabaseUseCase(): GetDatabaseUseCase { return new GetDatabaseUseCase(this.databaseRepository); }
- Type definition for input to the GetDatabaseUseCase, matching the tool schema.export interface GetDatabaseInput { databaseId: string; }