Skip to content

fix(agent-plugins): scope tool discovery to requested servers - #14

Closed
tylerbishopdev wants to merge 1 commit into
patleeman:mainfrom
tylerbishopdev:fix/agent-plugins-scoped-discovery
Closed

tylerbishopdev wants to merge 1 commit into
patleeman:mainfrom
tylerbishopdev:fix/agent-plugins-scoped-discovery

Conversation

@tylerbishopdev

Copy link
Copy Markdown

Summary

Scope Agent Plugins tool discovery before connecting to MCP servers, so an unrelated slow or failing server cannot delay a targeted tool lookup or call.

Currently, the bridge applies serverId after gateway.listTools() walks every enabled/approved server sequentially. Describe and call also perform that global walk, including retries of unrelated failed servers once their backoff expires.

Changes

  • Pass serverId through the static bridge and CLI before catalog loading.
  • Resolve requested opaque tool IDs against their owning server, using an in-memory routing hint and the current catalog. A fresh gateway can resolve a previously issued ID when its configured-server prefix is unambiguous.
  • Always compare the complete opaque ID, including the existing hash, before dispatch. Unknown, removed, disabled, unapproved, wrong-owner, wrong-kind and stale IDs cannot execute a tool. Ambiguous cold prefixes fail closed as not-found; scoped discovery records their exact ownership.
  • Load broad tool catalogs with up to four concurrent workers per request while preserving catalog order. Per-server in-flight coalescing, TTL, refresh notifications and error backoff remain in use. Targeted requests do not retry unrelated failures.
  • Recheck approval before reusing a connection, and verify that the tool still exists before dispatch. No mutation retry is added.

Catalog semantics

A serverId-scoped result now returns servers counts for that scope only. Accurate cold counts for unrelated servers would require discovering them. Unscoped counts and ordering retain their existing behavior, including synthetic server-error entries.

Static bridge tool names and input schemas, opaque-ID generation, query ranking/pagination, describe ordering/deduplication, metadata forwarding and the call result/error envelope are retained. OAuth and transport implementations are unchanged. This is scoped tool discovery; it does not introduce a background search service or change prompt/resource discovery.

Verification

  • Agent Plugins package suite: 109 tests passed in 17 files, including 20 new scoped gateway/bridge tests.
  • Typecheck passed against the base branch's pinned @get-bb/plugin-sdk@0.5.29.
  • bb plugin build packages/bb-plugin-agent-plugins passed.
  • pnpm check:compat passed for all 16 plugins against stable BB 0.49.0 / SDK 0.6.132.
  • Marketplace schema/index/path checks and git diff --check passed.

Fixture coverage includes cold/warm targeted discovery with unrelated hanging/error servers, a healthy call during stalled broad discovery, bounded concurrency and stable ordering, per-server retry isolation, TTL/list-changed/reset invalidation, malformed/stale IDs, slug-prefix collisions, approval changes, same-server IDs across plugins, concurrent load coalescing and single-dispatch mutation failures. Bridge/CLI tests cover scoped wiring and the existing schema/result contract; local protocol/OAuth fixtures also pass.

Five files changed: gateway, bridge/CLI wiring, two test files and a README paragraph. No dependency, manifest, lockfile or generated-bundle changes.

@tylerbishopdev
tylerbishopdev deleted the fix/agent-plugins-scoped-discovery branch November 9, 2026 22:05
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.

1 participant