Expand description
Runtime and transports for FlyMCPRust.
Most users should depend on the flymcprust facade crate instead.
The core is transport-agnostic: Server turns parsed JSON-RPC messages
into responses and implements tower::Service, while transports only move
bytes. See docs/ARCHITECTURE.md for the design.
Re-exports§
pub use apps::AppUi;pub use apps::Permission;pub use apps::Visibility;pub use auth::Principal;pub use auth::TokenError;pub use auth::TokenVerifier;
Modules§
- apps
- MCP Apps (
io.modelcontextprotocol/ui): tools that render an interactive HTML interface in the host. - auth
- Authorization: the authenticated caller (
Principal), access-token verification (TokenVerifier) and scope checks. - jsonrpc
- JSON-RPC 2.0 envelope parsing and response serialization.
- message
- Builders for prompt messages.
- security
- Helpers for handling untrusted client input safely.
- spec
- Protocol types of the targeted revision.
Protocol types for MCP specification revision
2026-07-28. - testing
- In-process test client (feature
test-client). - transport
- Transports. Each one only moves bytes; all protocol logic lives in
Server.
Structs§
- Auto
Prompt - A prompt registered by
#[prompt]for automatic discovery. - Auto
Resource - A resource registered by
#[resource]for automatic discovery. - Auto
Tool - A tool registered by
#[tool]for automatic discovery. - Completion
- Completion values. Results longer than
MAX_COMPLETION_VALUESare truncated, withtotalandhasMoreset accordingly. - Completion
Request - What the client asked to complete.
- Ctx
- Context of the request being handled. Declare a
Ctxparameter in a tool to receive it; it is excluded from the tool’s input schema. - Json
- Wraps a value returned as structured content. The tool’s
outputSchemais generated fromT, and the result carries bothstructuredContentand the serialized JSON as text, as the specification recommends. - Legacy
Session - What a legacy client declared at
initialize. - Limits
- Resource limits applied to every request.
- McpError
- A JSON-RPC error returned to the client.
- McpRequest
- A parsed message plus transport-provided context.
- Mirrored
Param - A tool parameter mirrored into an
Mcp-Param-{name}header. - Prompt
Arguments - The arguments of a
prompts/getrequest. - Prompt
Def - A registered prompt: its protocol description plus its entry point.
- Resource
Def - A registered resource or resource template.
- Server
- A built MCP server. Cheap to clone; all clones share one registry.
- Server
Builder - Builds a
Server. - State
- Shared application state registered with
ServerBuilder::state. Declare aState<T>parameter in a tool to receive it; it is excluded from the tool’s input schema. A tool that needs a state type that was never registered makesServerBuilder::buildfail. - State
Requirement - A shared-state type a handler needs.
- ToolDef
- A registered tool: its protocol description plus its entry point.
- Tool
Error - An error raised by a tool, resource or prompt handler.
- Transport
Context - Values attached by the transport to a request (for example, authenticated claims or HTTP headers). Tower middleware can populate it before the request reaches the server.
- UriTemplate
- A parsed URI template.
- UriTemplate
Error - A template that cannot be parsed or is not supported.
- UriVars
- Variable values extracted from a URI by
UriTemplate::matches.
Enums§
- Build
Error - Errors detected while building a server.
- Elicitation
- The outcome of an elicitation.
- Error
Kind - How an error relates to the request, independent of transport. HTTP uses it to pick a status code (400, 404, 200 or 500).
- Param
Kind - JSON Schema primitive type of a mirrored parameter.
- Tool
Output - What a tool produced.
Constants§
- LEGACY_
PROTOCOL_ VERSIONS - Legacy protocol versions the server accepts, newest first.
- MAX_
COMPLETION_ VALUES - Maximum number of values in one completion result (specification limit).
- MAX_
SUPPORTED_ JSON_ DEPTH - Hard upper bound for
Limits::max_json_depth:serde_jsonrefuses to nest deeper than this regardless of configuration. - MIN_
REQUEST_ STATE_ KEY_ BYTES - Minimum length of a
requestStatesigning key.
Traits§
- Extension
- A protocol extension supported by the server.
- Into
Content - Content that can appear in a message:
&str,String(as text) and the specification’s content types. - Into
Prompt Result - Conversion of a prompt’s return value into a result.
- Into
Resource Contents - Conversion of a resource handler’s return value into contents.
- Into
Tool Error - Conversion of tool errors. Implemented for
ToolErrorand for everystd::error::Error(treated as internal). - Into
Tool Result - Conversion of a tool’s return value into a result.
- Prompt
- A prompt that can be registered with
ServerBuilder::prompt. - Resource
- A resource that can be registered with
ServerBuilder::resource. - Tool
- A tool that can be registered with
ServerBuilder::tool.
Functions§
- input_
schema_ for - Builds a tool
inputSchemafrom the JSON Schema ofT, which must describe an object (tool arguments are always a JSON object). - is_
legacy_ version - Whether a protocol version is one of the supported legacy versions.
- output_
schema_ from - Wraps a generated schema as a tool
outputSchema. - parse_
arguments - Deserializes tool arguments. A missing
argumentsmember is treated as an empty object. - parse_
optional_ uri_ var - Like
parse_uri_varfor optional (query) variables. - parse_
uri_ var - Parses a template variable for a resource handler. A value that does not parse means no such resource exists.
- schema_
for - Generates a JSON Schema (2020-12) for
T, as used ininputSchemaandoutputSchema. The root$schemaandtitlekeys are removed: 2020-12 is the default dialect, and the title would expose a Rust type name.
Type Aliases§
- CallFn
- Entry point of a tool: deserializes the arguments synchronously (borrowing the request buffer) and returns the future that runs the tool.
- Complete
Fn - A completion provider. Completion runs synchronously and must be fast.
- GetFn
- Entry point of a prompt: receives the (string) arguments of
prompts/get. - Prompt
Future - The future returned by a prompt.
- ReadFn
- Entry point of a resource: receives the requested URI and, for templates, the variables extracted from it.
- Resource
Contents - One item of a
resources/readresult. - Resource
Future - The future returned by a resource read.
- Tool
Future - The future returned by a tool invocation.
- Tool
Result - The outcome of a tool invocation.