Built-in middleware constructors.
Middleware in FastestMCP wraps the shared operation pipeline used by local
dispatch, HTTP, and stdio. This module is the public constructor surface for
the built-in middleware implementations under FastestMCP.Middleware.*.
What Middleware Can Do
Middleware can:
- observe or log requests
- enforce limits
- rewrite metadata
- cache results
- inject synthetic tools
- catch and normalize failures
Usage
Add middleware while building a server:
server =
FastestMCP.server("docs")
|> FastestMCP.add_middleware(FastestMCP.Middleware.logging())
|> FastestMCP.add_middleware(FastestMCP.Middleware.error_handling())Each function in this module returns the concrete middleware object expected by
FastestMCP.add_middleware/2.
Summary
Functions
Builds middleware that expands local $ref pointers in JSON Schemas.
Builds detailed-timing middleware with per-operation labels.
Builds error-handling middleware with logging and counters.
Builds request-logging middleware.
Runs a ping request.
Builds middleware that exposes prompts as synthetic tools.
Builds token-bucket rate-limiting middleware.
Builds the synthetic resource-tool set used by tool injection.
Builds response-caching middleware.
Builds middleware that truncates oversized responses.
Builds retry middleware for transient failures.
Builds sliding-window rate-limiting middleware.
Builds request-logging middleware with structured output enabled.
Builds timing middleware that records total request duration.
Builds middleware that injects synthetic tools into the runtime.
Functions
Builds middleware that expands local $ref pointers in JSON Schemas.
Builds detailed-timing middleware with per-operation labels.
Builds error-handling middleware with logging and counters.
Builds request-logging middleware.
Runs a ping request.
Builds middleware that exposes prompts as synthetic tools.
Builds token-bucket rate-limiting middleware.
Builds the synthetic resource-tool set used by tool injection.
Builds response-caching middleware.
Builds middleware that truncates oversized responses.
Builds retry middleware for transient failures.
Builds sliding-window rate-limiting middleware.
Builds request-logging middleware with structured output enabled.
Builds timing middleware that records total request duration.
Builds middleware that injects synthetic tools into the runtime.