|
53 | 53 |
|
54 | 54 |
|
55 | 55 | if TYPE_CHECKING: |
56 | | - from typing import Any, Callable, ContextManager, Optional, Tuple, Union |
| 56 | + from typing import Any, Awaitable, Callable, ContextManager, Optional, Tuple, Union |
57 | 57 |
|
| 58 | + from mcp.types import ( |
| 59 | + CallToolResult, |
| 60 | + GetPromptResult, |
| 61 | + InputRequiredResult, |
| 62 | + ReadResourceResult, |
| 63 | + ) |
58 | 64 | from starlette.types import Receive, Scope, Send # type: ignore[import-not-found] |
59 | 65 |
|
60 | 66 | from sentry_sdk.traces import StreamedSpan |
@@ -496,12 +502,12 @@ def _prepare_handler_data( |
496 | 502 |
|
497 | 503 |
|
498 | 504 | async def _tool_handler_wrapper( |
499 | | - func: "Callable[..., Any]", |
| 505 | + func: "Callable[..., Awaitable[Union[CallToolResult, InputRequiredResult]]]", |
500 | 506 | original_args: "tuple[Any, ...]", |
501 | 507 | original_kwargs: "Optional[dict[str, Any]]" = None, |
502 | 508 | self: "Optional[Any]" = None, |
503 | 509 | force_await: bool = True, |
504 | | -): |
| 510 | +) -> "Union[CallToolResult, InputRequiredResult]": |
505 | 511 | """ |
506 | 512 | Wrapper for MCP tool handlers. |
507 | 513 | Creates and manages the MCP span and attaches all attributes on the span. |
@@ -614,12 +620,12 @@ async def _tool_handler_wrapper( |
614 | 620 |
|
615 | 621 |
|
616 | 622 | async def _prompt_handler_wrapper( |
617 | | - func: "Callable[..., Any]", |
| 623 | + func: "Callable[..., Awaitable[Union[GetPromptResult, InputRequiredResult]]]", |
618 | 624 | original_args: "tuple[Any, ...]", |
619 | 625 | original_kwargs: "Optional[dict[str, Any]]" = None, |
620 | 626 | self: "Optional[Any]" = None, |
621 | 627 | force_await: bool = True, |
622 | | -): |
| 628 | +) -> "Union[GetPromptResult, InputRequiredResult]": |
623 | 629 | """ |
624 | 630 | Wrapper for MCP prompt handlers. |
625 | 631 | Creates and manages the MCP span and attaches all attributes on the span. |
@@ -730,12 +736,12 @@ async def _prompt_handler_wrapper( |
730 | 736 |
|
731 | 737 |
|
732 | 738 | async def _resource_handler_wrapper( |
733 | | - func: "Callable[..., Any]", |
| 739 | + func: "Callable[..., Awaitable[Union[ReadResourceResult, InputRequiredResult]]]", |
734 | 740 | original_args: "tuple[Any, ...]", |
735 | 741 | original_kwargs: "Optional[dict[str, Any]]" = None, |
736 | 742 | self: "Optional[Any]" = None, |
737 | 743 | force_await: bool = True, |
738 | | -): |
| 744 | +) -> "Union[ReadResourceResult, InputRequiredResult]": |
739 | 745 | """ |
740 | 746 | Wrapper for MCP resource handlers. |
741 | 747 | Creates and manages the MCP span and attaches all attributes on the span. |
|
0 commit comments