<?php

namespace App\AI\Tools;

use App\AI\Mcp\Client;

/**
 * One tool exposed by an MCP server, presented to the agent exactly like a
 * local Tool. The agent loop cannot tell the difference.
 */
class McpTool implements Tool
{
    public function __construct(
        protected Client $client,
        protected string $name,
        protected string $description,
        protected array $inputSchema,
    ) {}

    public function definition(): array
    {
        return [
            'type' => 'function',
            'name' => $this->name,
            'description' => $this->description,
            // MCP schemas are not written for strict mode, so it stays off.
            'parameters' => $this->inputSchema,
        ];
    }

    public function use(array $arguments): string
    {
        return $this->client->call($this->name, $arguments);
    }
}
