"""Tests that the FastMCP server registers the expected tools."""

import asyncio

from django.test import TestCase

from mcp_server.server import mcp


EXPECTED_TOOLS = {
    "search",
    "get_chunk",
    "list_libraries",
    "list_collections",
    "list_items",
    "get_health",
}


class ServerRegistrationTest(TestCase):
    def test_expected_tools_registered(self):
        tools = asyncio.run(mcp.get_tools())
        self.assertEqual(EXPECTED_TOOLS, set(tools.keys()))

    def test_tool_descriptions_within_limit(self):
        tools = asyncio.run(mcp.get_tools())
        for name, tool in tools.items():
            description = tool.description or ""
            self.assertLessEqual(
                len(description), 1024,
                f"Tool '{name}' description exceeds 1024 chars (MCP spec limit).",
            )
