Rename FastMCP to MCPServer (#1951)
This commit is contained in:
parent
4a2d83a0cb
commit
65c614e48e
1 changed files with 713 additions and 693 deletions
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for lifespan functionality in both low-level and FastMCP servers."""
|
||||
"""Tests for lifespan functionality in both low-level and MCPServer servers."""
|
||||
|
||||
from collections.abc import AsyncIterator
|
||||
from contextlib import asynccontextmanager
|
||||
|
|
@ -8,8 +8,8 @@ import anyio
|
|||
import pytest
|
||||
from pydantic import TypeAdapter
|
||||
|
||||
from mcp.server.fastmcp import Context, FastMCP
|
||||
from mcp.server.lowlevel.server import NotificationOptions, Server
|
||||
from mcp.server.mcpserver import Context, MCPServer
|
||||
from mcp.server.models import InitializationOptions
|
||||
from mcp.server.session import ServerSession
|
||||
from mcp.shared.message import SessionMessage
|
||||
|
|
@ -120,11 +120,11 @@ async def test_lowlevel_server_lifespan():
|
|||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_fastmcp_server_lifespan():
|
||||
"""Test that lifespan works in FastMCP server."""
|
||||
async def test_mcpserver_server_lifespan():
|
||||
"""Test that lifespan works in MCPServer server."""
|
||||
|
||||
@asynccontextmanager
|
||||
async def test_lifespan(server: FastMCP) -> AsyncIterator[dict[str, bool]]:
|
||||
async def test_lifespan(server: MCPServer) -> AsyncIterator[dict[str, bool]]:
|
||||
"""Test lifespan context that tracks startup/shutdown."""
|
||||
context = {"started": False, "shutdown": False}
|
||||
try:
|
||||
|
|
@ -133,7 +133,7 @@ async def test_fastmcp_server_lifespan():
|
|||
finally:
|
||||
context["shutdown"] = True
|
||||
|
||||
server = FastMCP("test", lifespan=test_lifespan)
|
||||
server = MCPServer("test", lifespan=test_lifespan)
|
||||
|
||||
# Create memory streams for testing
|
||||
send_stream1, receive_stream1 = anyio.create_memory_object_stream[SessionMessage](100)
|
||||
|
|
@ -152,10 +152,10 @@ async def test_fastmcp_server_lifespan():
|
|||
async with anyio.create_task_group() as tg, send_stream1, receive_stream1, send_stream2, receive_stream2:
|
||||
|
||||
async def run_server():
|
||||
await server._mcp_server.run(
|
||||
await server._lowlevel_server.run(
|
||||
receive_stream1,
|
||||
send_stream2,
|
||||
server._mcp_server.create_initialization_options(),
|
||||
server._lowlevel_server.create_initialization_options(),
|
||||
raise_exceptions=True,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue