Skip to main content
Glama
jakedx6
by jakedx6

get_search_suggestions

Generate intelligent search suggestions and autocomplete results for partial queries, including recent searches, popular terms, and entity suggestions to improve search accuracy.

Instructions

Get intelligent search suggestions and autocomplete

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
partial_queryYesPartial search query for autocomplete
suggestion_typesNoTypes of suggestions to return
context_project_idNoProject context for better suggestions
max_suggestionsNoMaximum number of suggestions

Implementation Reference

  • The handler function that implements the core logic for the get_search_suggestions tool. It parses arguments with Zod schema, loops over suggestion types calling helper functions, aggregates results, and returns structured suggestions object.
    export const getSearchSuggestions = requireAuth(async (args: any) => { const { partial_query, suggestion_types, context_project_id, max_suggestions } = GetSearchSuggestionsSchema.parse(args) logger.info('Getting search suggestions', { partial_query, suggestion_types }) const suggestions: any = { partial_query, suggestions: {}, total_suggestions: 0 } for (const suggestionType of suggestion_types) { try { let typeSuggestions: any[] = [] switch (suggestionType) { case 'recent_searches': typeSuggestions = await getRecentSearches(partial_query, context_project_id) break case 'popular_terms': typeSuggestions = await getPopularSearchTerms(partial_query, context_project_id) break case 'related_concepts': typeSuggestions = await getRelatedConcepts(partial_query, context_project_id) break case 'entity_suggestions': typeSuggestions = await getEntitySuggestions(partial_query, context_project_id) break } suggestions.suggestions[suggestionType] = typeSuggestions.slice(0, max_suggestions) suggestions.total_suggestions += typeSuggestions.length } catch (error) { logger.error(`Failed to get suggestions for ${suggestionType}:`, error) suggestions.suggestions[suggestionType] = [] } } return suggestions })
  • Zod schema used for input validation and parsing in the getSearchSuggestions handler.
    const GetSearchSuggestionsSchema = z.object({ partial_query: z.string().min(1), suggestion_types: z.array(z.enum(['recent_searches', 'popular_terms', 'related_concepts', 'entity_suggestions'])).default(['recent_searches', 'popular_terms', 'entity_suggestions']), context_project_id: z.string().optional(), max_suggestions: z.number().min(1).max(20).default(10) })
  • MCPTool definition registering the get_search_suggestions tool with name, description, and JSON inputSchema for MCP protocol.
    export const getSearchSuggestionsTool: MCPTool = { name: 'get_search_suggestions', description: 'Get intelligent search suggestions and autocomplete', inputSchema: { type: 'object', properties: { partial_query: { type: 'string', description: 'Partial search query for autocomplete' }, suggestion_types: { type: 'array', items: { type: 'string', enum: ['recent_searches', 'popular_terms', 'related_concepts', 'entity_suggestions'] }, default: ['recent_searches', 'popular_terms', 'entity_suggestions'], description: 'Types of suggestions to return' }, context_project_id: { type: 'string', description: 'Project context for better suggestions' }, max_suggestions: { type: 'number', minimum: 1, maximum: 20, default: 10, description: 'Maximum number of suggestions' } }, required: ['partial_query'] } }
  • Registers the getSearchSuggestions handler function in the intelligentSearchHandlers export object, likely used for tool dispatching.
    export const intelligentSearchHandlers = { universal_search: universalSearch, semantic_search: semanticSearch, get_search_suggestions: getSearchSuggestions, get_search_analytics: getSearchAnalytics }
  • Helper function for 'entity_suggestions' type that queries projects via Supabase for matching names.
    async function getEntitySuggestions(partialQuery: string, projectId?: string): Promise<string[]> { // Search for project names, task titles, etc. that match const suggestions = [] try { const projects = await supabaseService.getProjects({ search: partialQuery }, { limit: 5 }) suggestions.push(...projects.map(p => p.name)) } catch (error) { logger.error('Error getting entity suggestions:', error) } return suggestions }

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/jakedx6/helios9-MCP-Server'

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