mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 15:19:10 +02:00
* Add FastMCPApp — a Provider for composable MCP applications * Wire Prefab callable resolver via to_json(tool_resolver=) parameter * Remove inspect.signature compat check, use try/except until prefab 0.10.0 * Address review: fix add_tool registry gaps, normalize auth errors, bump prefab to 0.10.0 * Register global key after _add_component succeeds * Simplify: extract decorator dispatch, use get_fastmcp_meta, expose get_global_tool * Remove prek from Marvin workflows These workflows run Claude to respond to /marvin mentions — linting the repo is unnecessary and fails without renderer deps installed. * Return ResolvedTool from callable resolver, add contacts example The callable resolver now returns ResolvedTool (from prefab_ui) instead of a plain string, carrying metadata like unwrap_result that the renderer needs to correctly handle structuredContent envelopes. The unwrap_result flag is derived from the tool's x-fastmcp-wrap-result output schema marker. * Bump prefab-ui requirement to >=0.11.0 * Remove stale ty ignore comments now that prefab-ui 0.11 is published * Add fastmcp dev apps command with browser UI preview * Improve fastmcp dev apps: dropdown picker, reload flag, process cleanup - Replace Tabs with Pages+Select for tool picker (Rx-based reactive state) - Add --reload/--no-reload flag (default: True) to fastmcp dev apps - Kill entire process group on shutdown so port 8000 is freed properly - Suppress uvicorn websockets deprecation warning (websockets-sansio) - Bump prefab-ui to >=0.11.1 (fixes get_renderer_head bug in 0.11.0) - Add farewell tool to greet_server example for multi-tool testing * Add docs for fastmcp dev apps command * Fix orphaned server on startup failure, guard Unix-only signal handling * Show tool title in picker, remove editable prefab source * Bump prefab-ui to >=0.11.2 * Fail fast when prefab-ui is not installed * Add apps/development docs, link from prefab and sidebar * Fix optional field defaults, fail with non-zero on startup timeout
64 lines
1.4 KiB
Python
64 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()
|