mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-24 06:24:18 +02:00
Update middleware imports and documentation
This commit is contained in:
parent
d7969b159e
commit
2690878412
4 changed files with 29 additions and 8 deletions
|
|
@ -1,5 +1,9 @@
|
|||
# FastMCP Development Guidelines
|
||||
|
||||
## Git
|
||||
|
||||
This project uses `pre-commit` to run checks on all commits. If your commit doesn't pass the checks, it will not be created. Do not attempt to amend commits to pass checks.
|
||||
|
||||
## Documentation
|
||||
|
||||
- Documentation uses the Mintlify framework
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ class ComponentAccessMiddleware(Middleware):
|
|||
|
||||
### Working with Listing Results
|
||||
|
||||
For listing operations, you can inspect and modify the FastMCP components directly:
|
||||
For listing operations, the middleware `call_next` function returns a special object that contains the full list of FastMCP components prior to being converted to MCP format. You can modify this object and return it to the client. Specifically, the `ListToolsResult`, `ListResourcesResult`, `ListResourceTemplatesResult`, and `ListPromptsResult` objects can all be imported from fastmcp.server.middleware for this purpose. For example:
|
||||
|
||||
```python
|
||||
from fastmcp.server.middleware import Middleware, MiddlewareContext, ListToolsResult
|
||||
|
|
|
|||
|
|
@ -1,6 +1,19 @@
|
|||
from .middleware import Middleware, MiddlewareContext
|
||||
from .middleware import (
|
||||
Middleware,
|
||||
MiddlewareContext,
|
||||
CallNext,
|
||||
ListToolsResult,
|
||||
ListResourcesResult,
|
||||
ListResourceTemplatesResult,
|
||||
ListPromptsResult,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"Middleware",
|
||||
"MiddlewareContext",
|
||||
"CallNext",
|
||||
"ListToolsResult",
|
||||
"ListResourcesResult",
|
||||
"ListResourceTemplatesResult",
|
||||
"ListPromptsResult",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -25,6 +25,16 @@ from fastmcp.tools.tool import Tool
|
|||
if TYPE_CHECKING:
|
||||
from fastmcp.server.context import Context
|
||||
|
||||
__all__ = [
|
||||
"Middleware",
|
||||
"MiddlewareContext",
|
||||
"CallNext",
|
||||
"ListToolsResult",
|
||||
"ListResourcesResult",
|
||||
"ListResourceTemplatesResult",
|
||||
"ListPromptsResult",
|
||||
]
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
|
@ -52,12 +62,6 @@ ServerResultT = TypeVar(
|
|||
)
|
||||
|
||||
|
||||
@dataclass(kw_only=True)
|
||||
class CallToolResult:
|
||||
content: list[mt.Content]
|
||||
isError: bool = False
|
||||
|
||||
|
||||
@dataclass(kw_only=True)
|
||||
class ListToolsResult:
|
||||
tools: dict[str, Tool]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue