MCPcopy
hub / github.com/modelcontextprotocol/python-sdk / list_tools

Method list_tools

src/mcp/client/session.py:753–779  ·  view source on GitHub ↗

Send a tools/list request. Args: params: Full pagination parameters including cursor and any future fields

(self, *, params: types.PaginatedRequestParams | None = None)

Source from the content-addressed store, hash-verified

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:

Callers 1

_validate_tool_resultMethod · 0.95

Calls 3

send_requestMethod · 0.95
warningMethod · 0.80

Tested by

no test coverage detected