Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

Remove duplicate tests

Jeremiah Lowind24d35639f4b
diff --git a/tests/server/test_server_interactions.py b/tests/server/test_server_interactions.py
index 48ee60234..75290edf1 100644
--- a/tests/server/test_server_interactions.py
+++ b/tests/server/test_server_interactions.py
@@ -129,104 +129,6 @@ class TestTools:
result = await client.call_tool("list_tool", {})
assert result[0].text == '[\n "x",\n 2\n]' # type: ignore[attr-defined]
- async def test_image(self, tmp_path: Path):
- mcp = FastMCP()
-
- @mcp.tool
- def image_tool(path: str) -> Image:
- return Image(path)
-
- # Create a test image
- image_path = tmp_path / "test.png"
- image_path.write_bytes(b"fake png data")
-
- async with Client(mcp) as client:
- result = await client.call_tool("image_tool", {"path": str(image_path)})
- content = result[0]
- assert isinstance(content, ImageContent)
- assert content.type == "image"
- assert content.mimeType == "image/png"
- # Verify base64 encoding
- decoded = base64.b64decode(content.data)
- assert decoded == b"fake png data"
-
- async def test_audio(self, tmp_path: Path):
- mcp = FastMCP()
-
- @mcp.tool
- def audio_tool(path: str) -> Audio:
- return Audio(path)
-
- # Create a test audio file
- audio_path = tmp_path / "test.wav"
- audio_path.write_bytes(b"fake wav data")
-
- async with Client(mcp) as client:
- result = await client.call_tool("audio_tool", {"path": str(audio_path)})
- content = result[0]
- assert isinstance(content, AudioContent)
- assert content.type == "audio"
- assert content.mimeType == "audio/wav"
- # Verify base64 encoding
- decoded = base64.b64decode(content.data)
- assert decoded == b"fake wav data"
-
- async def test_tool_mixed_list_with_image(
- self, tool_server: FastMCP, tmp_path: Path
- ):
- """Test that lists containing Image objects and other types are handled
- correctly. Note that the non-MCP content will be grouped together."""
- # Create a test image
- image_path = tmp_path / "test.png"
- image_path.write_bytes(b"test image data")
-
- async with Client(tool_server) as client:
- result = await client.call_tool(
- "mixed_list_fn", {"image_path": str(image_path)}
- )
- assert len(result) == 3
- # Check text conversion
- content1 = result[0]
- assert isinstance(content1, TextContent)
- assert json.loads(content1.text) == ["text message", {"key": "value"}]
- # Check image conversion
- content2 = result[1]
- assert isinstance(content2, ImageContent)
- assert content2.mimeType == "image/png"
- assert base64.b64decode(content2.data) == b"test image data"
- # Check direct TextContent
- content3 = result[2]
- assert isinstance(content3, TextContent)
- assert content3.text == "direct content"
-
- async def test_tool_mixed_list_with_audio(
- self, tool_server: FastMCP, tmp_path: Path
- ):
- """Test that lists containing Audio objects and other types are handled
- correctly. Note that the non-MCP content will be grouped together."""
- # Create a test audio file
- audio_path = tmp_path / "test.wav"
- audio_path.write_bytes(b"test audio data")
-
- async with Client(tool_server) as client:
- result = await client.call_tool(
- "mixed_audio_list_fn", {"audio_path": str(audio_path)}
- )
- assert len(result) == 3
- # Check text conversion
- content1 = result[0]
- assert isinstance(content1, TextContent)
- assert json.loads(content1.text) == ["text message", {"key": "value"}]
- # Check audio conversion
- content2 = result[1]
- assert isinstance(content2, AudioContent)
- assert content2.mimeType == "audio/wav"
- assert base64.b64decode(content2.data) == b"test audio data"
- # Check direct TextContent
- content3 = result[2]
- assert isinstance(content3, TextContent)
- assert content3.text == "direct content"
-
class TestToolTags:
def create_server(self, include_tags=None, exclude_tags=None):