Skip to main content
Glama
camiloluvino

Roam Research MCP Server

by camiloluvino

roam_search_by_status

Search for TODO or DONE blocks across Roam Research pages using status filters and optional content terms to organize tasks.

Instructions

Search for blocks with a specific status (TODO/DONE) across all pages or within a specific page.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
statusYesStatus to search for (TODO or DONE)
page_title_uidNoOptional: Title or UID of the page to search in (UID is preferred for accuracy). If not provided, searches across all pages.
includeNoOptional: Comma-separated list of terms to filter results by inclusion (matches content or page title)
excludeNoOptional: Comma-separated list of terms to filter results by exclusion (matches content or page title)

Implementation Reference

  • Core implementation of the status search logic using Datomic queries to find blocks containing '{{[[TODO]]}}' or '{{[[DONE]]}}' markers, with optional page scoping, block ref resolution, and result formatting.
    export class StatusSearchHandler extends BaseSearchHandler {
      constructor(
        graph: Graph,
        private params: StatusSearchParams
      ) {
        super(graph);
      }
    
      async execute(): Promise<SearchResult> {
        const { status, page_title_uid } = this.params;
    
        // Get target page UID if provided
        let targetPageUid: string | undefined;
        if (page_title_uid) {
          targetPageUid = await SearchUtils.findPageByTitleOrUid(this.graph, page_title_uid);
        }
    
        // Build query based on whether we're searching in a specific page
        let queryStr: string;
        let queryParams: any[];
    
        if (targetPageUid) {
          queryStr = `[:find ?block-uid ?block-str
                      :in $ ?status ?page-uid
                      :where [?p :block/uid ?page-uid]
                             [?b :block/page ?p]
             [?b :block/string ?block-str]
             [?b :block/uid ?block-uid]
             [(clojure.string/includes? ?block-str (str "{{[[" ?status "]]}}"))]]`;
          queryParams = [status, targetPageUid];
        } else {
          queryStr = `[:find ?block-uid ?block-str ?page-title
                      :in $ ?status
                      :where [?b :block/string ?block-str]
                             [?b :block/uid ?block-uid]
                             [?b :block/page ?p]
                             [?p :node/title ?page-title]
                             [(clojure.string/includes? ?block-str (str "{{[[" ?status "]]}}"))]]`;
          queryParams = [status];
        }
    
        const rawResults = await q(this.graph, queryStr, queryParams) as [string, string, string?][];
        
        // Resolve block references in content
        const resolvedResults = await Promise.all(
          rawResults.map(async ([uid, content, pageTitle]) => {
            const resolvedContent = await resolveRefs(this.graph, content);
            return [uid, resolvedContent, pageTitle] as [string, string, string?];
          })
        );
        
        return SearchUtils.formatSearchResults(resolvedResults, `with status ${status}`, !targetPageUid);
      }
    }
  • Input schema definition, description, and tool name mapping for 'roam_search_by_status'.
    [toolName(BASE_TOOL_NAMES.SEARCH_BY_STATUS)]: {
      name: toolName(BASE_TOOL_NAMES.SEARCH_BY_STATUS),
      description: 'Search for blocks with a specific status (TODO/DONE) across all pages or within a specific page.',
      inputSchema: {
        type: 'object',
        properties: {
          status: {
            type: 'string',
            description: 'Status to search for (TODO or DONE)',
            enum: ['TODO', 'DONE']
          },
          page_title_uid: {
            type: 'string',
            description: 'Optional: Title or UID of the page to search in (UID is preferred for accuracy). If not provided, searches across all pages.'
          },
          include: {
            type: 'string',
            description: 'Optional: Comma-separated list of terms to filter results by inclusion (matches content or page title)'
          },
          exclude: {
            type: 'string',
            description: 'Optional: Comma-separated list of terms to filter results by exclusion (matches content or page title)'
          }
        },
        required: ['status']
      }
    },
  • Tool registration in the MCP server request handler switch statement, dispatching to ToolHandlers.searchByStatus.
    case BASE_TOOL_NAMES.SEARCH_BY_STATUS: {
      const { status, page_title_uid, include, exclude } = request.params.arguments as {
        status: 'TODO' | 'DONE';
        page_title_uid?: string;
        include?: string;
        exclude?: string;
      };
      const result = await this.toolHandlers.searchByStatus(status, page_title_uid, include, exclude);
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • SearchOperations.searchByStatus method that instantiates the StatusSearchHandler, executes core search, and applies post-processing filters for include/exclude parameters.
    async searchByStatus(
      status: 'TODO' | 'DONE',
      page_title_uid?: string,
      include?: string,
      exclude?: string
    ): Promise<SearchHandlerResult> {
      const handler = new StatusSearchHandlerImpl(this.graph, {
        status,
        page_title_uid,
      });
      const result = await handler.execute();
    
      // Post-process results with include/exclude filters
      let matches = result.matches;
    
      if (include) {
        const includeTerms = include.split(',').map(term => term.trim());
        matches = matches.filter((match: SearchResult) => {
          const matchContent = match.content;
          const matchTitle = match.page_title;
          const terms = includeTerms;
          return terms.some(term => 
            matchContent.includes(term) ||
            (matchTitle && matchTitle.includes(term))
          );
        });
      }
    
      if (exclude) {
        const excludeTerms = exclude.split(',').map(term => term.trim());
        matches = matches.filter((match: SearchResult) => {
          const matchContent = match.content;
          const matchTitle = match.page_title;
          const terms = excludeTerms;
          return !terms.some(term => 
            matchContent.includes(term) ||
            (matchTitle && matchTitle.includes(term))
          );
        });
      }
    
      return {
        success: true,
        matches,
        message: `Found ${matches.length} block(s) with status ${status}${include ? ` including "${include}"` : ''}${exclude ? ` excluding "${exclude}"` : ''}`
      };
    }
  • Delegation method in ToolHandlers class that routes the tool call to SearchOperations.
    async searchByStatus(
      status: 'TODO' | 'DONE',
      page_title_uid?: string,
      include?: string,
      exclude?: string
    ) {
      return this.searchOps.searchByStatus(status, page_title_uid, include, exclude);
    }
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 searching 'across all pages or within a specific page', which adds some behavioral context, but it doesn't disclose critical traits like whether this is a read-only operation, potential rate limits, authentication needs, or what the output format looks like (e.g., list of blocks). For a search tool with no annotations, this is a significant gap.

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 ('Search for blocks with a specific status') and includes key details (status types and scope). There is no wasted verbiage, making it appropriately sized and structured.

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 no annotations and no output schema, the description is incomplete. It lacks information on behavioral traits (e.g., read-only nature, error handling) and output format, which are crucial for a search tool. While the schema covers inputs well, the overall context for an AI agent to use this tool effectively is insufficient.

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 'across all pages or within a specific page', which loosely relates to the 'page_title_uid' parameter, but it doesn't provide additional syntax or format details. Baseline 3 is appropriate when 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 verb 'search' and resource 'blocks with a specific status (TODO/DONE)', making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'roam_search_by_text' or 'roam_search_for_tag', which also search blocks but with different criteria, so it falls short of a perfect 5.

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 by mentioning 'across all pages or within a specific page', providing some context, but it doesn't explicitly state when to use this tool versus alternatives like other search tools (e.g., 'roam_search_by_text' for text-based searches). No exclusions or clear alternatives are named, so it's not fully explicit.

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