Skip to main content
Glama

TriliumNext Notes' MCP Server

searchManager.ts1.85 kB
/** * Search Management Module * Handles search and listing operations for TriliumNext notes */ import { buildSearchQuery } from "./searchQueryBuilder.js"; import { trimNoteResults, formatNotesForListing } from "../utils/noteFormatter.js"; import { createSearchDebugInfo, createListSummary } from "../utils/verboseUtils.js"; // Interface for SearchOperation - unified searchCriteria structure export interface SearchOperation { text?: string; searchCriteria?: any[]; limit?: number; } export interface SearchResponse { results: any[]; debugInfo?: string; summary?: string; } /** * Handle search notes operation */ export async function handleSearchNotes( args: SearchOperation, axiosInstance: any ): Promise<SearchResponse> { // Build query from structured parameters const query = buildSearchQuery(args); if (!query.trim()) { throw new Error("At least one search parameter must be provided"); } const params = new URLSearchParams(); params.append("search", query); // Smart fastSearch logic: use fastSearch=true ONLY when ONLY text parameter is provided (no other parameters) const hasOnlyText = args.text && (!args.searchCriteria || !Array.isArray(args.searchCriteria) || args.searchCriteria.length === 0) && !args.limit; // fastSearch doesn't support limit clauses params.append("fastSearch", hasOnlyText ? "true" : "false"); params.append("includeArchivedNotes", "true"); // Always include archived notes const response = await axiosInstance.get(`/notes?${params.toString()}`); // Prepare verbose debug info if enabled const verboseInfo = createSearchDebugInfo(query, args); let searchResults = response.data.results || []; const trimmedResults = trimNoteResults(searchResults); return { results: trimmedResults, debugInfo: verboseInfo }; }

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/tan-yong-sheng/triliumnext-mcp'

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