"""Tests for the MCP server."""
import pytest
from mcp_server_hero.core.server import MCPServerHero
@pytest.fixture
def server():
"""Create a test server instance."""
return MCPServerHero(name="Test Server", debug=True)
def test_server_initialization():
"""Test server initialization."""
server = MCPServerHero(name="Test")
assert server.settings.name == "Test"
assert server.tool_registry is not None
assert server.resource_registry is not None
assert server.prompt_registry is not None
def test_add_tool(server):
"""Test adding a tool to the server."""
async def test_tool(x: int) -> int:
return x * 2
server.add_tool("multiply", test_tool, "Multiply by 2")
assert "multiply" in server.tool_registry._tools
def test_add_resource(server):
"""Test adding a resource to the server."""
async def test_resource() -> str:
return "test data"
server.add_resource("test://data", test_resource, "test", "Test resource")
assert "test://data" in server.resource_registry._resources
def test_add_prompt(server):
"""Test adding a prompt to the server."""
async def test_prompt(topic: str) -> str:
return f"Tell me about {topic}"
server.add_prompt("ask", test_prompt, "Ask about topic")
assert "ask" in server.prompt_registry._prompts