mcpproxy-go icon indicating copy to clipboard operation
mcpproxy-go copied to clipboard

[Feature]: Optional upstream selector for retrieve_tools

Open neylwalecki opened this issue 1 month ago • 1 comments

Problem / motivation

When an agent already knows which upstream owns a capability, it still has to search the global catalog with retrieve_tools. Including the upstream name in the query does not restrict results to that upstream. In larger catalogs, unrelated tools can occupy the result window, requiring more searches or a larger response.

This request follows the upstream-search item discussed in #969. That issue also covered diagnostics and preflight work, which should remain separate from this proposal.

Proposed solution

Add an optional exact upstream selector to retrieve_tools. Its name and accepted shape are open for discussion. For example, a single-server selector could look like this (illustrative API, not currently supported):

{"query":"list records","server":"sample-catalog","limit":5}

Expected behavior:

  • Only consider tools belonging to the selected upstream that the caller is already allowed to discover.
  • Apply the selector before the final result limit.
  • Preserve token and profile boundaries, tool policy, quarantine, approval and annotation filters.
  • Keep existing calls without the selector compatible.
  • Define a non-disclosing response for unknown or inaccessible upstreams.

This is a catalog-narrowing feature. It does not require changing global profiles or rewriting the ranking algorithm.

Alternatives considered

  • Include the upstream name in the text query. This is available today, but it is not an exact filter.
  • Increase the result limit. This can reveal relevant matches but increases response size and does not restrict the catalog.
  • Inspect the upstream catalog and use describe_tool when the exact tool ID is known. This helps known-tool workflows, but does not replace searching within one upstream for an unknown tool.
  • Use a dedicated profile. Profiles establish persistent access and policy boundaries; a per-request selector would narrow discovery within those existing permissions.

Which edition?

Personal was the observed use case on v0.72.0. The proposed authorization semantics should also apply to Server edition; no Server deployment reproduction is claimed here.

Additional context

The qualified-ID retrieval defect is a separate investigation and is not the subject of this feature request. Synthetic fixtures can test selection before the limit, duplicate tool names across servers, caller scope, profiles and approval states once the API contract is agreed.

Pre-submission checklist

  • [x] I searched existing issues and discussions for a similar request.

neylwalecki avatar Nov 04 '26 23:11 neylwalecki

Thanks for filing this. It is the item we deferred in #969, and I agree it is worth doing.

Proposed contract, so we can settle it before code:

  • New optional string argument server on retrieve_tools, declared once and shared by all three registrations.
  • Exact match on the configured server name. No wildcards and no list in v1.
  • Applied together with the existing scope check, before the ranked result is cut to limit. Token scope, profile scope and tool policy still apply first.
  • An unknown server and a server the caller cannot see give the same answer as a visible server with no matching tools: the normal empty result. No error and no hint, so it cannot be used to probe which servers exist. Same rule as the profile pin boundary in Spec 118.
  • Quarantine, approval, include_disabled and the annotation filters work as today. Locked name-only entries and the debug counts use the same selector.
  • Calls without server stay byte-identical.

The work is mostly in handleRetrieveToolsWithMode, one shared schema helper, the tools/list goldens, and tests for selection before the limit, duplicate tool names across servers, scoped tokens and pinned profiles. I would keep the REST /api/v1/index/search parameter as a follow-up.

If you want to send the PR, I am happy to review it against this contract. Tell me if you would rather I take it.

Dumbris avatar Nov 06 '26 10:11 Dumbris