Skip to content

Conversation

Copy link

Copilot AI commented Nov 7, 2025

Every connect() call was creating a new transporter instance, causing redundant HTTP client instantiation, session handshakes, and process spawning. This resulted in significant latency overhead for subsequent requests to the same server.

Changes

  • TransporterPool (src/Core/TransporterPool.php): Maintains singleton registry of transporters keyed by server name. Provides get(), forget(), clear(), and getActiveServers() methods.

  • MCPClient (src/MCPClient.php): Constructor now accepts TransporterPool instead of TransporterFactory. The connect() method passes server name to pool for lookup/creation.

  • MCPClientServiceProvider (src/MCPClientServiceProvider.php): Registers TransporterPool as singleton to ensure all MCPClient instances share the same pool.

  • Tests: Added integration tests for pool behavior. Updated existing MCPClient tests to mock pool instead of factory.

Usage

No code changes required. Subsequent connections automatically reuse transporters:

$client = app(MCPClient::class);

$client->connect('github')->tools();      // Creates transporter
$client->connect('github')->resources();  // Reuses transporter (50-80% faster)

// Force reconnection if needed
app(TransporterPool::class)->forget('github');

Impact

  • 50-80% latency reduction for subsequent requests to same server
  • Single HTTP client instance per server
  • No repeated session handshakes
  • No redundant process spawning for STDIO transporters

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/CarbonPHP/carbon-doctrine-types/zipball/18ba5ddfec8976260ead6e866180bd5d2f71aa1d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/CarbonPHP/carbon/zipball/8e3643dcd149ae0fe1d2ff4f2c8e4bbfad7c165f
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/FakerPHP/Faker/zipball/e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/3ba905c11371512af9d9bdd27d99b782216b6945
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/PHP-DI/Invoker/zipball/3c1ddfdef181431fbc4be83378f6d036d59e81e1
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/PHP-DI/PHP-DI/zipball/f88054cc052e40dbe7b383c8817c19442d480352
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/Seldaek/monolog/zipball/10d85740180ecba7896c87e06a166e0c95a0e3b6
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/dflydev/dflydev-dot-access-data/zipball/a23a2bf4f31d3518f3ecb38660c95715dfead60f
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/doctrine/deprecations/zipball/459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/doctrine/inflector/zipball/6d6c96277ea252fc1304627204c3d5e6e15faa3b
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/doctrine/lexer/zipball/31ad66abc0fc9e1a1f2d9bc6a42668d2fbbcd6dd
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/dragonmantank/cron-expression/zipball/d61a8a9604ec1f8c3d150d09db6ce98b32675013
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/egulias/EmailValidator/zipball/d42c8731f0624ad6bdc8d3e5e9a4524f68801cfa
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/filp/whoops/zipball/d2102955e48b9fd9ab24280a7ad12ed552752c4d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/fruitcake/php-cors/zipball/3d158f36e7875e2f040f37bc0573956240a5a38b
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/guzzle/guzzle/zipball/b51ac707cfa420b7bfd4e4d5e510ba8008e822b4
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/guzzle/promises/zipball/481557b130ef3790cf82b713667b43030dc9c957
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/guzzle/psr7/zipball/21dc724a0583619cd1652f673303492272778051
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/guzzle/uri-template/zipball/4f4bbd4e7172148801e76e3decc1e559bdee34e1
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/hamcrest/hamcrest-php/zipball/f8b1c0173b22fa6ec77a81fe63e5b01eba7e6487
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/iamcal/SQLParser/zipball/947083e2dca211a6f12fb1beb67a01e387de9b62
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/larastan/larastan/zipball/d13ef96d652d1b2a8f34f1760ba6bf5b9c98112e
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/laravel/framework/zipball/3c3c4ad30f5b528b164a7c09aa4ad03118c4c125
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/laravel/pail/zipball/8cc3d575c1f0e57eeb923f366a37528c50d2385a
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/laravel/pint/zipball/5016e263f95d97670d71b9a987bd8996ade6d8d9
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/laravel/prompts/zipball/a1891d362714bc40c8d23b0b1d7090f022ea27cc
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/laravel/serializable-closure/zipball/038ce42edee619599a1debb7e81d7b3759492819
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/mockery/mockery/zipball/1f4efdd7d3beafe9807b08156dfcb176d18f1699
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/nette/schema/zipball/2befc2f42d7c715fd9d95efc31b1081e5d765004
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/nette/utils/zipball/c930ca4e3cf4f17dcfb03037703679d2396d2ede
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/nunomaduro/termwind/zipball/eb61920a53057a7debd718a5b89c2178032b52c0
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/orchestral/sidekick/zipball/371ce2882ee3f5bf826b36e75d461e51c9cd76c2
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/orchestral/testbench/zipball/87a7cb58edcfea9b1f26a63761c4d7ed5448f560
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/orchestral/workbench/zipball/4e8a5a68200971ddb9ce4abf26488838bf5c0812
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/pestphp/pest-plugin-arch/zipball/db7bd9cb1612b223e16618d85475c6f63b9c8daa
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/pestphp/pest-plugin-laravel/zipball/6801be82fd92b96e82dd72e563e5674b1ce365fc
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/pestphp/pest-plugin-mutate/zipball/e10dbdc98c9e2f3890095b4fe2144f63a5717e08
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/pestphp/pest-plugin/zipball/e79b26c65bc11c41093b10150c1341cc5cdbea83
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/pestphp/pest/zipball/72cf695554420e21858cda831d5db193db102574
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/php-fig/clock/zipball/e41a24703d4560fd0acb709162f73b8adfc3aa0d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94f8051919d1b0369a6bcc7931d679a511c03fe9
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/679e3ce485b99e84c775d28e2e96fade9a7fb50a
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/phpstan/phpdoc-parser/zipball/1e0cd5370df5dd2e556a36b9c62f62e555870495
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/468e02c9176891cc901143da118f09dc9505fc2f
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/9a9b161baee88a5f5c58d816943cff354ff233dc
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/phpstan/phpstan/zipball/ead89849d879fe203ce9292c6ef5e7e76f867b96
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/ramsey/collection/zipball/344572933ad0181accbf4ba763e85a0306a8c5e2
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/ramsey/uuid/zipball/81f941f6f729b1e3ceea61d9d014f8b6c6800440
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/schmittjoh/php-option/zipball/638a154f8d4ee6a5cfa96d6a34dfbe0cffa9566d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/diff/zipball/b4ccd857127db5d41a5b676f24b51371d76d8544
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/environment/zipball/a5c75038693ad2e8d4b6c15ba2403532647830c4
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/exporter/zipball/70a298763b40b213ec087c51c739efcaa90bcd74
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/global-state/zipball/3be331570a721f9a4b5917f4209773de17f747d7
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/f5b498e631a74204185071eb41f33f38d64608aa
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/6e1a43b411b2ad34146dee7524cb13a068bb35f9
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/f6458abbf32a6c8174f8f26261475dc133b3d9dc
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/f77d2d4e78738c98d9a68d2596fe5e8fa380f449
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/c687e3387b99f5b03b6caa64c74b63e2936ff874
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/spatie/backtrace/zipball/8c0f16a59ae35ec8c62d85c3c17585158f430110
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/spatie/laravel-package-tools/zipball/f09a799850b1ed765103a4f0b4355006360c49a5
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/spatie/laravel-ray/zipball/7b9cfdb024a390171397c14dbf321727d940bac5
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/spatie/macroable/zipball/ec2c320f932e730607aff8052c44183cf3ecb072
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/spatie/ray/zipball/2104ba5fb20cceda04aaa72dc7a4786a89c67cb4
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/staabm/side-effects-detector/zipball/d8334211a140ce329c13726d4a715adbddd0a163
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/clock/zipball/b81435fbd6648ea425d1ee96a2d8e68f4ceacd24
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/console/zipball/c28ad91448f86c5f6d9d2c70f0cf68bf135f252a
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/css-selector/zipball/84321188c4754e64273b46b406081ad9b18e8614
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/error-handler/zipball/bbe40bfab84323d99dab491b716ff142410a92a8
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/59eb412e93815df44f05f342958efa9f46b1e586
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/event-dispatcher/zipball/b7dc69e71de420ac04bc9ab830cf3ffebba48191
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/finder/zipball/9f696d2f1e340484b4683f7853b273abff94421f
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/http-foundation/zipball/6379e490d6ecfc5c4224ff3a754b90495ecd135c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/http-kernel/zipball/f9a34dc0196677250e3609c2fac9de9e1551a262
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/mailer/zipball/fd497c45ba9c10c37864e19466b090dcb60a50ba
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/mime/zipball/b1b828f69cbaf887fa835a091869e55df91d0e35
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/polyfill-iconv/zipball/5f3b930437ae03ae5dff61269024d8ea1b3774aa
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/380872130d3a5dd3ace2f4010d95125fde5d5c70
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/9614ac4d8061dc257ecc64cba1b140873dce8ad3
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/polyfill-php83/zipball/17f6f9a6b1735c0f163024d959f700cfbc5155e5
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/polyfill-php84/zipball/d8ced4d875142b6a7426000426b8abc631d6b191
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/polyfill-php85/zipball/d4e5fcd4ab3d998ab16c0db48e6cbb9a01993f91
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/polyfill-uuid/zipball/21533be36c24be3f4b1669c4725c7d1d2bab4ae2
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/process/zipball/f24f8f316367b30810810d4eb30c543d7003ff3b
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/routing/zipball/c97abe725f2a1a858deca629a6488c8fc20c3091
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/service-contracts/zipball/f021b05a130d35510bd6b25fe9053c2a8a15d5d4
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/stopwatch/zipball/5a49289e2b308214c8b9c2fda4ea454d8b8ad7cd
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/string/zipball/f96476035142921000338bad71e5247fbc138872
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/translation-contracts/zipball/df210c7a2573f1913b2d17cc95f90f53a73d8f7d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/translation/zipball/ec25870502d0c7072d086e8ffba1420c85965174
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/uid/zipball/a69f69f3159b852651a6bf45a9fdd149520525bb
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/symfony/var-dumper/zipball/476c4ae17f43a9a36650c69879dcf5b1e6ae724d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/ta-tikoma/phpunit-architecture-test/zipball/cf6fb197b676ba716837c886baca842e4db29005
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/thephpleague/commonmark/zipball/10732241927d3971d28e7ea7b5712721fa2296ca
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/thephpleague/config/zipball/754b3604fb2984c71f4af4a9cbe7b57f346ec1f3
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/thephpleague/flysystem-local/zipball/6691915f77c7fb69adfb87dcd550052dc184ee10
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/thephpleague/flysystem/zipball/c139fd65c1f796b926f4aec0df37f6caa959a8da
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/thephpleague/mime-type-detection/zipball/2d6702ff215bf922936ccc1ad31007edc76451b9
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/thephpleague/uri-interfaces/zipball/08cfc6c4f3d811584fb09c37e2849e6a7f9b0742
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/thephpleague/uri/zipball/81fb5145d2644324614cc532b28efd0215bda430
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/0d72ac1c00084279c1816675284073c5a337c20d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/vlucas/phpdotenv/zipball/24ac4c74f91ee2c193fa1aaa5c249cb0822809af
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/voku/portable-ascii/zipball/b1d923f88091c6bf09699efcd7c8a1b1bfd7351d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/webmozarts/assert/zipball/9be6926d8b485f55b9229203f962b51ed377ba68
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/zbateson/mail-mime-parser/zipball/f0ccec9290a5b9cf014d7b7ea3401d2a4a626e9a
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/zbateson/mb-wrapper/zipball/50a14c0c9537f978a61cde9fdc192a0267cc9cff
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/zbateson/stream-decorators/zipball/32a2a62fb0f26313395c996ebd658d33c3f9c4e5
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/EFdpg7 /usr/bin/composer install --no-interaction --prefer-dist (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature]: Connection/Transporter Pooling and Reuse</issue_title>
<issue_description>### Summary

