notion_search
Search Notion pages and databases by title to find specific content. Filter results by type, sort by edit time, and retrieve information in JSON or markdown formats.
Instructions
Search pages or databases by title in Notion
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | Text to search for in page or database titles | |
| filter | No | Filter results by object type (page or database) | |
| sort | No | Sort order of results | |
| start_cursor | No | Pagination start cursor | |
| page_size | No | Number of results to return (max 100). | |
| format | No | Specify the response format. 'json' returns the original data structure, 'markdown' returns a more readable format. Use 'markdown' when the user only needs to read the page and isn't planning to write or modify it. Use 'json' when the user needs to read the page with the intention of writing to or modifying it. | markdown |
Implementation Reference
- src/server/index.ts:266-276 (handler)Tool request handler for 'notion_search' that extracts arguments and calls notionClient.search() with query, filter, sort, start_cursor, and page_size parameterscase "notion_search": { const args = request.params.arguments as unknown as args.SearchArgs; response = await notionClient.search( args.query, args.filter, args.sort, args.start_cursor, args.page_size ); break; }
- src/types/schemas.ts:461-511 (schema)Tool schema definition for 'notion_search' defining name, description, and inputSchema with properties for query, filter, sort, start_cursor, page_size, and format// Search tool export const searchTool: Tool = { name: "notion_search", description: "Search pages or databases by title in Notion", inputSchema: { type: "object", properties: { query: { type: "string", description: "Text to search for in page or database titles", }, filter: { type: "object", description: "Filter results by object type (page or database)", properties: { property: { type: "string", description: "Must be 'object'", }, value: { type: "string", description: "Either 'page' or 'database'", }, }, }, sort: { type: "object", description: "Sort order of results", properties: { direction: { type: "string", enum: ["ascending", "descending"], }, timestamp: { type: "string", enum: ["last_edited_time"], }, }, }, start_cursor: { type: "string", description: "Pagination start cursor", }, page_size: { type: "number", description: "Number of results to return (max 100). ", }, format: formatParameter, }, }, };
- src/server/index.ts:317-342 (registration)Tool registration in ListToolsRequestSchema handler where schemas.searchTool is added to the allTools array and filtered by enabledToolsSetserver.setRequestHandler(ListToolsRequestSchema, async () => { const allTools = [ schemas.appendBlockChildrenTool, schemas.retrieveBlockTool, schemas.retrieveBlockChildrenTool, schemas.deleteBlockTool, schemas.updateBlockTool, schemas.createPageTool, schemas.retrievePageTool, schemas.updatePagePropertiesTool, schemas.listAllUsersTool, schemas.retrieveUserTool, schemas.retrieveBotUserTool, schemas.createDatabaseTool, schemas.queryDatabaseTool, schemas.retrieveDatabaseTool, schemas.updateDatabaseTool, schemas.createDatabaseItemTool, schemas.createCommentTool, schemas.retrieveCommentsTool, schemas.searchTool, ]; return { tools: filterTools(allTools, enabledToolsSet), }; });
- src/client/index.ts:328-352 (helper)NotionClientWrapper.search() method implementation that makes a POST request to the Notion API /search endpoint with query, filter, sort, start_cursor, and page_size parametersasync search( query?: string, filter?: { property: string; value: string }, sort?: { direction: "ascending" | "descending"; timestamp: "last_edited_time"; }, start_cursor?: string, page_size?: number ): Promise<ListResponse> { const body: Record<string, any> = {}; if (query) body.query = query; if (filter) body.filter = filter; if (sort) body.sort = sort; if (start_cursor) body.start_cursor = start_cursor; if (page_size) body.page_size = page_size; const response = await fetch(`${this.baseUrl}/search`, { method: "POST", headers: this.headers, body: JSON.stringify(body), }); return response.json(); }
- src/types/args.ts:135-145 (schema)TypeScript interface SearchArgs defining the argument types for the search function with optional query, filter, sort, start_cursor, page_size, and format propertiesexport interface SearchArgs { query?: string; filter?: { property: string; value: string }; sort?: { direction: "ascending" | "descending"; timestamp: "last_edited_time"; }; start_cursor?: string; page_size?: number; format?: "json" | "markdown"; }