> ## Documentation Index
> Fetch the complete documentation index at: https://gofastmcp.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# form

# `fastmcp.apps.form`

FormInput — a Provider that collects structured input from the user.

Define a Pydantic model for the data you need, and `FormInput`
generates a form UI. The user fills it out, the submission is
validated, and an optional callback processes the result.

Requires `fastmcp[apps]` (prefab-ui).

Usage::

from pydantic import BaseModel
from fastmcp import FastMCP
from fastmcp.apps.form import FormInput

class ShippingAddress(BaseModel):
street: str
city: str
state: str
zip\_code: str

mcp = FastMCP("My Server")
mcp.add\_provider(FormInput(model=ShippingAddress))

## Classes

### `FormInput` <sup>[https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp\_slim/fastmcp/apps/form.py#L88](https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/form.py#L88)</sup>

A Provider that collects structured input via a Pydantic model.

Define a model for the data you need, and `FormInput` generates
a form from it using `Form.from_model()`. Field types, labels,
descriptions, and validation are all derived from the model.

Optionally provide an `on_submit` callback to process the
validated data. The callback receives a model instance and returns
a string that goes back to the LLM. Without a callback, the
validated JSON is sent directly.

Example::

from pydantic import BaseModel
from fastmcp import FastMCP
from fastmcp.apps.form import FormInput

class Contact(BaseModel):
name: str
email: str

mcp = FastMCP("My Server")
mcp.add\_provider(FormInput(model=Contact))

With a callback::

def save\_contact(contact: Contact) -> str:
db.insert(contact.model\_dump())
return f"Saved {contact.name}"

mcp.add\_provider(FormInput(model=Contact, on\_submit=save\_contact))


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.