#!/usr/bin/env python3
# File: tests/unit/mcp/test_fastmcp.py
# Purpose: Validate FastMCP stub registration mechanics for tool handlers.
# Context: Ensures decorators capture metadata required by integration tests.

from __future__ import annotations

from mcp.server.fastmcp import FastMCP, RegisteredTool


def test_tool_registration_preserves_handler_and_description() -> None:
    """Decorated functions are stored with metadata accessible via _tools."""

    server = FastMCP(name="stub", instructions="test")

    @server.tool(name="sample", description="説明テキスト")
    def handler(value: int) -> int:
        return value * 2

    assert "sample" in server._tools

    tool_entry = server._tools["sample"]
    assert isinstance(tool_entry, RegisteredTool)
    assert tool_entry.description == "説明テキスト"
    assert tool_entry.fn(3) == 6
