Skip to main content
Glama

TriliumNext Notes' MCP Server

searchHandler.ts1.38 kB
/** * Search Handler Module * Centralized request handling for search operations */ import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js"; import { PermissionChecker } from "../utils/permissionUtils.js"; import { SearchOperation, handleSearchNotes } from "./searchManager.js"; import { formatNotesForListing } from "../utils/noteFormatter.js"; /** * Handle search_notes tool requests */ export async function handleSearchNotesRequest( args: any, axiosInstance: any, permissionChecker: PermissionChecker ): Promise<{ content: Array<{ type: string; text: string }> }> { if (!permissionChecker.hasPermission("READ")) { throw new McpError(ErrorCode.InvalidRequest, "Permission denied: Not authorized to search notes."); } try { const searchOperation: SearchOperation = { text: args.text, searchCriteria: args.searchCriteria, limit: args.limit }; const result = await handleSearchNotes(searchOperation, axiosInstance); const resultsText = JSON.stringify(result.results, null, 2); return { content: [{ type: "text", text: `${result.debugInfo || ''}${resultsText}` }] }; } catch (error) { if (error instanceof McpError) { throw error; } throw new McpError(ErrorCode.InvalidParams, error instanceof Error ? error.message : String(error)); } }

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