Files
wehub-resource-sync 60e0ffc959
Upgrade checks / Notify on failure (push) Has been cancelled
Upgrade checks / Close issue on success (push) Has been cancelled
Schema Crash Test / Real-world schema crash test (232K schemas) (push) Has been cancelled
Run static analysis / static_analysis (push) Has been cancelled
Tests / Tests: Python 3.10 on ubuntu-latest (push) Has been cancelled
Tests / Tests: Python 3.13 on ubuntu-latest (push) Has been cancelled
Tests / Tests: Python 3.10 on windows-latest (push) Has been cancelled
Tests / Tests with lowest-direct dependencies (push) Has been cancelled
Tests / MCP conformance tests (push) Has been cancelled
Tests / Integration tests (push) Has been cancelled
Tests / Package install smoke (push) Has been cancelled
Upgrade checks / Static analysis (push) Has been cancelled
Upgrade checks / Tests: Python 3.10 on ubuntu-latest (push) Has been cancelled
Upgrade checks / Tests: Python 3.13 on ubuntu-latest (push) Has been cancelled
Upgrade checks / Tests: Python 3.10 on windows-latest (push) Has been cancelled
Upgrade checks / Integration tests (push) Has been cancelled
Update MCPServerConfig Schema / update-config-schema (push) Has been cancelled
Update SDK Documentation / update-sdk-docs (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:39:59 +08:00

65 lines
1.4 KiB
Python

"""Minimal example demonstrating a @app=True tool with arguments.
Usage:
uv run python greet_server.py
"""
from __future__ import annotations
from typing import Literal
from prefab_ui.components import Badge, Column, Heading, Muted
from fastmcp import FastMCP
mcp = FastMCP("Greeter")
GREETINGS: dict[str, str] = {
"English": "Hello",
"Spanish": "¡Hola",
"French": "Bonjour",
"Japanese": "こんにちは",
"Arabic": "مرحبا",
}
@mcp.tool(app=True)
def greet(
name: str,
language: Literal["English", "Spanish", "French", "Japanese", "Arabic"] = "English",
) -> Column:
"""Greet someone in their language."""
word = GREETINGS[language]
with Column(gap=3, css_class="p-8") as view:
Heading(f"{word}, {name}!")
Muted("Greeting rendered by FastMCP")
Badge(language)
return view
FAREWELLS: dict[str, str] = {
"English": "Goodbye",
"Spanish": "Adiós",
"French": "Au revoir",
"Japanese": "さようなら",
"Arabic": "مع السلامة",
}
@mcp.tool(app=True)
def farewell(
name: str,
language: Literal["English", "Spanish", "French", "Japanese", "Arabic"] = "English",
) -> Column:
"""Say farewell in their language."""
word = FAREWELLS[language]
with Column(gap=3, css_class="p-8") as view:
Heading(f"{word}, {name}!")
Muted("Farewell rendered by FastMCP")
Badge(language)
return view
if __name__ == "__main__":
mcp.run()