Skip to main content
Glama

query_pages

Retrieve Notion database pages matching specific conditions using filters and sorting. Find tasks by status, projects by due date, or records by custom criteria.

Instructions

Queries and retrieves pages (records) from a Notion database. Supports filtering and sorting. Examples: "tasks with status In Progress", "projects due this week", "tasks assigned to me". Retrieve pages matching specific conditions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseIdYesThe ID of the Notion database to query (32 or 36 character UUID format). Example: "123e4567-e89b-12d3-a456-426614174000"
filterNoFilter conditions (optional). Follows Notion API filter syntax. Examples: - Status equals "In Progress": { "property": "Status", "select": { "equals": "In Progress" } } - Checkbox is checked: { "property": "Completed", "checkbox": { "equals": true } } - Date is this week: { "property": "Due Date", "date": { "this_week": {} } } - Multiple conditions (AND): { "and": [condition1, condition2] } - Multiple conditions (OR): { "or": [condition1, condition2] }
sortsNoSort conditions (optional). Array of sort specifications. Examples: - Date ascending: [{ "property": "Due Date", "direction": "ascending" }] - Priority descending: [{ "property": "Priority", "direction": "descending" }] - Created time descending: [{ "timestamp": "created_time", "direction": "descending" }]
startCursorNoPagination cursor (optional). Use the nextCursor from a previous query to fetch the next page of results.
pageSizeNoNumber of pages to retrieve at once (optional, default: 100, max: 100). Use with pagination for large datasets.

Implementation Reference

  • MCP tool handler method that executes the query_pages tool. It calls the QueryPagesUseCase with input arguments and formats the response as MCP content.
    private async handleQueryPages(args: any) {
      const result = await this.dependencies.queryPagesUseCase.execute({
        databaseId: args.databaseId,
        filter: args.filter,
        sorts: args.sorts,
        startCursor: args.startCursor,
        pageSize: args.pageSize,
      });
    
      return {
        content: [
          {
            type: 'text' as const,
            text: JSON.stringify(
              {
                pages: result.pages.map((page) => ({
                  id: page.id.toString(),
                  properties: page.properties,
                  createdTime: page.createdTime,
                  archived: page.archived,
                })),
                hasMore: result.hasMore,
                nextCursor: result.nextCursor,
              },
              null,
              2
            ),
          },
        ],
      };
    }
  • Tool registration in the getTools() method, defining the name 'query_pages', description, and input schema for the MCP ListTools response.
          {
            name: 'query_pages',
            description: 'Queries and retrieves pages (records) from a Notion database. Supports filtering and sorting. Examples: "tasks with status In Progress", "projects due this week", "tasks assigned to me". Retrieve pages matching specific conditions.',
            inputSchema: {
              type: 'object',
              properties: {
                databaseId: {
                  type: 'string',
                  description: 'The ID of the Notion database to query (32 or 36 character UUID format). Example: "123e4567-e89b-12d3-a456-426614174000"',
                },
                filter: {
                  type: 'object',
                  description: `Filter conditions (optional). Follows Notion API filter syntax.
    
    Examples:
    - Status equals "In Progress": { "property": "Status", "select": { "equals": "In Progress" } }
    - Checkbox is checked: { "property": "Completed", "checkbox": { "equals": true } }
    - Date is this week: { "property": "Due Date", "date": { "this_week": {} } }
    - Multiple conditions (AND): { "and": [condition1, condition2] }
    - Multiple conditions (OR): { "or": [condition1, condition2] }`,
                },
                sorts: {
                  type: 'array',
                  description: `Sort conditions (optional). Array of sort specifications.
    
    Examples:
    - Date ascending: [{ "property": "Due Date", "direction": "ascending" }]
    - Priority descending: [{ "property": "Priority", "direction": "descending" }]
    - Created time descending: [{ "timestamp": "created_time", "direction": "descending" }]`,
                },
                startCursor: {
                  type: 'string',
                  description: 'Pagination cursor (optional). Use the nextCursor from a previous query to fetch the next page of results.',
                },
                pageSize: {
                  type: 'number',
                  description: 'Number of pages to retrieve at once (optional, default: 100, max: 100). Use with pagination for large datasets.',
                },
              },
              required: ['databaseId'],
            },
          },
  • TypeScript interface defining the input schema for the QueryPagesUseCase, matching the MCP tool input.
    export interface QueryPagesInput {
      databaseId: string;
      filter?: Record<string, unknown>;
      sorts?: Array<{ property: string; direction: 'ascending' | 'descending' }>;
      startCursor?: string;
      pageSize?: number;
    }
  • Core business logic handler in QueryPagesUseCase.execute(), which validates input, constructs query options, and delegates to the page repository.
    export class QueryPagesUseCase {
      constructor(private readonly pageRepository: IPageRepository) {}
    
      async execute(input: QueryPagesInput): Promise<PageQueryResult> {
        const databaseId = new DatabaseId(input.databaseId);
        
        const options: PageQueryOptions = {
          filter: input.filter,
          sorts: input.sorts,
          startCursor: input.startCursor,
          pageSize: input.pageSize,
        };
    
        return await this.pageRepository.query(databaseId, options);
      }
    }
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. It mentions filtering and sorting but lacks details on permissions, rate limits, pagination behavior (beyond cursor hints in schema), error handling, or what 'retrieves pages' entails (e.g., format, fields returned). For a query tool with no annotation coverage, this leaves significant behavioral gaps.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded with the core purpose, followed by examples that reinforce usage. However, the last sentence ('Retrieve pages matching specific conditions') is somewhat redundant with the first part, slightly reducing efficiency.

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

Completeness3/5

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

Given no annotations and no output schema, the description is incomplete for a complex query tool with 5 parameters and nested objects. It covers the basic purpose and examples but lacks details on behavioral traits, return values, and comprehensive usage guidelines, leaving the agent with gaps in understanding.

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?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema by mentioning 'supports filtering and sorting' and giving general examples, but does not provide additional syntax or format details. Baseline 3 is appropriate when schema does the heavy lifting.

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

Purpose5/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 specific verbs ('queries and retrieves') and resources ('pages from a Notion database'), and distinguishes it from siblings by focusing on querying rather than creating, deleting, or updating pages. The examples further clarify the scope.

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

Usage Guidelines3/5

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

The description implies usage through examples like 'tasks with status In Progress' but does not explicitly state when to use this tool versus alternatives such as 'get_page' for single pages or 'list_databases' for listing databases. No explicit exclusions or prerequisites are provided.

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

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

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