---
title: tool_injection
sidebarTitle: tool_injection
---
# `fastmcp.server.middleware.tool_injection`
A middleware for injecting tools into the MCP server context.
## Functions
### `list_prompts`
```python
list_prompts(context: Context) -> list[Prompt]
```
List prompts available on the server.
### `get_prompt`
```python
get_prompt(context: Context, name: Annotated[str, 'The name of the prompt to render.'], arguments: Annotated[dict[str, Any] | None, 'The arguments to pass to the prompt.'] = None) -> mcp.types.GetPromptResult
```
Render a prompt available on the server.
### `list_resources`
```python
list_resources(context: Context) -> list[mcp.types.Resource]
```
List resources available on the server.
### `read_resource`
```python
read_resource(context: Context, uri: Annotated[AnyUrl | str, 'The URI of the resource to read.']) -> ResourceResult
```
Read a resource available on the server.
## Classes
### `ToolInjectionMiddleware`
A middleware for injecting tools into the context.
**Methods:**
#### `on_list_tools`
```python
on_list_tools(self, context: MiddlewareContext[mcp.types.ListToolsRequest], call_next: CallNext[mcp.types.ListToolsRequest, Sequence[Tool]]) -> Sequence[Tool]
```
Inject tools into the response.
#### `on_call_tool`
```python
on_call_tool(self, context: MiddlewareContext[mcp.types.CallToolRequestParams], call_next: CallNext[mcp.types.CallToolRequestParams, ToolResult]) -> ToolResult
```
Intercept tool calls to injected tools.
### `PromptToolMiddleware`
A middleware for injecting prompts as tools into the context.
.. deprecated::
Use ``fastmcp.server.transforms.PromptsAsTools`` instead.
### `ResourceToolMiddleware`
A middleware for injecting resources as tools into the context.
.. deprecated::
Use ``fastmcp.server.transforms.ResourcesAsTools`` instead.