Skip to main content
Glama

search_pages

Search Logseq pages by content or title, with optional filtering by tags and folder types to find specific information in your knowledge graph.

Instructions

페이지 내용/제목 검색. 태그 및 폴더 필터 지원

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes검색어
tagsNo태그 필터 (선택)
folderNo폴더 필터 (선택)

Implementation Reference

  • MCP tool handler for 'search_pages': parses arguments with schema and delegates to GraphService.searchPages method.
    case 'search_pages': {
      const { query, tags, folder } = SearchPagesSchema.parse(args);
      const results = await graph.searchPages(query, { tags, folder });
      return {
        content: [{ type: 'text', text: JSON.stringify(results, null, 2) }],
      };
    }
  • Zod schema defining input validation for search_pages tool: query (required), optional tags and folder filters.
    const SearchPagesSchema = z.object({
      query: z.string().max(MAX_QUERY_LENGTH).describe('검색어'),
      tags: z.array(z.string().max(MAX_TAG_LENGTH)).max(MAX_TAGS_COUNT).optional().describe('태그 필터 (선택)'),
      folder: z.enum(['pages', 'journals']).optional().describe('폴더 필터 (선택)'),
    });
  • src/index.ts:181-193 (registration)
    Registration of 'search_pages' tool in the TOOLS array, including name, description, and input schema for MCP server.
    {
      name: 'search_pages',
      description: '페이지 내용/제목 검색. 태그 및 폴더 필터 지원',
      inputSchema: {
        type: 'object' as const,
        properties: {
          query: { type: 'string', description: '검색어' },
          tags: { type: 'array', items: { type: 'string' }, description: '태그 필터 (선택)' },
          folder: { type: 'string', enum: ['pages', 'journals'], description: '폴더 필터 (선택)' },
        },
        required: ['query'],
      },
    },
  • Core implementation of page search in GraphService: lists pages, applies filters, scans content line-by-line for query matches, returns results with context.
    async searchPages(query: string, options?: { tags?: string[]; folder?: string }): Promise<SearchResult[]> {
      // 보안: 검색어 길이 제한 (DoS 방지)
      if (query.length > 1000) {
        throw new Error('Search query too long (max 1000 characters)');
      }
    
      const results: SearchResult[] = [];
      const pages = await this.listPages(options?.folder);
      const queryLower = query.toLowerCase();
    
      for (const page of pages) {
        // Filter by tags if specified
        if (options?.tags && options.tags.length > 0) {
          const hasTag = options.tags.some(tag => page.tags.includes(tag));
          if (!hasTag) continue;
        }
    
        // Search in content
        const filePath = join(this.graphPath, page.path);
    
        // 보안: TOCTOU 방지 - 심링크/하드링크 체크
        try {
          await this.checkRegularFile(filePath);
        } catch {
          continue; // 심링크/하드링크/특수파일은 건너뜀
        }
    
        const content = await readFile(filePath, 'utf-8');
        const lines = content.split('\n');
        const matches: SearchMatch[] = [];
    
        for (let i = 0; i < lines.length; i++) {
          if (lines[i].toLowerCase().includes(queryLower)) {
            matches.push({
              line: i + 1,
              content: lines[i],
              context: lines.slice(Math.max(0, i - 1), i + 2).join('\n'),
            });
          }
        }
    
        // Also match page name
        if (page.name.toLowerCase().includes(queryLower) || matches.length > 0) {
          results.push({ page, matches });
        }
      }
    
      return results;
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions search functionality and filter support but doesn't disclose behavioral traits like whether this is a read-only operation, how results are returned (e.g., pagination, format), performance considerations, or error handling. For a search tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 extremely concise with just one sentence in Korean, efficiently stating the purpose and key features (tag and folder filter support). Every word earns its place, and it's front-loaded with the core functionality. No unnecessary details or redundancy are present.

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 tool has 3 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what the search returns (e.g., list of pages, metadata), how results are structured, or any limitations (e.g., search scope, performance). For a search tool with moderate complexity and no structured output information, more context is needed to be fully helpful.

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 (query, tags, folder) with descriptions and constraints. The description adds minimal value by mentioning tag and folder filters but doesn't provide additional semantics beyond what's in the schema. With high schema coverage, the baseline score of 3 is appropriate.

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 searches page content/titles and mentions support for tag and folder filters. It specifies the verb ('검색' - search) and resource ('페이지 내용/제목' - page content/titles), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'list_pages' or 'get_journal' which might also retrieve page information.

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 like 'list_pages' or 'read_page'. It mentions tag and folder filter support, which implies usage for filtered searches, but doesn't specify scenarios, prerequisites, or exclusions. Without explicit when/when-not instructions, usage context is minimal.

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/dearcloud09/logseq-mcp'

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