Skip to main content

Context

method init

Parameters
RequestContext[ServerSessionT, LifespanContextT, RequestT] | None
default:"None"
Parameter value
FastMCP | None
default:"None"
Parameter value
Any
required
Parameter value
Signature

method get_http_request

Return the underlying Starlette Request when running over HTTP transports.Returns
Request | None
Signature

method list_roots

Request the list of roots from the client.Roots represent directories or files that the client has access to and wants to make available to the server.Example:
Returns
list[Root]
A list of Root objects, each with a ‘uri’ (file:// URI) and optional ‘name’ field.
Signature

method sample

Request a client-side LLM sampling invocation.Parameters
str | SamplingMessage | Sequence[SamplingMessage | str]
required
The sampling prompt(s). Accepts a simple string, a single
int
default:"512"
Maximum number of tokens to request from the client LLM.
str | None
default:"None"
Optional system instructions to prepend.
bool | None
default:"None"
Whether to ask the client to include MCP context.
float | None
default:"None"
Optional sampling temperature.
Sequence[str] | None
default:"None"
Optional stop sequences to pass to the client LLM.
dict[str, Any] | None
default:"None"
Optional provider-specific metadata.
ModelPreferences | None
default:"None"
Optional hint about the desired model.
bool
default:"False"
When True returns the full CreateMessageResult instead of
Returns
CreateMessageResult
Signature

method send_prompt_list_changed

Notify the client that the prompt list changed.Signature

method send_resource_list_changed

Notify the client that the resource list changed.Signature

method send_tool_list_changed

Notify the client that the tool list changed.Signature