Skip to main content
Glama
camiloluvino

Roam Research MCP Server

by camiloluvino

roam_find_pages_modified_today

Retrieve pages modified today in Roam Research with pagination and sorting options for efficient daily review.

Instructions

Find pages that have been modified today (since midnight), with pagination and sorting options.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoThe maximum number of pages to retrieve (default: 50). Use -1 for no limit, but be aware that very large result sets can impact performance.
offsetNoThe number of pages to skip before returning matches. Useful for pagination. Defaults to 0.
sort_orderNoSort order for pages based on modification date. "desc" for most recent first, "asc" for oldest first.desc

Implementation Reference

  • The main handler function that executes the tool logic: queries the Roam graph using Datomic for pages with blocks modified since midnight today, handles pagination and sorting, extracts unique page titles, and returns formatted results.
    async findPagesModifiedToday(limit: number = 50, offset: number = 0, sort_order: 'asc' | 'desc' = 'desc') {
      // Define ancestor rule for traversing block hierarchy
      const ancestorRule = `[
        [ (ancestor ?b ?a)
          [?a :block/children ?b] ]
        [ (ancestor ?b ?a)
          [?parent :block/children ?b]
          (ancestor ?parent ?a) ]
      ]`;
    
      // Get start of today
      const startOfDay = new Date();
      startOfDay.setHours(0, 0, 0, 0);
    
      try {
        // Query for pages modified today, including modification time for sorting
        let query = `[:find ?title ?time
            :in $ ?start_of_day %
            :where
            [?page :node/title ?title]
            (ancestor ?block ?page)
            [?block :edit/time ?time]
            [(> ?time ?start_of_day)]]`;
    
        if (limit !== -1) {
          query += ` :limit ${limit}`;
        }
        if (offset > 0) {
          query += ` :offset ${offset}`;
        }
    
        const results = await q(
          this.graph,
          query,
          [startOfDay.getTime(), ancestorRule]
        ) as [string, number][];
    
        if (!results || results.length === 0) {
          return {
            success: true,
            pages: [],
            message: 'No pages have been modified today'
          };
        }
    
        // Sort results by modification time
        results.sort((a, b) => {
          if (sort_order === 'desc') {
            return b[1] - a[1]; // Newest first
          } else {
            return a[1] - b[1]; // Oldest first
          }
        });
    
        // Extract unique page titles from sorted results
        const uniquePages = Array.from(new Set(results.map(([title]) => title)));
    
        return {
          success: true,
          pages: uniquePages,
          message: `Found ${uniquePages.length} page(s) modified today`
        };
      } catch (error: any) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to find modified pages: ${error.message}`
        );
      }
    }
  • Tool registration in the MCP server switch statement: matches the tool name via BASE_TOOL_NAMES.FIND_PAGES_MODIFIED_TODAY, extracts parameters, calls the handler, and formats the response.
    case BASE_TOOL_NAMES.FIND_PAGES_MODIFIED_TODAY: {
      const { max_num_pages } = request.params.arguments as {
        max_num_pages?: number;
      };
      const result = await this.toolHandlers.findPagesModifiedToday(max_num_pages || 50);
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • Defines the tool name, description, and input schema (parameters: limit, offset, sort_order with defaults).
    [toolName(BASE_TOOL_NAMES.FIND_PAGES_MODIFIED_TODAY)]: {
      name: toolName(BASE_TOOL_NAMES.FIND_PAGES_MODIFIED_TODAY),
      description: 'Find pages that have been modified today (since midnight), with pagination and sorting options.',
      inputSchema: {
        type: 'object',
        properties: {
          limit: {
            type: 'integer',
            description: 'The maximum number of pages to retrieve (default: 50). Use -1 for no limit, but be aware that very large result sets can impact performance.',
            default: 50
          },
          offset: {
            type: 'integer',
            description: 'The number of pages to skip before returning matches. Useful for pagination. Defaults to 0.',
            default: 0
          },
          sort_order: {
            type: 'string',
            description: 'Sort order for pages based on modification date. "desc" for most recent first, "asc" for oldest first.',
            enum: ['asc', 'desc'],
            default: 'desc'
          }
        }
      }
    },
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. It mentions 'pagination and sorting options' and implies a read operation, but fails to detail performance impacts (e.g., from large result sets), authentication needs, rate limits, or error handling. This is inadequate for a tool with no annotation coverage.

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 front-loads the core purpose and briefly notes additional features. There is no wasted text, and it is appropriately sized for the tool's complexity.

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 3 parameters with full schema coverage and no output schema, the description is minimally complete but lacks depth. It covers the basic purpose and hints at functionality but does not address behavioral aspects like performance or error handling, which are important for a tool with no annotations.

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%, providing full documentation for all parameters (limit, offset, sort_order). The description adds minimal value beyond the schema by mentioning 'pagination and sorting options,' which aligns with the parameters but does not elaborate on their semantics or usage. Baseline 3 is appropriate as the schema does the heavy lifting.

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: 'Find pages that have been modified today (since midnight)' with 'pagination and sorting options.' It specifies the verb ('Find'), resource ('pages'), and temporal scope ('today'), but does not explicitly differentiate from sibling tools like 'roam_search_by_date' or 'roam_search_by_text,' which could have overlapping functionality.

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 mentions 'pagination and sorting options' but does not specify use cases, prerequisites, or exclusions compared to sibling tools such as 'roam_search_by_date' or 'roam_search_by_text,' leaving the agent without contextual direction.

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/camiloluvino/roamMCP'

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