Skip to main content

Crate flymcprust_core

Crate flymcprust_core 

Source
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§

AutoPrompt
A prompt registered by #[prompt] for automatic discovery.
AutoResource
A resource registered by #[resource] for automatic discovery.
AutoTool
A tool registered by #[tool] for automatic discovery.
Completion
Completion values. Results longer than MAX_COMPLETION_VALUES are truncated, with total and hasMore set accordingly.
CompletionRequest
What the client asked to complete.
Ctx
Context of the request being handled. Declare a Ctx parameter 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 outputSchema is generated from T, and the result carries both structuredContent and the serialized JSON as text, as the specification recommends.
LegacySession
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.
MirroredParam
A tool parameter mirrored into an Mcp-Param-{name} header.
PromptArguments
The arguments of a prompts/get request.
PromptDef
A registered prompt: its protocol description plus its entry point.
ResourceDef
A registered resource or resource template.
Server
A built MCP server. Cheap to clone; all clones share one registry.
ServerBuilder
Builds a Server.
State
Shared application state registered with ServerBuilder::state. Declare a State<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 makes ServerBuilder::build fail.
StateRequirement
A shared-state type a handler needs.
ToolDef
A registered tool: its protocol description plus its entry point.
ToolError
An error raised by a tool, resource or prompt handler.
TransportContext
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.
UriTemplateError
A template that cannot be parsed or is not supported.
UriVars
Variable values extracted from a URI by UriTemplate::matches.

Enums§

BuildError
Errors detected while building a server.
Elicitation
The outcome of an elicitation.
ErrorKind
How an error relates to the request, independent of transport. HTTP uses it to pick a status code (400, 404, 200 or 500).
ParamKind
JSON Schema primitive type of a mirrored parameter.
ToolOutput
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_json refuses to nest deeper than this regardless of configuration.
MIN_REQUEST_STATE_KEY_BYTES
Minimum length of a requestState signing key.

Traits§

Extension
A protocol extension supported by the server.
IntoContent
Content that can appear in a message: &str, String (as text) and the specification’s content types.
IntoPromptResult
Conversion of a prompt’s return value into a result.
IntoResourceContents
Conversion of a resource handler’s return value into contents.
IntoToolError
Conversion of tool errors. Implemented for ToolError and for every std::error::Error (treated as internal).
IntoToolResult
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 inputSchema from the JSON Schema of T, 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 arguments member is treated as an empty object.
parse_optional_uri_var
Like parse_uri_var for 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 in inputSchema and outputSchema. The root $schema and title keys 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.
CompleteFn
A completion provider. Completion runs synchronously and must be fast.
GetFn
Entry point of a prompt: receives the (string) arguments of prompts/get.
PromptFuture
The future returned by a prompt.
ReadFn
Entry point of a resource: receives the requested URI and, for templates, the variables extracted from it.
ResourceContents
One item of a resources/read result.
ResourceFuture
The future returned by a resource read.
ToolFuture
The future returned by a tool invocation.
ToolResult
The outcome of a tool invocation.