mirror of
https://github.com/aljazceru/mcp-python-sdk.git
synced 2025-12-19 14:54:24 +01:00
fix type issues
This commit is contained in:
@@ -6,6 +6,7 @@ from pathlib import Path
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import anyio
|
import anyio
|
||||||
|
import anyio.to_thread
|
||||||
import httpx
|
import httpx
|
||||||
import pydantic.json
|
import pydantic.json
|
||||||
import pydantic_core
|
import pydantic_core
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import pytest
|
|||||||
from mcp.shared.memory import (
|
from mcp.shared.memory import (
|
||||||
create_connected_server_and_client_session as client_session,
|
create_connected_server_and_client_session as client_session,
|
||||||
)
|
)
|
||||||
|
from mcp.types import TextContent
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.anyio
|
@pytest.mark.anyio
|
||||||
@@ -16,6 +17,7 @@ async def test_simple_echo():
|
|||||||
result = await client.call_tool("echo", {"text": "hello"})
|
result = await client.call_tool("echo", {"text": "hello"})
|
||||||
assert len(result.content) == 1
|
assert len(result.content) == 1
|
||||||
content = result.content[0]
|
content = result.content[0]
|
||||||
|
assert isinstance(content, TextContent)
|
||||||
assert content.text == "hello"
|
assert content.text == "hello"
|
||||||
|
|
||||||
|
|
||||||
@@ -30,6 +32,9 @@ async def test_complex_inputs():
|
|||||||
"name_shrimp", {"tank": tank, "extra_names": ["charlie"]}
|
"name_shrimp", {"tank": tank, "extra_names": ["charlie"]}
|
||||||
)
|
)
|
||||||
assert len(result.content) == 3
|
assert len(result.content) == 3
|
||||||
|
assert isinstance(result.content[0], TextContent)
|
||||||
|
assert isinstance(result.content[1], TextContent)
|
||||||
|
assert isinstance(result.content[2], TextContent)
|
||||||
assert result.content[0].text == "bob"
|
assert result.content[0].text == "bob"
|
||||||
assert result.content[1].text == "alice"
|
assert result.content[1].text == "alice"
|
||||||
assert result.content[2].text == "charlie"
|
assert result.content[2].text == "charlie"
|
||||||
@@ -38,6 +43,8 @@ async def test_complex_inputs():
|
|||||||
@pytest.mark.anyio
|
@pytest.mark.anyio
|
||||||
async def test_desktop():
|
async def test_desktop():
|
||||||
"""Test the desktop server"""
|
"""Test the desktop server"""
|
||||||
|
from pydantic import AnyUrl
|
||||||
|
|
||||||
from examples.fastmcp.desktop import mcp
|
from examples.fastmcp.desktop import mcp
|
||||||
|
|
||||||
async with client_session(mcp._mcp_server) as client:
|
async with client_session(mcp._mcp_server) as client:
|
||||||
@@ -45,10 +52,12 @@ async def test_desktop():
|
|||||||
result = await client.call_tool("add", {"a": 1, "b": 2})
|
result = await client.call_tool("add", {"a": 1, "b": 2})
|
||||||
assert len(result.content) == 1
|
assert len(result.content) == 1
|
||||||
content = result.content[0]
|
content = result.content[0]
|
||||||
|
assert isinstance(content, TextContent)
|
||||||
assert content.text == "3"
|
assert content.text == "3"
|
||||||
|
|
||||||
# Test the desktop resource
|
# Test the desktop resource
|
||||||
result = await client.read_resource("dir://desktop")
|
result = await client.read_resource(AnyUrl("dir://desktop"))
|
||||||
assert len(result.contents) == 1
|
assert len(result.contents) == 1
|
||||||
content = result.contents[0]
|
content = result.contents[0]
|
||||||
|
assert isinstance(content, TextContent)
|
||||||
assert isinstance(content.text, str)
|
assert isinstance(content.text, str)
|
||||||
|
|||||||
Reference in New Issue
Block a user