<?php

declare(strict_types=1);

namespace Plugin\tnt_mcp\src\Mcp\Tools;

use Plugin\tnt_mcp\src\Mcp\Contracts\Tool;
use Plugin\tnt_mcp\src\Mcp\Mode\EndpointClass;
use Plugin\tnt_mcp\src\Mcp\Support\ShopInfo;

/** READ tool: returns basic shop identity. A thin delegate to {@see ShopInfo}. */
final class GetShopInfo implements Tool
{
    public function __construct(private readonly ShopInfo $shop)
    {
    }

    public function name(): string
    {
        return 'get_shop_info';
    }

    public function description(): string
    {
        return 'Basic shop identity: name, URL, default language and currency.';
    }

    /** @return array<string,mixed> */
    public function inputSchema(): array
    {
        return ['type' => 'object', 'properties' => [], 'additionalProperties' => false];
    }

    public function isWrite(): bool
    {
        return false;
    }

    public function scope(): string
    {
        return 'shop:read';
    }

    /** Read-only — safe in every mode. */
    public function endpointClass(): EndpointClass
    {
        return EndpointClass::Reversible;
    }

    /**
     * @param array<string,mixed> $args
     *
     * @return array<string,mixed>
     */
    public function run(array $args): array
    {
        return [
            'name'     => $this->shop->name(),
            'url'      => $this->shop->url(),
            'language' => $this->shop->defaultLanguageIso(),
            'currency' => $this->shop->defaultCurrencyCode(),
        ];
    }
}
