Skip to main content
Glama

hybridSearch

Combine keyword and semantic search to find content by balancing exact matches with contextual relevance in knowledge bases.

Instructions

Performs a combined keyword and semantic search, balancing between exact matches and semantic similarity. Requires hybridConfig with weights for both search types.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namespaceIdNo
queryYes
topKNo
scoreThresholdNo
filterNo
hybridConfigYes
tenantIdNo
searchTypeNo

Implementation Reference

  • MCP server tool handler for 'hybridSearch'. Extracts parameters, creates SourceSyncApiClient using createClient, calls its hybridSearch method with appropriate defaults, wrapped in safeApiCall for error handling.
    async (params: any) => {
      return safeApiCall(async () => {
        const {
          namespaceId,
          query,
          topK,
          scoreThreshold,
          filter,
          hybridConfig,
          tenantId,
          searchType,
        } = params
    
        // Create a client with the provided parameters
        const client = createClient({ namespaceId, tenantId })
    
        // Call the hybridSearch method with the searchType (default to HYBRID if not provided)
        return await client.hybridSearch({
          query,
          topK,
          scoreThreshold,
          filter,
          hybridConfig,
          searchType: searchType || SourceSyncSearchType.HYBRID,
        })
      })
    },
  • Zod schema defining the input parameters for the hybridSearch tool, including query, optional topK, scoreThreshold, filter, required hybridConfig with weights, optional namespaceId and searchType, and tenantId.
    export const HybridSearchSchema = 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(),
      hybridConfig: z.object({
        semanticWeight: z.number(),
        keywordWeight: z.number(),
      }),
      tenantId: tenantIdSchema,
      searchType: SearchTypeEnum.optional(),
    })
  • src/index.ts:602-633 (registration)
    Registration of the 'hybridSearch' MCP tool using server.tool(), specifying the tool name, description, input schema, and handler function.
    server.tool(
      'hybridSearch',
      'Performs a combined keyword and semantic search, balancing between exact matches and semantic similarity. Requires hybridConfig with weights for both search types.',
      HybridSearchSchema.shape,
      async (params: any) => {
        return safeApiCall(async () => {
          const {
            namespaceId,
            query,
            topK,
            scoreThreshold,
            filter,
            hybridConfig,
            tenantId,
            searchType,
          } = params
    
          // Create a client with the provided parameters
          const client = createClient({ namespaceId, tenantId })
    
          // Call the hybridSearch method with the searchType (default to HYBRID if not provided)
          return await client.hybridSearch({
            query,
            topK,
            scoreThreshold,
            filter,
            hybridConfig,
            searchType: searchType || SourceSyncSearchType.HYBRID,
          })
        })
      },
    )
  • Underlying implementation of hybridSearch in SourceSyncApiClient class. Sends a POST request to the /v1/search/hybrid API endpoint with the search parameters and namespaceId, returning the search response.
    public async hybridSearch({
      query,
      topK,
      scoreThreshold,
      filter,
      hybridConfig,
      searchType,
    }: Omit<
      SourceSyncHybridSearchRequest,
      'namespaceId'
    >): Promise<SourceSyncSearchResponse> {
      return this.client
        .url('/v1/search/hybrid')
        .json({
          query,
          namespaceId: this.namespaceId,
          topK,
          scoreThreshold,
          filter,
          hybridConfig,
          searchType,
        } satisfies SourceSyncHybridSearchRequest)
        .post()
        .json<SourceSyncSearchResponse>()
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the requirement for hybridConfig and the balancing of search types, but lacks details on permissions, rate limits, output format, or potential side effects. For a search tool with 8 parameters and no annotation coverage, this leaves significant gaps in understanding how the tool behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with two sentences that are front-loaded with the core purpose. There's no wasted text, though it could be slightly more informative without losing efficiency. The structure is clear but brief.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (8 parameters, nested objects, no output schema, and no annotations), the description is incomplete. It doesn't explain return values, error handling, or the interplay between parameters like searchType and hybridConfig. For a tool with rich input schema and no structured support, more context is needed to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, meaning none of the 8 parameters are documented in the schema. The description only mentions 'hybridConfig with weights for both search types,' which partially explains one parameter (hybridConfig) but ignores the other 7 (e.g., namespaceId, query, topK). It adds minimal value beyond the bare schema, failing to compensate for the low coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Performs a combined keyword and semantic search, balancing between exact matches and semantic similarity.' It specifies the verb ('performs'), resource ('search'), and method ('combined keyword and semantic'), though it doesn't explicitly differentiate from the sibling 'semanticSearch' tool, which appears to be a related alternative.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides minimal guidance: it mentions that hybridConfig with weights is required, but offers no explicit advice on when to use this tool versus alternatives like 'semanticSearch' or other search-related tools in the sibling list. There's no context on use cases, prerequisites, or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.