fastmcp/docs/servers
William Easton f5dbabff4e
Add ToolInjectionMiddleware + Tools for Read/List Resource/Prompt for Client Compat (#2142)
* Add compatibility tools contrib module

Implements four standalone tools that expose resources and prompts
as callable tools for clients that only support the tools capability.

Features:
- list_resources: List all available resources
- get_resource: Read a resource by URI
- list_prompts: List all available prompts
- get_prompt: Get a prompt with optional arguments

The tools use Context to access the server instance and can be easily
added to any FastMCP server using the add_compatibility_tools helper
or by adding individual tool instances directly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: William Easton <strawgate@users.noreply.github.com>

* Simplify compatibility tools to return raw MCP protocol objects

Return raw MCP protocol objects (ListResourcesResult, ReadResourceResult,
ListPromptsResult, GetPromptResult) instead of custom dictionaries. This
makes the tools simpler and more predictable by directly exposing what
the client methods return.

Co-authored-by: William Easton <strawgate@users.noreply.github.com>

* Add tool injection middleware

* cleanup contrib module

* More clean-up

* Clean up tool injection middleware.

* Update src/fastmcp/server/middleware/tool_injection.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add tool injection docs

* Small cleanup of prompt middleware

* PR Feedback

* Fix tool injection tests

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: William Easton <strawgate@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-24 18:06:58 -04:00
..
auth Add platform-aware OAuth token persistence (#2218) 2025-10-22 20:42:24 -04:00
composition.mdx Add storage backend documentation (#2137) 2025-10-19 19:24:13 -04:00
context.mdx Clarify context is scoped to single MCP request (#2099) 2025-10-15 06:00:03 -07:00
elicitation.mdx Add storage backend documentation (#2137) 2025-10-19 19:24:13 -04:00
icons.mdx Add storage backend documentation (#2137) 2025-10-19 19:24:13 -04:00
logging.mdx Also push client messages (info/warn/debug) to server debug log (#2063) 2025-10-14 11:38:26 -07:00
middleware.mdx Add ToolInjectionMiddleware + Tools for Read/List Resource/Prompt for Client Compat (#2142) 2025-10-24 18:06:58 -04:00
progress.mdx Update parameter capitalization 2025-06-28 15:06:16 -04:00
prompts.mdx Implement icon support (#2121) 2025-10-17 17:28:08 -04:00
proxy.mdx Improve docs on prefix rules (#2028) 2025-10-08 19:57:14 -04:00
resources.mdx Implement icon support (#2121) 2025-10-17 17:28:08 -04:00
sampling.mdx Move sampling fallback handler docs to server section (#2163) 2025-10-21 10:02:11 -04:00
server.mdx Implement icon support (#2121) 2025-10-17 17:28:08 -04:00
storage-backends.mdx Add platform-aware OAuth token persistence (#2218) 2025-10-22 20:42:24 -04:00
tools.mdx Update content type in advanced_tool function (#2147) 2025-10-20 08:43:35 -04:00