KEMBAR78
fix serialization issue in streamablehttp mcp tools by victordibia · Pull Request #6721 · microsoft/autogen · GitHub
Skip to content

Conversation

@victordibia
Copy link
Collaborator

@victordibia victordibia commented Jun 25, 2025

The current StreamableHttpServerParams has timedelta values that are not JSON serializable (config.dump_component.model_dump_json()).
This make is unusable in UIs like AGS that expect configs to be serializable to json,

class StreamableHttpServerParams(BaseModel):
    """Parameters for connecting to an MCP server over Streamable HTTP."""

    type: Literal["StreamableHttpServerParams"] = "StreamableHttpServerParams"

    url: str  # The endpoint URL.
    headers: dict[str, Any] | None = None  # Optional headers to include in requests.
    timeout: timedelta = timedelta(seconds=30)  # HTTP timeout for regular operations.
    sse_read_timeout: timedelta = timedelta(seconds=60 * 5)  # Timeout for SSE read operations.
    terminate_on_close: bool = True

This PR uses float for time outs and casts it to timedelta as needed.

class StreamableHttpServerParams(BaseModel):
    """Parameters for connecting to an MCP server over Streamable HTTP."""

    type: Literal["StreamableHttpServerParams"] = "StreamableHttpServerParams"

    url: str  # The endpoint URL.
    headers: dict[str, Any] | None = None  # Optional headers to include in requests.
    timeout: float = 30.0  # HTTP timeout for regular operations in seconds.
    sse_read_timeout: float = 300.0  # Timeout for SSE read operations in seconds.
    terminate_on_close: bool = True

Why are these changes needed?

Related issue number

Checks

@victordibia
Copy link
Collaborator Author

@withsmilo ,
Do you want to take a look here as this touches some of your earlier contributions.
Thanks.

@codecov
Copy link

codecov bot commented Jun 25, 2025

Codecov Report

Attention: Patch coverage is 33.33333% with 4 lines in your changes missing coverage. Please review.

Project coverage is 79.73%. Comparing base (9b8dc8d) to head (84f7c31).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../autogen-ext/src/autogen_ext/tools/mcp/_session.py 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6721      +/-   ##
==========================================
- Coverage   79.75%   79.73%   -0.02%     
==========================================
  Files         232      232              
  Lines       17401    17403       +2     
==========================================
- Hits        13878    13877       -1     
- Misses       3523     3526       +3     
Flag Coverage Δ
unittests 79.73% <33.33%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rickyloynd-microsoft rickyloynd-microsoft self-requested a review June 25, 2025 17:50
@victordibia victordibia merged commit 1183962 into main Jun 25, 2025
66 of 67 checks passed
@victordibia victordibia deleted the mcp_streamable_serializtion branch June 25, 2025 19:28
@victordibia
Copy link
Collaborator Author

mcp_776_streaming_1080.mp4

withsmilo added a commit to withsmilo/autogen that referenced this pull request Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants