Skip to main content
Glama
awkoy

notion-mcp-server

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),
    }),
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Search' implies a read-only operation, the description doesn't specify whether this requires authentication, rate limits, pagination behavior beyond the cursor parameter, or what the return format looks like. It lacks details on error conditions or performance characteristics.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without any redundant information. It's appropriately sized and front-loaded, with every word contributing to clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a search tool with 4 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain the return values, error handling, or behavioral traits like pagination or authentication needs. The agent lacks sufficient context to use the tool effectively beyond basic parameter passing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, providing clear details for all parameters (page_size, query, sort, start_cursor). The description adds no additional parameter semantics beyond what's in the schema, so it meets the baseline of 3 for high schema coverage without compensating value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Search') and resource ('pages and databases in Notion'), and specifies the search scope ('by title'). It doesn't explicitly distinguish from siblings like 'retrieve_block' or 'retrieve_block_children', which are retrieval rather than search operations, but the distinction is implicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any prerequisites, exclusions, or specific contexts for usage. Without such guidance, the agent must infer usage from the tool name and parameters alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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