Skip to main content
Glama

search_pages

Find pages and databases in Notion by title using customizable search queries, results sorting, and pagination for efficient content navigation.

Instructions

Search for pages and databases in Notion by title

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
page_sizeNoNumber of results to return (1-100)
queryNoSearch query for filtering by title
sortNoSort order for results
start_cursorNoCursor for pagination

Implementation Reference

  • The core handler function implementing the search_pages tool logic, performing a Notion search API call and formatting results.
    export async function searchPages( params: SearchPagesParams ): Promise<CallToolResult> { try { const response = await notion.search({ query: params.query || "", sort: params.sort, start_cursor: params.start_cursor, page_size: params.page_size || 10, }); const resultsText = JSON.stringify(response, null, 2); return { content: [ { type: "text", text: `Found ${response.results.length} results. ${ response.has_more ? "More results available." : "" }\n\n${resultsText}`, }, ], }; } catch (error) { return handleNotionError(error); } }
  • Zod schema defining the input parameters specifically for the search_pages action.
    export const SEARCH_PAGES_SCHEMA = { query: z.string().optional().describe("Search query for filtering by title"), sort: z .object({ direction: z.enum(["ascending", "descending"]), timestamp: z.literal("last_edited_time"), }) .optional() .describe("Sort order for results"), start_cursor: z.string().optional().describe("Cursor for pagination"), page_size: z .number() .min(1) .max(100) .optional() .describe("Number of results to return (1-100)"), };
  • Registration of the 'notion_pages' MCP tool, which includes the search_pages action via its dispatcher.
    // Register combined pages operation tool server.tool( "notion_pages", "Perform various page operations (create, archive, restore, search, update)", PAGES_OPERATION_SCHEMA, registerPagesOperationTool );
  • Dispatcher function that routes 'search_pages' action to the searchPages handler.
    export const registerPagesOperationTool = async ( params: PagesOperationParams ): Promise<CallToolResult> => { switch (params.payload.action) { case "create_page": return registerCreatePageTool(params.payload.params); case "archive_page": return archivePage(params.payload.params); case "restore_page": return restorePage(params.payload.params); case "search_pages": return searchPages(params.payload.params); case "update_page_properties": return updatePageProperties(params.payload.params); default: return handleNotionError( new Error( `Unsupported action, use one of the following: "create_page", "archive_page", "restore_page", "search_pages", "update_page_properties"` ) ); }
  • Part of the discriminated union schema defining the search_pages action variant.
    action: z .literal("search_pages") .describe("Use this action to search for pages based on a query."), params: z.object(SEARCH_PAGES_SCHEMA), }),

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/awkoy/notion-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server