Skip to main content
Glama

semanticSearch

Find relevant content by meaning across knowledge bases 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
NameRequiredDescriptionDefault
namespaceIdNo
queryYes
topKNo
scoreThresholdNo
filterNo
tenantIdNo
searchTypeNo

Implementation Reference

  • MCP tool handler function for 'semanticSearch' that extracts parameters, creates SourceSyncApiClient, and delegates to its semanticSearch method.
    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, }) }) },
  • Zod schema (SemanticSearchSchema) defining the input validation for the semanticSearch tool, including query, optional topK, scoreThreshold, filter, etc.
    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 using server.tool, specifying name, description, input schema, and handler function.
    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, }) }) }, )
  • SourceSyncApiClient.semanticSearch helper method that makes the POST request to SourceSync API /v1/search endpoint to execute the semantic search.
    */ 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>() }

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/pbteja1998/sourcesyncai-mcp'

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