Skip to main content
Glama
disnet
by disnet

search_notes_advanced

Search notes in Flint Note using structured filters for metadata, dates, content, and sorting to find specific information quickly.

Instructions

Advanced search with structured filters for metadata, dates, and content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeNoFilter by note type
metadata_filtersNoArray of metadata filters
updated_withinNoFind notes updated within time period (e.g., "7d", "1w", "2m")
updated_beforeNoFind notes updated before time period (e.g., "7d", "1w", "2m")
created_withinNoFind notes created within time period
created_beforeNoFind notes created before time period
content_containsNoSearch within note content
sortNoSort order for results
limitNoMaximum number of results
offsetNoNumber of results to skip
vault_idNoOptional vault ID to operate on. If not provided, uses the current active vault.
fieldsNoOptional array of field names to include in response. Supports dot notation for nested fields (e.g. "metadata.tags") and wildcard patterns (e.g. "metadata.*"). If not specified, all fields are returned.

Implementation Reference

  • The primary MCP tool handler for 'search_notes_advanced'. Validates arguments, resolves vault context, executes advanced search via HybridSearchManager, applies field filtering, and returns formatted JSON results.
     */
    handleSearchNotesAdvanced = async (args: SearchNotesAdvancedArgs) => {
      // Validate arguments
      validateToolArgs('search_notes_advanced', args);
    
      const { hybridSearchManager } = await this.resolveVaultContext(args.vault_id);
    
      const results = await hybridSearchManager.searchNotesAdvanced(args);
    
      // Apply field filtering if specified
      const filteredResults = filterSearchResults(results, args.fields);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(filteredResults, null, 2)
          }
        ]
      };
    };
  • Tool registration and schema definition in the TOOL_SCHEMAS array used for MCP tool registration. Defines name, description, and complete input schema.
    {
      name: 'search_notes_advanced',
      description:
        'Advanced search with structured filters for metadata, dates, and content',
      inputSchema: {
        type: 'object',
        properties: {
          type: {
            type: 'string',
            description: 'Filter by note type'
          },
          metadata_filters: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                key: {
                  type: 'string',
                  description: 'Metadata key to filter on'
                },
                value: {
                  type: 'string',
                  description: 'Value to match'
                },
                operator: {
                  type: 'string',
                  enum: ['=', '!=', '>', '<', '>=', '<=', 'LIKE', 'IN'],
                  description: 'Comparison operator',
                  default: '='
                }
              },
              required: ['key', 'value']
            },
            description: 'Filters for metadata fields'
          },
          updated_within: {
            type: 'string',
            description: 'Filter notes updated within this period (e.g., "7d", "1h")'
          },
          updated_before: {
            type: 'string',
            description: 'Filter notes updated before this date (ISO format)'
          },
          created_within: {
            type: 'string',
            description: 'Filter notes created within this period (e.g., "7d", "1h")'
          },
          created_before: {
            type: 'string',
            description: 'Filter notes created before this date (ISO format)'
          },
          content_query: {
            type: 'string',
            description: 'Search within note content'
          },
          title_query: {
            type: 'string',
            description: 'Search within note titles'
          },
          limit: {
            type: 'number',
            description: 'Maximum number of results to return'
          },
          vault_id: {
            type: 'string',
            description:
              'Optional vault ID to search in. If not provided, uses the current active vault.'
          },
          fields: {
            type: 'array',
            items: {
              type: 'string'
            },
            description:
              'Optional list of fields to include in response (id, title, content, type, filename, path, created, updated, size, metadata)'
          }
        }
      }
    },
  • Validation rules and custom validators for search_notes_advanced tool arguments in TOOL_VALIDATION_RULES, plus dedicated validateSearchNotesAdvancedArgs function.
    search_notes_advanced: [
      {
        field: 'type',
        required: false,
        type: 'string',
        allowEmpty: false
      },
      {
        field: 'metadata_filters',
        required: false,
        type: 'array',
        allowEmpty: true
      },
      {
        field: 'updated_within',
        required: false,
        type: 'string',
        allowEmpty: false
      },
      {
        field: 'updated_before',
        required: false,
        type: 'string',
        allowEmpty: false
      },
      {
        field: 'created_within',
        required: false,
        type: 'string',
        allowEmpty: false
      },
      {
        field: 'created_before',
        required: false,
        type: 'string',
        allowEmpty: false
      },
      {
        field: 'content_contains',
        required: false,
        type: 'string',
        allowEmpty: false
      },
      {
        field: 'sort',
        required: false,
        type: 'array',
        allowEmpty: true
      },
      {
        field: 'limit',
        required: false,
        type: 'number'
      },
      {
        field: 'offset',
        required: false,
        type: 'number'
      },
      {
        field: 'vault_id',
        required: false,
        type: 'string',
        allowEmpty: false
      },
      {
        field: 'fields',
        required: false,
        type: 'array',
        arrayItemType: 'string',
        allowEmpty: true
      }
    ],
  • Core implementation of advanced note search in HybridSearchManager. Constructs SQL queries dynamically based on filters (type, metadata, dates, content), handles pagination, FTS integration, and result formatting.
    async searchNotesAdvanced(options: AdvancedSearchOptions): Promise<SearchResponse> {
      const startTime = Date.now();
      const connection = await this.getReadOnlyConnection();
    
      try {
        const limit = options.limit ?? 50;
        const offset = options.offset ?? 0;
    
        const sql = 'SELECT DISTINCT n.*';
        const countSql = 'SELECT COUNT(DISTINCT n.id) as total';
        let fromClause = ' FROM notes n';
        const whereConditions: string[] = [];
        const params: (string | number)[] = [];
        const joins: string[] = [];
    
        // Type filter
        if (options.type) {
          whereConditions.push('n.type = ?');
          params.push(options.type);
        }
    
        // Metadata filters
        if (options.metadata_filters && options.metadata_filters.length > 0) {
          options.metadata_filters.forEach((filter, index) => {
            const alias = `m${index}`;
            joins.push(`JOIN note_metadata ${alias} ON n.id = ${alias}.note_id`);
    
            whereConditions.push(`${alias}.key = ?`);
            params.push(filter.key);
    
            const operator = filter.operator || '=';
            if (operator === 'IN') {
              const values = filter.value.split(',').map(v => v.trim());
              const placeholders = values.map(() => '?').join(',');
              whereConditions.push(`${alias}.value IN (${placeholders})`);
              params.push(...values);
            } else {
              whereConditions.push(`${alias}.value ${operator} ?`);
              params.push(filter.value);
            }
          });
        }
    
        // Date filters
        if (options.updated_within) {
          const date = this.parseDateFilter(options.updated_within);
          whereConditions.push('n.updated >= ?');
          params.push(date);
        }
    
        if (options.updated_before) {
          const date = this.parseDateFilter(options.updated_before);
          whereConditions.push('n.updated <= ?');
          params.push(date);
        }
    
        if (options.created_within) {
          const date = this.parseDateFilter(options.created_within);
          whereConditions.push('n.created >= ?');
          params.push(date);
        }
    
        if (options.created_before) {
          const date = this.parseDateFilter(options.created_before);
          whereConditions.push('n.created <= ?');
          params.push(date);
        }
    
        // Content search
        if (options.content_contains) {
          joins.push('JOIN notes_fts fts ON n.id = fts.id');
          whereConditions.push('notes_fts MATCH ?');
          params.push(options.content_contains);
        }
    
        // Build complete query
        fromClause += ' ' + joins.join(' ');
    
        if (whereConditions.length > 0) {
          fromClause += ' WHERE ' + whereConditions.join(' AND ');
        }
    
        // Add sorting
        let orderClause = '';
        if (options.sort && options.sort.length > 0) {
          const sortTerms = options.sort.map(
            sort => `n.${sort.field} ${sort.order.toUpperCase()}`
          );
          orderClause = ' ORDER BY ' + sortTerms.join(', ');
        } else {
          orderClause = ' ORDER BY n.updated DESC';
        }
    
        // Execute count query
        const countResult = await connection.get<{ total: number }>(
          countSql + fromClause,
          params
        );
        const total = countResult?.total || 0;
    
        // Execute main query
        const mainSql = sql + fromClause + orderClause + ' LIMIT ? OFFSET ?';
        const rows = await connection.all<SearchRow>(mainSql, [...params, limit, offset]);
    
        const results = await this.convertRowsToResults(rows, connection);
        const queryTime = Date.now() - startTime;
    
        return {
          results,
          total,
          has_more: offset + results.length < total,
          query_time_ms: queryTime
        };
      } catch (error) {
        throw new Error(
          `Advanced search failed: ${error instanceof Error ? error.message : 'Unknown error'}`
        );
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'advanced search' but fails to describe critical behaviors such as pagination (implied by limit/offset parameters but not explained), rate limits, authentication needs, error handling, or what the search returns (e.g., result format, default fields). This leaves significant gaps for a tool with 12 parameters and no output schema.

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 key information ('Advanced search with structured filters') without unnecessary words. Every part of the sentence earns its place by specifying the tool's core functionality, making it easy to scan and understand quickly.

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's complexity (12 parameters, no annotations, no output schema), the description is insufficient. It lacks details on behavioral traits (e.g., search performance, result limits), usage context (e.g., when to choose over siblings), and output expectations. For a search tool with many options, this leaves the agent under-informed about how to effectively invoke it.

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 12 parameters thoroughly. The description adds minimal value by hinting at filter types ('metadata, dates, and content'), but it doesn't provide additional context like parameter interactions, default behaviors, or examples beyond what the schema specifies. This meets the baseline for high schema coverage.

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 as 'Advanced search with structured filters for metadata, dates, and content,' which specifies the verb (search), resource (notes), and scope (advanced with structured filters). It distinguishes itself from simpler search tools like 'search_notes' but doesn't explicitly differentiate from 'search_notes_sql' or 'search_by_links' among siblings.

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 'search_notes' (simpler search), 'search_notes_sql' (SQL-based), or 'search_by_links' (link-focused). It mentions 'advanced search' but doesn't clarify specific use cases, prerequisites, or exclusions, leaving the agent to infer usage from the tool name 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

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/disnet/flint-note'

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