agentic-community / agentic-community/mcp-gateway-registry
Inconsistent tool extraction between hybrid and client-side search paths
- Dominant language
- Python
- Stars
- 911
- Forks
- 234
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 62
Description
## 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+)
Contributor guide
Assessment
This issue has not been assessed yet.