<?php
namespace boru\ai\Mcp;

class ClientBackedMcpToolDiscovery implements McpToolDiscoveryInterface
{
    /** @var McpClientFactoryInterface */
    protected $clientFactory;

    public function __construct(McpClientFactoryInterface $clientFactory)
    {
        $this->clientFactory = $clientFactory;
    }

    public function discover(McpServerConfig $serverConfig)
    {
        $client = $this->clientFactory->makeClient($serverConfig);
        $client->initialize($serverConfig);

        return $client->listTools();
    }
}