Priority: 🔴 HIGH
Impact: 50-80% reduction in latency for subsequent requests
Difficulty: Medium

Testing Checklist

  • TransporterPool correctly stores and retrieves transporters
  • Same transporter instance is returned for same server name
  • forget() method removes specific transporter
  • clear() method removes all transporters
  • MCPClient uses TransporterPool instead of creating new instances
  • All existing MCPClient tests still pass
  • Multiple connects to same server reuse transporter

Expected Outcome

After implementing this:

  • First connect() call: Creates new transporter (same as before)
  • Subsequent connect() calls to same server: Reuses existing transporter (MUCH faster)
  • Users can force reconnection with reconnect() method if needed

Problem

Currently, every time MCPClient::connect() is called, a new transporter instance is created. This means:

  1. For HTTP transporters:

    • A new Guzzle HTTP client is instantiated
    • A new session initialization handshake occurs (extra network round-trip)
    • Memory overhead from multiple client instances
  2. For STDIO transporters:

    • A new process is spawned every time
    • Process startup overhead (even with reduced delays)
    • Initialization handshakes are repeated unnecessarily

Example of Current Inefficiency

// User code that makes multiple requests
$client = app(MCPClient::class);

// First request - creates new transporter, initializes session
$client->connect('github')->tools();

// Second request - creates ANOTHER new transporter, initializes ANOTHER session
$client->connect('github')->resources();

