query_database
Retrieve and filter data from Notion databases to extract specific information for analysis or integration.
Instructions
Query a Notion database with optional filter
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database_id | Yes | ||
| filter | No |
Implementation Reference
- src/apis/notion/notion.ts:100-105 (handler)The main handler function for the 'query_database' tool. It validates the Notion token and database_id, then delegates to the NotionClient's queryDatabase method.async query_database(args: Record<string, unknown>) { if (!cfg.notionToken) throw new Error("NOTION_TOKEN is not configured"); const databaseId = String(args.database_id || ""); if (!databaseId) throw new Error("database_id is required"); return client.queryDatabase(databaseId, args.filter); },
- src/apis/notion/notion.ts:54-61 (schema)Input schema for the 'query_database' tool, defining required 'database_id' string and optional 'filter' object.inputSchema: { type: "object", properties: { database_id: { type: "string" }, filter: { type: "object" }, }, required: ["database_id"], },
- src/apis/notion/notion.ts:51-62 (registration)Registration of the 'query_database' tool within the tools array in registerNotion() function.{ name: "query_database", description: "Query a Notion database with optional filter", inputSchema: { type: "object", properties: { database_id: { type: "string" }, filter: { type: "object" }, }, required: ["database_id"], }, },
- src/apis/notion/notion.ts:16-21 (helper)Helper method in NotionClient class that makes the actual Notion API request to query the specified database.queryDatabase(databaseId: string, filter?: unknown) { return this.request(`/v1/databases/${databaseId}/query`, { method: "POST", body: filter ? { filter } : {}, }); }