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
42 lines
975 B
Python
42 lines
975 B
Python
"""Form input — collect structured data from users via Pydantic models.
|
|
|
|
Usage:
|
|
uv run python form_server.py
|
|
"""
|
|
|
|
from typing import Literal
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from fastmcp import FastMCP
|
|
from fastmcp.apps.form import FormInput
|
|
|
|
|
|
class ShippingAddress(BaseModel):
|
|
name: str = Field(description="Full name")
|
|
street: str = Field(description="Street address")
|
|
city: str
|
|
state: str = Field(description="Two-letter state code")
|
|
zip_code: str = Field(description="5-digit ZIP")
|
|
|
|
|
|
class BugReport(BaseModel):
|
|
title: str = Field(description="Brief summary")
|
|
severity: Literal["low", "medium", "high", "critical"]
|
|
description: str = Field(
|
|
description="Detailed description",
|
|
json_schema_extra={"ui": {"type": "textarea"}},
|
|
)
|
|
|
|
|
|
mcp = FastMCP(
|
|
"Form Demo",
|
|
providers=[
|
|
FormInput(model=ShippingAddress),
|
|
FormInput(model=BugReport),
|
|
],
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
mcp.run()
|