Skip to content

Add dynamic client support (PIDs, via tuples, global tuples) - #19

Merged
montebrown merged 1 commit into
mainfrom
feature/dynamic-client-support
Jan 25, 2026
Merged

montebrown merged 1 commit into
mainfrom
feature/dynamic-client-support

Conversation

@montebrown

Copy link
Copy Markdown
Owner

Enable MCP adapters to work with dynamically started clients instead of only module names. This unlocks per-job client patterns needed for scenarios like Playwright browser automation where each job requires an isolated browser context to prevent race conditions between concurrent jobs.

Why this matters:

  • Shared MCP clients cause race conditions.
  • Single persistent connections defeat load balancer distribution.
  • Per-job clients enable true horizontal scaling across server pools.
  • Memory stays bounded (contexts cleaned up when jobs complete).

Changes:

  • Config: Accept PIDs (with alive check), {:via, Registry, _}, {:global, _}
  • ToolExecutor: Dispatch based on client type, resolve supervisor PIDs to Anubis.Client.Base automatically
  • TestSupport: Use apply/3 for Mimic calls to avoid compile-time dep
  • README: Document "Client Types" and "Dynamic Clients" sections

Example usage: {:ok, client_pid} = MyApp.MCPClient.start_link(opts) :ok = Adapter.wait_for_server_ready(client_pid) adapter = Adapter.new(client: client_pid)
#... use adapter ...
Supervisor.stop(client_pid)

Enable MCP adapters to work with dynamically started clients instead of
only module names. This unlocks per-job client patterns needed for
scenarios like Playwright browser automation where each job requires an
isolated browser context to prevent race conditions between concurrent
jobs.

Why this matters:
- Shared MCP clients cause race conditions.
- Single persistent connections defeat load balancer distribution.
- Per-job clients enable true horizontal scaling across server pools.
- Memory stays bounded (contexts cleaned up when jobs complete).

Changes:
- Config: Accept PIDs (with alive check), {:via, Registry, _}, {:global,
  _}
- ToolExecutor: Dispatch based on client type, resolve supervisor PIDs
  to Anubis.Client.Base automatically
- TestSupport: Use apply/3 for Mimic calls to avoid compile-time dep
- README: Document "Client Types" and "Dynamic Clients" sections

Example usage: {:ok, client_pid} = MyApp.MCPClient.start_link(opts) :ok
= Adapter.wait_for_server_ready(client_pid) adapter =
Adapter.new(client: client_pid)
  #... use adapter ...
  Supervisor.stop(client_pid)
@montebrown
montebrown force-pushed the feature/dynamic-client-support branch from 3c03104 to f8fc317 Compare January 25, 2026 19:09
@montebrown
montebrown merged commit 25798ec into main Jan 25, 2026
2 checks passed
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