Server initialize response update to last spec (add title, description) (#1634)
This commit is contained in:
parent
f397783c39
commit
3863f203e9
2 changed files with 73 additions and 1 deletions
|
|
@ -20,6 +20,7 @@ from mcp.types import (
|
|||
BlobResourceContents,
|
||||
ContentBlock,
|
||||
EmbeddedResource,
|
||||
Icon,
|
||||
ImageContent,
|
||||
TextContent,
|
||||
TextResourceContents,
|
||||
|
|
@ -29,9 +30,23 @@ from mcp.types import (
|
|||
class TestServer:
|
||||
@pytest.mark.anyio
|
||||
async def test_create_server(self):
|
||||
mcp = FastMCP(instructions="Server instructions")
|
||||
mcp = FastMCP(
|
||||
title="FastMCP Server",
|
||||
description="Server description",
|
||||
instructions="Server instructions",
|
||||
website_url="https://example.com/mcp_server",
|
||||
version="1.0",
|
||||
icons=[Icon(src="https://example.com/icon.png", mimeType="image/png", sizes=["48x48", "96x96"])],
|
||||
)
|
||||
assert mcp.name == "FastMCP"
|
||||
assert mcp.title == "FastMCP Server"
|
||||
assert mcp.description == "Server description"
|
||||
assert mcp.instructions == "Server instructions"
|
||||
assert mcp.website_url == "https://example.com/mcp_server"
|
||||
assert mcp.version == "1.0"
|
||||
assert isinstance(mcp.icons, list)
|
||||
assert len(mcp.icons) == 1
|
||||
assert mcp.icons[0].src == "https://example.com/icon.png"
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_normalize_path(self):
|
||||
|
|
|
|||
|
|
@ -10,6 +10,29 @@ from mcp.shared.metadata_utils import get_display_name
|
|||
from mcp.types import Prompt, Resource, ResourceTemplate, Tool, ToolAnnotations
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_server_name_title_description_version():
|
||||
"""Test that server title and description are set and retrievable correctly."""
|
||||
mcp = FastMCP(
|
||||
name="TestServer",
|
||||
title="Test Server Title",
|
||||
description="This is a test server description.",
|
||||
version="1.0",
|
||||
)
|
||||
|
||||
assert mcp.title == "Test Server Title"
|
||||
assert mcp.description == "This is a test server description."
|
||||
assert mcp.version == "1.0"
|
||||
|
||||
# Start server and connect client
|
||||
async with create_connected_server_and_client_session(mcp._mcp_server) as client:
|
||||
init_result = await client.initialize()
|
||||
assert init_result.serverInfo.name == "TestServer"
|
||||
assert init_result.serverInfo.title == "Test Server Title"
|
||||
assert init_result.serverInfo.description == "This is a test server description."
|
||||
assert init_result.serverInfo.version == "1.0"
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_tool_title_precedence():
|
||||
"""Test that tool title precedence works correctly: title > annotations.title > name."""
|
||||
|
|
|
|||
Loading…
Reference in a new issue