python-sdk icon indicating copy to clipboard operation
python-sdk copied to clipboard

CallToolResult type missing member structuredContent

Open stevemadere opened this issue 7 months ago • 1 comments

Describe the bug

When a tool call is made to any tool with a defined outputSchema, the server absolutely blows up if the function implementing the tool call does not include structuredContent.

This structuredContent is included in the data.result of the server's response.

On client side, it definitely gets parsed and included in the CallToolResult object returned by session.call_tool().

All great so far.

However, the definition of CallToolResult class does not allow for a member named structuredContent.

(it also does not allow for a member named structured_content so that's not the issue).

To Reproduce Steps to reproduce the behavior:

  1. Implement a tool "get_structure" with an outputSchema using the ModelContentProtocol typescript SDK.
  2. Call that tool from the python SDK: python result:CallToolResult = await session.call_tool(name="get_structure",arguments={}) print(f"result.structuredContent = {result.structuredContent}")
  3. Notice that the print succeeds
  4. Notice that pyright complains that Attribute "structuredContent" is unknown

Expected behavior There should be an optional member called structuredContent in the declaration of CallToolResult:

structuredContent: dict[str, Any] | list[Any] | str | int | float | bool | None = None

Screenshots

Image

Additional context Add any other context about the problem here.

stevemadere avatar May 26 '25 17:05 stevemadere

I think outputSchema and CallToolResult.structuredContent support is WIP in #685

TypeScript SDK has better support for this.

imfing avatar May 26 '25 23:05 imfing

structuredContent support added in #993 (v1.10.0)

bhosmer-ant avatar Jul 09 '25 14:07 bhosmer-ant