// Third request - yet ANOTHER new transporter and session
$client->connect('github')->callTool('search', ['query' => 'test']);

Each of these creates a brand new transporter instance, even though they're connecting to the same server!

Proposed Solution

Create a TransporterPool class that maintains a singleton registry of active transporters and reuses them.

Implementation Steps

Step 1: Create TransporterPool Class

Create file: src/Core/TransporterPool.php

Step 2: Update MCPClient to Use TransporterPool

Modify src/MCPClient.php:

Step 3: Update Service Provider

Modify src/MCPClientServiceProvider.php:

public function packageBooted(): void
{
    // Register TransporterPool as singleton
    $this->app->singleton(TransporterPool::class, function ($app) {
        return new TransporterPool();
    });

    $this->app->bind(MCPClient::class, function ($app) {
        $servers = $app['config']->get('mcp-client.servers', []);

        return new MCPClient($servers, $app->make(TransporterPool::class));
    });
}

Step 4: Create Tests

Create file: tests/Core/TransporterPoolTest.php

  • creates transporter on first call
  • returns same transporter on subsequent calls
  • forget removes transporter from pool
  • clear removes all transporters
  • getActiveServers returns list of server names

Step 5: Update Existing Tests

Update tests/MCPClient/MCPClientTest.php to use TransporterPool instead of TransporterFactory:

Replace all instances of:

$mockFactory = Mockery::mock(TransporterFactory::class);

With:

$mockPool = Mockery::mock(TransporterPool::class);

And update the expectations from shouldReceive('make') to shouldReceive('get').

Alternatives Considered

No response

Package Version

1

PHP Version

8.4

Laravel Version

12

Notes

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits November 7, 2025 07:48
Co-authored-by: nikajorjika <4212052+nikajorjika@users.noreply.github.com>
Co-authored-by: nikajorjika <4212052+nikajorjika@users.noreply.github.com>
…tory usage

Co-authored-by: nikajorjika <4212052+nikajorjika@users.noreply.github.com>
Copilot AI changed the title [WIP] Add connection and transporter pooling functionality Add connection pooling for MCP transporters Nov 7, 2025
Copilot AI requested a review from nikajorjika November 7, 2025 07:59
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.

[Feature]: Connection/Transporter Pooling and Reuse

2 participants