Skip to content

Commit 43796bf

Browse files
committed
test: Add test for non-ASCII character handling in FastMCP tools
1 parent d93b99e commit 43796bf

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/server/fastmcp/test_server.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,29 @@ async def test_create_server(self):
3030
mcp = FastMCP()
3131
assert mcp.name == "FastMCP"
3232

33+
@pytest.mark.anyio
34+
async def test_non_ascii_description(self):
35+
"""Test that FastMCP handles non-ASCII characters in descriptions correctly"""
36+
mcp = FastMCP()
37+
38+
@mcp.tool(description="🌟 This tool uses emojis and UTF-8 characters: á é í ó ú ñ 漢字 🎉")
39+
def hello_world(name: str = "世界") -> str:
40+
return f"¡Hola, {name}! 👋"
41+
42+
async with client_session(mcp._mcp_server) as client:
43+
tools = await client.list_tools()
44+
assert len(tools.tools) == 1
45+
tool = tools.tools[0]
46+
assert "🌟" in tool.description
47+
assert "漢字" in tool.description
48+
assert "🎉" in tool.description
49+
50+
result = await client.call_tool("hello_world", {})
51+
assert len(result.content) == 1
52+
content = result.content[0]
53+
assert isinstance(content, TextContent)
54+
assert "¡Hola, 世界! 👋" == content.text
55+
3356
@pytest.mark.anyio
3457
async def test_add_tool_decorator(self):
3558
mcp = FastMCP()

0 commit comments

Comments
 (0)