Skip to content

[Bug]: retrieve_tools misses non-contiguous underscore segments in tool names #1290

Closed

Description

@neylwalecki

What happened?

retrieve_tools handles exact, prefix, and contiguous wildcard matches for underscore-containing tool names, but it does not treat identifier segments as independently searchable terms.

For example, a tool named work_start_task_attachment_upload is not found by the query work_upload_attachment, even though every requested segment is present. A natural-language description query can find the same tool, so the limitation is specific to identifier-style discovery.

The current underscore regression test covers a contiguous substring (Get_current_TVL), which passes through the wildcard query, but not non-contiguous identifier segments.

This is intentionally narrower than hybrid/vector search in #31 and requires no external model or service.

Expected behavior

  • Treat underscore-separated identifier segments as an additional internal search signal.
  • Require all normalized query segments for that signal.
  • Keep the canonical tool name and exact-match boost unchanged.
  • Return the original canonical tool ID without publishing aliases or duplicate tools.

Steps to reproduce

  1. Index this synthetic tool in internal/index:

    &config.ToolMetadata{
        Name:        "work_start_task_attachment_upload",
        ServerName:  "fixture",
        Description: "Create a signed request for a local file.",
        ParamsJSON:  `{"type":"object","properties":{}}`,
        Hash:        "synthetic",
    }
  2. Run SearchTools("work_upload_attachment", 10).

  3. Observe that the result list is empty.

I reproduced this with MCPProxy v0.66.1 and current main at 8acb506deb0a64f9c538843cfed0882036f1da8a.

Implementation question

I can prepare a focused PR with index-level regression tests. Before settling the implementation, would you prefer:

  1. A normalized internal index field, with an explicit safe rebuild/migration path; or
  2. Segment-aware query clauses over the existing keyword field, avoiding an index mapping change?

The first option offers cleaner term semantics but changes the persisted Bleve mapping. The second keeps the existing index but needs careful segment-boundary and performance handling.

Environment

  • MCPProxy version: v0.66.1 (personal) darwin/arm64
  • Operating system: macOS

Pre-submission checklist

  • I searched existing issues and discussions and did not find a duplicate.

Activity

  1. Dumbris commented on Sep 17, 2026

    @Dumbris
    Member

    Thanks for the clean repro and the two options, @neylwalecki!

    Go with Option 2 — we don't have index-rebuild infra yet, so a mapping change would mean building that first for no real gain at our tool-set sizes.

    Left a couple of correctness notes on #1291.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions