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

Inconsistent tool extraction between hybrid and client-side search paths

Đang mở
#805 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
parking-lot search semantic-search
Ngôn ngữ chính
Python
Star
912
Fork
234
Merge trung bình
1 ngày 11 giờ
Pull request đã merge (30 ngày)
62

Mô tả

## 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+)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.