Skip to content

Commit ed99316

Browse files
committed
example: Add FastMCP example with Unicode characters and emojis
1 parent 43796bf commit ed99316

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

examples/fastmcp/unicode_example.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
"""
2+
Example FastMCP server that uses Unicode characters in various places to help test
3+
Unicode handling in tools and inspectors.
4+
"""
5+
6+
from mcp.server.fastmcp import FastMCP
7+
8+
mcp = FastMCP()
9+
10+
11+
@mcp.tool(description="🌟 A tool that uses various Unicode characters in its description: á é í ó ú ñ 漢字 🎉")
12+
def hello_unicode(name: str = "世界", greeting: str = "¡Hola") -> str:
13+
"""
14+
A simple tool that demonstrates Unicode handling in:
15+
- Tool description (emojis, accents, CJK characters)
16+
- Parameter defaults (CJK characters)
17+
- Return values (Spanish punctuation, emojis)
18+
"""
19+
return f"{greeting}, {name}! 👋"
20+
21+
22+
@mcp.tool(description="🎨 Tool that returns a list of emoji categories")
23+
def list_emoji_categories() -> list[str]:
24+
"""Returns a list of emoji categories with emoji examples."""
25+
return [
26+
"😀 Smileys & Emotion",
27+
"👋 People & Body",
28+
"🐶 Animals & Nature",
29+
"🍎 Food & Drink",
30+
"⚽ Activities",
31+
"🌍 Travel & Places",
32+
"💡 Objects",
33+
"❤️ Symbols",
34+
"🚩 Flags"
35+
]
36+
37+
38+
@mcp.tool(description="🔤 Tool that returns text in different scripts")
39+
def multilingual_hello() -> str:
40+
"""Returns hello in different scripts and writing systems."""
41+
return "\n".join([
42+
"English: Hello!",
43+
"Spanish: ¡Hola!",
44+
"French: Bonjour!",
45+
"German: Grüß Gott!",
46+
"Russian: Привет!",
47+
"Greek: Γεια σας!",
48+
"Hebrew: !שָׁלוֹם",
49+
"Arabic: !مرحبا",
50+
"Hindi: नमस्ते!",
51+
"Chinese: 你好!",
52+
"Japanese: こんにちは!",
53+
"Korean: 안녕하세요!",
54+
"Thai: สวัสดี!",
55+
])
56+
57+
58+
if __name__ == "__main__":
59+
mcp.run()

0 commit comments

Comments
 (0)