Send a tools/list request. Args: params: Full pagination parameters including cursor and any future fields
(self, *, params: types.PaginatedRequestParams | None = None)
| 751 | ) |
| 752 | |
| 753 | async def list_tools(self, *, params: types.PaginatedRequestParams | None = None) -> types.ListToolsResult: |
| 754 | """Send a tools/list request. |
| 755 | |
| 756 | Args: |
| 757 | params: Full pagination parameters including cursor and any future fields |
| 758 | """ |
| 759 | result = await self.send_request( |
| 760 | types.ListToolsRequest(params=params), |
| 761 | types.ListToolsResult, |
| 762 | ) |
| 763 | |
| 764 | if self._negotiated_version in MODERN_PROTOCOL_VERSIONS: |
| 765 | # 2026-07-28: clients MUST drop tools whose x-mcp-header annotations are invalid. |
| 766 | kept: list[types.Tool] = [] |
| 767 | for tool in result.tools: |
| 768 | if (reason := find_invalid_x_mcp_header(tool.input_schema)) is not None: |
| 769 | logger.warning("dropping tool %r: invalid x-mcp-header (%s)", tool.name, reason) |
| 770 | continue |
| 771 | kept.append(tool) |
| 772 | result.tools = kept |
| 773 | |
| 774 | # Cache tool output schemas for future validation |
| 775 | # Note: don't clear the cache, as we may be using a cursor |
| 776 | for tool in result.tools: |
| 777 | self._tool_output_schemas[tool.name] = tool.output_schema |
| 778 | |
| 779 | return result |
| 780 | |
| 781 | @deprecated("The roots capability is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning) |
| 782 | async def send_roots_list_changed(self) -> None: |
no test coverage detected