<?php
namespace boru\ai\Mcp;

class McpServerRegistry
{
    /** @var McpServerConfig[] */
    protected $servers = array();

    public function register(McpServerConfig $server)
    {
        if (!$server->name()) {
            throw new \InvalidArgumentException('MCP server requires a name');
        }

        $this->servers[$server->name()] = $server;
        return $this;
    }

    public function has($name)
    {
        return isset($this->servers[$name]);
    }

    public function get($name)
    {
        if (!$this->has($name)) {
            throw new \InvalidArgumentException('Unknown MCP server: ' . $name);
        }
        return $this->servers[$name];
    }

    public function all()
    {
        return array_values($this->servers);
    }
}
