Skip to content

Commit 73a69bb

Browse files
committed
fix type issues
1 parent 2e78bff commit 73a69bb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/mcp/server/fastmcp/resources/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import Any
77

88
import anyio
9+
import anyio.to_thread
910
import httpx
1011
import pydantic.json
1112
import pydantic_core

tests/test_examples.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from mcp.shared.memory import (
66
create_connected_server_and_client_session as client_session,
77
)
8+
from mcp.types import TextContent
89

910

1011
@pytest.mark.anyio
@@ -16,6 +17,7 @@ async def test_simple_echo():
1617
result = await client.call_tool("echo", {"text": "hello"})
1718
assert len(result.content) == 1
1819
content = result.content[0]
20+
assert isinstance(content, TextContent)
1921
assert content.text == "hello"
2022

2123

@@ -30,6 +32,9 @@ async def test_complex_inputs():
3032
"name_shrimp", {"tank": tank, "extra_names": ["charlie"]}
3133
)
3234
assert len(result.content) == 3
35+
assert isinstance(result.content[0], TextContent)
36+
assert isinstance(result.content[1], TextContent)
37+
assert isinstance(result.content[2], TextContent)
3338
assert result.content[0].text == "bob"
3439
assert result.content[1].text == "alice"
3540
assert result.content[2].text == "charlie"
@@ -38,17 +43,21 @@ async def test_complex_inputs():
3843
@pytest.mark.anyio
3944
async def test_desktop():
4045
"""Test the desktop server"""
46+
from pydantic import AnyUrl
47+
4148
from examples.fastmcp.desktop import mcp
4249

4350
async with client_session(mcp._mcp_server) as client:
4451
# Test the add function
4552
result = await client.call_tool("add", {"a": 1, "b": 2})
4653
assert len(result.content) == 1
4754
content = result.content[0]
55+
assert isinstance(content, TextContent)
4856
assert content.text == "3"
4957

5058
# Test the desktop resource
51-
result = await client.read_resource("dir://desktop")
59+
result = await client.read_resource(AnyUrl("dir://desktop"))
5260
assert len(result.contents) == 1
5361
content = result.contents[0]
62+
assert isinstance(content, TextContent)
5463
assert isinstance(content.text, str)

0 commit comments

Comments
 (0)