agentic-community / agentic-community/mcp-gateway-registry

Inconsistent tool extraction between hybrid and client-side search paths

未关闭
#805 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
parking-lot search semantic-search
主要语言
Python
星标
912
派生
234
平均合并
1 天 11 小时
30 天内合并 PR
62

描述

## Problem

Tool extraction from selected servers behaves differently between the two search paths:

- **Client-side path (MongoDB CE)**: Uses cosine similarity between the query embedding and tool name/description embeddings. Semantic matching means `currenttime` successfully extracts `current_time_by_timezone` from the Current Time API server.

- **Hybrid path (DocumentDB)**: Uses keyword/regex matching against search tokens. The single token `currenttime` does not regex-match `current_time_by_timezone` (underscores act as word boundaries). Searching `current_time` (two tokens: `current` + `time`) works correctly.

## Observed Behavior

| Query | Path | Tools Extracted |
|-------|------|----------------|
| `currenttime` | Client-side (MongoDB CE) | 2 (current_time_by_timezone from both Current Time API instances) |
| `currenttime` | Hybrid (DocumentDB) | 0 |
| `current_time` | Client-side (MongoDB CE) | 2 |
| `current_time` | Hybrid (DocumentDB) | 1 (current_time_by_timezone) |

## Expected Behavior

Both search paths should produce consistent tool extraction results for semantically equivalent queries.

## Possible Approaches

1. **Semantic tool matching on hybrid path**: Compute cosine similarity between query embedding and tool name/description for selected servers. Most accurate but adds latency (embedding computation per tool).

2. **Improved token matching**: Before regex matching, normalize both search tokens and tool names by stripping underscores/hyphens. So `currenttime` would match against `currenttimebytimezone`. Cheap and handles the common case.

3. **Accept the inconsistency**: The difference only matters for edge cases where users don't use natural word spacing. `current time` and `current_time` both work on both paths.

## Context

Discovered during verification of the result distribution algorithm (PR #804). The distribution algorithm itself works correctly on both paths -- this is specifically about tool extraction from selected servers.

## Files

- `registry/repositories/documentdb/search_repository.py` -- hybrid path tool extraction (~line 1780+), client-side tool extraction (~line 1125+)

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。