Skip to content

Per-server lazy discovery for tools/call, resources/read, prompts/get#81

Merged
avelino merged 2 commits intomainfrom
avelino/issue-77
Apr 14, 2026
Merged

Per-server lazy discovery for tools/call, resources/read, prompts/get#81
avelino merged 2 commits intomainfrom
avelino/issue-77

Conversation

@avelino
Copy link
Copy Markdown
Owner

@avelino avelino commented Apr 14, 2026

On cold start, tools/call was blocking on discovery of ALL backends before responding — a fast CLI call like gh issue view took 5-30s waiting for kubectl, grafana, slack and every other server to finish.

Infer the target backend from the namespaced tool name (server__tool) and discover only that server. Listing operations (tools/list, resources/list, prompts/list) still do full batch discovery since the client wants the complete catalog. Falls back to all-backend discovery when the backend can't be inferred from the name.

Fixed: #77

On cold start, tools/call was blocking on discovery of ALL backends before
responding — a fast CLI call like gh issue view took 5-30s waiting for
kubectl, grafana, slack and every other server to finish.

Infer the target backend from the namespaced tool name (server__tool) and
discover only that server. Listing operations (tools/list, resources/list,
prompts/list) still do full batch discovery since the client wants the
complete catalog. Falls back to all-backend discovery when the backend
can't be inferred from the name.

Fixed: #77

Signed-off-by: Avelino <[email protected]>
Copilot AI review requested due to automatic review settings April 14, 2026 09:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements per-server lazy discovery for single-item requests so cold-start tools/call / resources/read / prompts/get no longer blocks on discovering every configured backend.

Changes:

  • Add backend inference (server__toolserver) and a per-backend “needs discovery” check in ProxyServer.
  • Update request dispatch to discover only the inferred backend for tools/call, resources/read, and prompts/get (with fallback to full discovery when inference fails).
  • Add discover_single_backend and update docs to describe the new discovery behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/serve/proxy.rs Adds backend-name inference helper, per-backend undiscovered check, and unit tests for both.
src/serve/dispatch.rs Switches single-item request paths to per-backend discovery (or full discovery fallback).
src/serve/discovery.rs Introduces discover_single_backend and cache persistence for single-backend discovery.
docs/reference/architecture.md Documents per-server lazy discovery behavior and its concurrency implications.
docs/guides/proxy-mode.md Updates proxy-mode guide to reflect the per-server discovery behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/serve/discovery.rs
Comment thread src/serve/discovery.rs Outdated
Comment thread src/serve/discovery.rs
Comment thread docs/reference/architecture.md Outdated
Comment thread docs/guides/proxy-mode.md Outdated
Signed-off-by: Avelino <[email protected]>
@avelino avelino merged commit 1ba87fc into main Apr 14, 2026
6 of 8 checks passed
@avelino avelino deleted the avelino/issue-77 branch April 14, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI transport: first tool call blocks on all-backend discovery

2 participants