Skip to main content

fastmcp.server.middleware.middleware

Functions

make_middleware_wrapper

Create a wrapper that applies a single middleware to a context. The closure bakes in the middleware and call_next function, so it can be passed to other functions that expect a call_next function.

Classes

CallNext

MiddlewareContext

Unified context for all middleware operations. Methods:

copy

Middleware

Base class for FastMCP middleware with dispatching hooks. Methods:

on_message

on_request

on_notification

on_initialize

on_call_tool

on_read_resource

on_get_prompt

on_list_tools

on_list_resources

on_list_resource_templates

on_list_prompts