semanticSearch
Find relevant content by meaning across namespaces using semantic search, enabling discovery beyond exact keyword matches.
Instructions
Performs semantic search across the namespace to find relevant content based on meaning rather than exact keyword matches.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| namespaceId | No | ||
| query | Yes | ||
| topK | No | ||
| scoreThreshold | No | ||
| filter | No | ||
| tenantId | No | ||
| searchType | No |
Implementation Reference
- src/sourcesync.ts:562-584 (handler)The core handler function in SourceSyncApiClient that performs the semantic search by making a POST request to the '/v1/search' endpoint with the provided query and parameters.public async semanticSearch({ query, topK, scoreThreshold, filter, searchType, }: Omit< SourceSyncSemanticSearchRequest, 'namespaceId' >): Promise<SourceSyncSearchResponse> { return this.client .url('/v1/search') .json({ query, namespaceId: this.namespaceId, topK, scoreThreshold, filter, searchType, } satisfies SourceSyncSemanticSearchRequest) .post() .json<SourceSyncSearchResponse>() }
- src/schemas.ts:427-439 (schema)Zod schema defining the input parameters and validation for the semanticSearch tool.export const SemanticSearchSchema = z.object({ namespaceId: namespaceIdSchema.optional(), query: z.string(), topK: z.number().optional(), scoreThreshold: z.number().optional(), filter: z .object({ metadata: z.record(z.union([z.string(), z.array(z.string())])).optional(), }) .optional(), tenantId: tenantIdSchema, searchType: SearchTypeEnum.optional(), })
- src/index.ts:571-600 (registration)Registers the 'semanticSearch' tool with the MCP server, including description, input schema, and wrapper handler that creates a client and delegates to the semanticSearch method.server.tool( 'semanticSearch', 'Performs semantic search across the namespace to find relevant content based on meaning rather than exact keyword matches.', SemanticSearchSchema.shape, async (params: any) => { return safeApiCall(async () => { const { namespaceId, query, topK, scoreThreshold, filter, tenantId, searchType, } = params // Create a client with the provided parameters const client = createClient({ namespaceId, tenantId }) // Call the semanticSearch method with the searchType (default to SEMANTIC if not provided) return await client.semanticSearch({ query, topK, scoreThreshold, filter, searchType: searchType || SourceSyncSearchType.SEMANTIC, }) }) }, )
- src/sourcesync.types.ts:695-702 (schema)TypeScript type definition for the SourceSyncSemanticSearchRequest used in the semanticSearch handler.export type SourceSyncSemanticSearchRequest = { query: string namespaceId: string topK?: number scoreThreshold?: number filter?: SourceSyncSearchFilter searchType?: SourceSyncSearchType.SEMANTIC }