semantic_search
Find relevant project information using AI-powered semantic search based on natural language queries, supporting various content types like technical documentation and meeting notes.
Instructions
Perform semantic similarity search using AI embeddings
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Natural language search query | |
| context_type | No | Type of context to optimize search for | general |
| similarity_threshold | No | Minimum similarity score for results | |
| max_results | No | Maximum number of results | |
| include_explanations | No | Include explanations of why items matched |
Implementation Reference
- src/tools/intelligent-search.ts:224-249 (handler)The main execution handler for the 'semantic_search' tool. Parses input using Zod schema, expands the query semantically based on context, performs the search, adds explanations if requested, and returns structured results.export const semanticSearch = requireAuth(async (args: any) => { const { query, context_type, similarity_threshold, max_results, include_explanations } = SemanticSearchSchema.parse(args) logger.info('Performing semantic search', { query, context_type, similarity_threshold }) // For now, implement a simplified semantic search using keyword expansion // In production, this would use actual embeddings/vector search const expandedQuery = expandSemanticQuery(query, context_type) const semanticResults = await performSemanticSearch(expandedQuery, similarity_threshold, max_results) if (include_explanations) { semanticResults.forEach((result: any) => { result.match_explanation = generateMatchExplanation(result, query, context_type) }) } return { original_query: query, expanded_query: expandedQuery, context_type, similarity_threshold, results: semanticResults, total_matches: semanticResults.length } })
- MCPTool definition for 'semantic_search', including name, description, and detailed inputSchema specifying parameters like query, context_type, similarity_threshold, max_results, and include_explanations.export const semanticSearchTool: MCPTool = { name: 'semantic_search', description: 'Perform semantic similarity search using AI embeddings', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Natural language search query' }, context_type: { type: 'string', enum: ['project_context', 'technical_documentation', 'meeting_notes', 'code_related', 'general'], default: 'general', description: 'Type of context to optimize search for' }, similarity_threshold: { type: 'number', minimum: 0, maximum: 1, default: 0.7, description: 'Minimum similarity score for results' }, max_results: { type: 'number', minimum: 1, maximum: 50, default: 10, description: 'Maximum number of results' }, include_explanations: { type: 'boolean', default: false, description: 'Include explanations of why items matched' } }, required: ['query'] } }
- Zod validation schema used within the handler to parse and validate input arguments.const SemanticSearchSchema = z.object({ query: z.string().min(1), context_type: z.enum(['project_context', 'technical_documentation', 'meeting_notes', 'code_related', 'general']).default('general'), similarity_threshold: z.number().min(0).max(1).default(0.7), max_results: z.number().min(1).max(50).default(10), include_explanations: z.boolean().default(false) })
- src/tools/intelligent-search.ts:667-672 (registration)Local registration of the semantic_search handler function within the intelligentSearchHandlers object.export const intelligentSearchHandlers = { universal_search: universalSearch, semantic_search: semanticSearch, get_search_suggestions: getSearchSuggestions, get_search_analytics: getSearchAnalytics }
- src/index.ts:143-155 (registration)Central registration in the MCP server where intelligentSearchHandlers (including semantic_search) are spread into the allHandlers object used by the server to dispatch tool calls.this.allHandlers = { ...projectHandlers, ...taskHandlers, ...documentHandlers, ...conversationHandlers, ...contextAggregationHandlers, ...workflowAutomationHandlers, ...intelligentSearchHandlers, ...analyticsInsightsHandlers, ...initiativeHandlers, ...promptToProjectTools.reduce((acc, tool) => ({ ...acc, [tool.name]: tool.handler }), {}), ...debugHandlers, }