File size: 869 Bytes
1814d17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
title: middleware
sidebarTitle: middleware
---

# `fastmcp.server.middleware`

## Functions

### `make_middleware_wrapper`

```python
make_middleware_wrapper(middleware: Middleware, call_next: CallNext[T, R]) -> CallNext[T, R]
```


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`

### `CallToolResult`

### `ListToolsResult`

### `ListResourcesResult`

### `ListResourceTemplatesResult`

### `ListPromptsResult`

### `ServerResultProtocol`

### `MiddlewareContext`


Unified context for all middleware operations.


**Methods:**

#### `copy`

```python
copy(self, **kwargs: Any) -> MiddlewareContext[T]
```

### `Middleware`


Base class for FastMCP middleware with dispatching hooks.